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:
Arkadiusz Fal
2026-05-31 16:55:39 +02:00
parent fa6ad2235c
commit 05bbd449f8
18 changed files with 1348 additions and 404 deletions

View File

@@ -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)