接入有界趋势、平滑滚动、菜单式外侧详情、底部操作与三语文案,装配独立外观设置和 Dock 生命周期。 合并跟随系统外观刷新、自选颜色入口与色块绘制修复,保留用户确认的配色联动、重启保存及滚动验收。 多场景视觉与长期资源验证边界仍记录于 docs。
56 lines
2.3 KiB
Swift
56 lines
2.3 KiB
Swift
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))
|
|
}
|
|
|
|
}
|