fix(menubar): 修复清理构建状态项并增加液态外观选择

This commit is contained in:
2026-10-30 17:24:39 +08:00
parent 5b71e5bd80
commit c411a8241f
12 changed files with 122 additions and 48 deletions
@@ -53,14 +53,7 @@ struct AppearanceSettingsView: View {
Form {
Section {
LabeledContent("appearance.title") {
Picker("appearance.title", selection: $preferences.appearance) {
Text("appearance.system").tag(AppAppearance.system)
Text("appearance.light").tag(AppAppearance.light)
Text("appearance.dark").tag(AppAppearance.dark)
}
.labelsHidden()
.pickerStyle(.segmented)
.fixedSize()
LiquidAppearancePicker(selection: $preferences.appearance)
}
LabeledContent("accent.title") {
Picker("accent.title", selection: $preferences.accent) {
@@ -148,6 +141,71 @@ 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 {
if reduceMotion {
selection = appearance
} else {
withAnimation(.smooth(duration: 0.24)) {
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)
}
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("appearance.title"))
}
}
private extension AppAppearance {
var title: LocalizedStringKey {
switch self {
case .system: "appearance.system"
case .light: "appearance.light"
case .dark: "appearance.dark"
}
}
var symbol: String {
switch self {
case .system: "circle.lefthalf.filled"
case .light: "sun.max.fill"
case .dark: "moon.fill"
}
}
}
private enum SettingsPage: String, CaseIterable, Identifiable {
case appearance, language, about
var id: String { rawValue }