refactor(settings): 统一单色下拉选择器并收窄窗口

This commit is contained in:
2026-11-03 21:04:03 +08:00
parent 9a1f072356
commit 94922b2b9e
3 changed files with 21 additions and 52 deletions
@@ -32,7 +32,8 @@ struct AppearanceSettingsView: View {
}
.background(SettingsWindowLifecycle(title: AppLocalization.string("settings.title", locale: locale),
requestID: presentation.requestID))
.frame(minWidth: 600, idealWidth: 640, minHeight: 420, idealHeight: 460)
.frame(width: 520)
.frame(minHeight: 420, idealHeight: 460)
.modifier(AppearanceStyle(preferences: preferences, refreshContentOnChange: true))
}
@@ -40,7 +41,15 @@ struct AppearanceSettingsView: View {
Form {
Section {
LabeledContent("appearance.title") {
LiquidAppearancePicker(selection: $preferences.appearance)
Picker("appearance.title", selection: $preferences.appearance) {
ForEach(AppAppearance.allCases) { appearance in
Text(appearance.title).tag(appearance)
}
}
.pickerStyle(.menu)
.labelsHidden()
.fixedSize()
.tint(.primary)
}
LabeledContent("language.title") {
Picker("language.title", selection: $language.language) {
@@ -49,8 +58,10 @@ struct AppearanceSettingsView: View {
Text(verbatim: "繁體中文").tag(AppLanguage.traditionalChinese)
Text(verbatim: "English").tag(AppLanguage.english)
}
.pickerStyle(.menu)
.labelsHidden()
.fixedSize()
.tint(.primary)
}
}
Section {
@@ -99,49 +110,6 @@ struct AppearanceSettingsView: View {
}
}
private struct LiquidAppearancePicker: View {
@Binding var selection: AppAppearance
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@Namespace private var selectionNamespace
var body: some View {
GlassEffectContainer(spacing: 10) {
HStack(spacing: 4) {
ForEach(AppAppearance.allCases) { appearance in
Button {
// Theme changes must not animate the native tab view / Form hierarchy.
selection = appearance
} label: {
Label(appearance.title, systemImage: appearance.symbol)
.labelStyle(.titleAndIcon)
.font(.system(size: 13, weight: .medium))
.foregroundStyle(selection == appearance ? .primary : .secondary)
.padding(.horizontal, 11)
.frame(minWidth: 108, minHeight: 34)
.contentShape(.capsule)
.background {
if selection == appearance {
Capsule()
.fill(.clear)
.glassEffect(.regular.interactive(), in: .capsule)
.glassEffectID("appearance-selection", in: selectionNamespace)
.glassEffectTransition(.matchedGeometry)
}
}
}
.buttonStyle(.plain)
.accessibilityAddTraits(selection == appearance ? .isSelected : [])
}
}
.padding(4)
.glassEffect(.regular, in: .capsule)
}
.animation(reduceMotion ? nil : .smooth(duration: 0.24), value: selection)
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("appearance.title"))
}
}
private extension AppAppearance {
var title: LocalizedStringKey {
switch self {
@@ -151,13 +119,6 @@ private extension AppAppearance {
}
}
var symbol: String {
switch self {
case .system: "circle.lefthalf.filled"
case .light: "sun.max.fill"
case .dark: "moon.fill"
}
}
}
private enum SettingsPage: Hashable {