mirror of
https://github.com/yattee/yattee.git
synced 2026-10-24 05:32:53 +00:00
Drive macOS player control bars from presets
Render the macOS control bar button row and top bar from the active preset's sections via a new MacOSControlsSectionRenderer, replacing the hardcoded QuickTime-style rows in MacOSControlBar. Add a keepOnTop button type and macOS-specific button availability lists, and adapt the player controls settings editors (preset editor, section editor, button configuration) for macOS. Also apply the preset font style to the control bar time labels, and update the built-in macOS Default preset order (queue before transport, fullscreen at the end), bumping builtInPresetsVersion to 7.
This commit is contained in:
@@ -85,39 +85,22 @@ struct PresetEditorView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macOSDialog
|
||||
#else
|
||||
NavigationStack {
|
||||
Form {
|
||||
// Base Layout Picker (only for create mode)
|
||||
if case .create(_, _) = mode {
|
||||
Section {
|
||||
Picker(
|
||||
String(localized: "settings.playerControls.baseLayout"),
|
||||
selection: $selectedBaseLayoutID
|
||||
) {
|
||||
ForEach(baseLayouts) { preset in
|
||||
Text(preset.name).tag(preset.id as UUID?)
|
||||
}
|
||||
}
|
||||
basePicker
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
TextField(mode.placeholder, text: $name)
|
||||
.focused($isNameFocused)
|
||||
.submitLabel(.done)
|
||||
.onSubmit(saveIfValid)
|
||||
nameField
|
||||
} footer: {
|
||||
HStack {
|
||||
if trimmedName.count > LayoutPreset.maxNameLength {
|
||||
Text(String(localized: "settings.playerControls.nameTooLong"))
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
Spacer()
|
||||
Text("\(trimmedName.count)/\(LayoutPreset.maxNameLength)")
|
||||
.foregroundStyle(
|
||||
trimmedName.count > LayoutPreset.maxNameLength ? .red : .secondary
|
||||
)
|
||||
}
|
||||
nameFooter
|
||||
}
|
||||
}
|
||||
.navigationTitle(mode.title)
|
||||
@@ -145,11 +128,87 @@ struct PresetEditorView: View {
|
||||
#if os(iOS)
|
||||
.presentationDetents([.medium])
|
||||
#endif
|
||||
#if os(macOS)
|
||||
.frame(minWidth: 500, minHeight: 350)
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Shared Controls
|
||||
|
||||
private var basePicker: some View {
|
||||
Picker(
|
||||
String(localized: "settings.playerControls.baseLayout"),
|
||||
selection: $selectedBaseLayoutID
|
||||
) {
|
||||
ForEach(baseLayouts) { preset in
|
||||
Text(preset.name).tag(preset.id as UUID?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var nameField: some View {
|
||||
TextField(mode.placeholder, text: $name)
|
||||
.focused($isNameFocused)
|
||||
.submitLabel(.done)
|
||||
.onSubmit(saveIfValid)
|
||||
}
|
||||
|
||||
private var nameFooter: some View {
|
||||
HStack {
|
||||
if trimmedName.count > LayoutPreset.maxNameLength {
|
||||
Text(String(localized: "settings.playerControls.nameTooLong"))
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
Spacer()
|
||||
Text("\(trimmedName.count)/\(LayoutPreset.maxNameLength)")
|
||||
.foregroundStyle(
|
||||
trimmedName.count > LayoutPreset.maxNameLength ? .red : .secondary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - macOS Dialog
|
||||
|
||||
#if os(macOS)
|
||||
/// Compact dialog layout matching native macOS sheets (title, fields,
|
||||
/// trailing action buttons) instead of the iOS navigation-bar form.
|
||||
private var macOSDialog: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text(mode.title)
|
||||
.font(.headline)
|
||||
|
||||
if case .create(_, _) = mode {
|
||||
basePicker
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
nameField
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
nameFooter
|
||||
.font(.caption)
|
||||
}
|
||||
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(String(localized: "settings.playerControls.cancel")) {
|
||||
dismiss()
|
||||
}
|
||||
.keyboardShortcut(.cancelAction)
|
||||
|
||||
Button(mode.saveButtonTitle) {
|
||||
saveIfValid()
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.disabled(!isValid)
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 400)
|
||||
.onAppear {
|
||||
isNameFocused = true
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private func saveIfValid() {
|
||||
guard isValid else { return }
|
||||
onSave(trimmedName, selectedBaseLayoutID)
|
||||
|
||||
Reference in New Issue
Block a user