import SwiftUI import AppKit /// B-stage appearance controls; general/modules/permissions remain D-stage work. struct AppearanceSettingsView: View { @Bindable var preferences: AppearancePreferences @State private var colorPicker = CustomColorPicker() var body: some View { Form { Section("settings.appearance") { Picker("appearance.title", selection: $preferences.appearance) { Text("appearance.system").tag(AppAppearance.system) Text("appearance.light").tag(AppAppearance.light) Text("appearance.dark").tag(AppAppearance.dark) } .pickerStyle(.segmented) Picker("accent.title", selection: $preferences.accent) { Text("accent.system").tag(AccentChoice.system) Text("accent.blue").tag(AccentChoice.blue) Text("accent.purple").tag(AccentChoice.purple) Text("accent.teal").tag(AccentChoice.teal) Text("accent.green").tag(AccentChoice.green) Text("accent.orange").tag(AccentChoice.orange) Text("accent.pink").tag(AccentChoice.pink) Text("accent.custom").tag(AccentChoice.custom) } if preferences.accent == .custom { HStack { Text("accent.custom") Spacer() CustomColorWell(preferences: preferences, picker: colorPicker) .frame(width: 44, height: 26) } } } } .background(SettingsWindowLifecycle(onClose: { colorPicker.close() })) .onChange(of: preferences.accent) { _, choice in if choice == .custom { Task { @MainActor in await Task.yield() guard preferences.accent == .custom else { return } colorPicker.show(for: preferences) } } else { colorPicker.close() } } .onAppear { NSApp.setActivationPolicy(.regular); NSApp.activate() } .formStyle(.grouped) .frame(width: 420, height: 240) .modifier(AppearanceStyle(preferences: preferences)) } }