← All repositories

crossmate

A collaborative crossword app for iPhone and iPad

git clone https://code.inqk.net/crossmate.git


commit f1980095c229e708d4f1a5672440138a5b4361b5
parent b05cae15dcec44fa44358244ea9d13976ff04099
Author: Michael Camilleri <[email protected]>
Date:   Tue, 16 Jun 2026 05:24:52 +0900

Add colour selection to Settings

The user's colour could previously only be changed from the in-game
menu, leaving Settings able to set the name but not the colour shown to
other players. This commit adds a Colour row to the Profile section,
beneath Name, so both halves of the profile are editable in the same
place.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Diffstat

MCrossmate/Views/SettingsView.swift | 52++++++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 52 insertions(+), 0 deletions(-)

diff --git a/Crossmate/Views/SettingsView.swift b/Crossmate/Views/SettingsView.swift

@@ -28,6 +28,16 @@ struct SettingsView: View {
                                 .lineLimit(1)
                         }
                     }
+
+                    NavigationLink {
+                        ProfileColorEditView()
+                    } label: {
+                        HStack {
+                            Text("Colour")
+                            Spacer()
+                            colorSwatch(preferences.color)
+                        }
+                    }
                 } header: {
                     Text("Profile")
                 }
@@ -138,6 +148,12 @@ struct SettingsView: View {
 
     // MARK: - Subviews
 
+    private func colorSwatch(_ color: PlayerColor) -> some View {
+        Circle()
+            .fill(color.tint)
+            .frame(width: 20, height: 20)
+    }
+
     private enum ExternalSource: String, CaseIterable, Identifiable {
         case newYorkTimes
 
@@ -189,6 +205,42 @@ struct SettingsView: View {
     }
 }
 
+private struct ProfileColorEditView: View {
+    @Environment(PlayerPreferences.self) private var preferences
+    @Environment(\.dismiss) private var dismiss
+
+    var body: some View {
+        @Bindable var preferences = preferences
+        Form {
+            Section {
+                Picker("Colour", selection: $preferences.color) {
+                    ForEach(PlayerColor.palette) { color in
+                        Label {
+                            Text(color.name)
+                        } icon: {
+                            Circle()
+                                .fill(color.tint)
+                                .frame(width: 20, height: 20)
+                        }
+                        .tag(color)
+                    }
+                }
+                .pickerStyle(.inline)
+                .labelsHidden()
+            } footer: {
+                Text("This is the colour other players will see for your letters.")
+            }
+        }
+        .navigationTitle("Colour")
+        .navigationBarTitleDisplayMode(.inline)
+        // Mimic the native navigation-link picker, which pops back as soon as a
+        // colour is chosen.
+        .onChange(of: preferences.color) {
+            dismiss()
+        }
+    }
+}
+
 private struct ProfileNameEditView: View {
     @Environment(PlayerPreferences.self) private var preferences
     @State private var nameDraft = ""