mirror of
https://github.com/yattee/yattee.git
synced 2026-07-20 22:32:01 +00:00
Add glass background theme setting for macOS control bar
Rename the macOS "Control Bar Buttons" settings entry to "Control Bar" and add an Auto/Light/Dark glass background picker on that page. The choice is stored per-preset as GlobalLayoutSettings.controlBarTheme and forces the bar's glass color scheme via glassBackground(colorScheme:).
This commit is contained in:
@@ -354,7 +354,7 @@ private struct LayoutSectionsSection: View {
|
||||
HStack {
|
||||
#if os(macOS)
|
||||
Label(
|
||||
String(localized: "settings.playerControls.controlBarButtons", defaultValue: "Control Bar Buttons"),
|
||||
String(localized: "settings.playerControls.controlBar", defaultValue: "Control Bar"),
|
||||
systemImage: "rectangle.bottomthird.inset.filled"
|
||||
)
|
||||
#else
|
||||
|
||||
@@ -15,6 +15,7 @@ struct SectionEditorView: View {
|
||||
// Local state for immediate UI updates
|
||||
@State private var buttons: [ControlButtonConfiguration] = []
|
||||
@State private var availableTypes: [ControlButtonType] = []
|
||||
@State private var controlBarTheme: ControlsTheme = .system
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
@@ -45,6 +46,29 @@ struct SectionEditorView: View {
|
||||
.listRowBackground(Color.clear)
|
||||
#endif
|
||||
|
||||
// The macOS bar draws a glass capsule whose appearance can be forced.
|
||||
#if os(macOS)
|
||||
if sectionType == .bottom {
|
||||
Section {
|
||||
Picker(
|
||||
String(localized: "settings.playerControls.glassBackground", defaultValue: "Glass Background"),
|
||||
selection: $controlBarTheme
|
||||
) {
|
||||
ForEach(ControlsTheme.allCases, id: \.self) { theme in
|
||||
Text(glassBackgroundLabel(for: theme)).tag(theme)
|
||||
}
|
||||
}
|
||||
.disabled(!viewModel.canEditActivePreset)
|
||||
.onChange(of: controlBarTheme) { _, newTheme in
|
||||
guard newTheme != viewModel.currentLayout.globalSettings.controlBarTheme else { return }
|
||||
viewModel.updateGlobalSettingsSync { $0.controlBarTheme = newTheme }
|
||||
}
|
||||
} header: {
|
||||
Text(String(localized: "settings.playerControls.appearance"))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Added buttons
|
||||
Section {
|
||||
ForEach(buttons) { button in
|
||||
@@ -139,6 +163,7 @@ struct SectionEditorView: View {
|
||||
case .bottom:
|
||||
buttons = preset.layout.bottomSection.buttons
|
||||
}
|
||||
controlBarTheme = preset.layout.globalSettings.controlBarTheme
|
||||
syncAvailableTypes()
|
||||
}
|
||||
|
||||
@@ -160,12 +185,27 @@ struct SectionEditorView: View {
|
||||
viewModel.addButtonSync(buttonType, to: sectionType)
|
||||
}
|
||||
|
||||
#if os(macOS)
|
||||
private func glassBackgroundLabel(for theme: ControlsTheme) -> String {
|
||||
switch theme {
|
||||
case .system:
|
||||
return String(localized: "controls.theme.auto", defaultValue: "Auto")
|
||||
case .light, .dark:
|
||||
return theme.displayName
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private var sectionTitle: String {
|
||||
switch sectionType {
|
||||
case .top:
|
||||
return String(localized: "settings.playerControls.topButtons")
|
||||
case .bottom:
|
||||
#if os(macOS)
|
||||
return String(localized: "settings.playerControls.controlBar", defaultValue: "Control Bar")
|
||||
#else
|
||||
return String(localized: "settings.playerControls.bottomButtons")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user