Add context menu with delete option to player controls editor buttons

Buttons in the section, mini player, and pill editors can now be
removed via long-press/right-click context menu instead of only
swipe-to-delete. This also gives macOS a delete affordance in the
section editor, which previously had none.
This commit is contained in:
Arkadiusz Fal
2026-06-07 08:10:36 +02:00
parent 3e7d50415b
commit a0a6634d1c
3 changed files with 68 additions and 25 deletions

View File

@@ -88,17 +88,31 @@ struct PlayerPillEditorView: View {
@ViewBuilder
private func buttonRow(for config: ControlButtonConfiguration) -> some View {
if config.buttonType.hasSettings {
NavigationLink {
PillButtonConfigurationView(
buttonID: config.id,
viewModel: viewModel
)
} label: {
Group {
if config.buttonType.hasSettings {
NavigationLink {
PillButtonConfigurationView(
buttonID: config.id,
viewModel: viewModel
)
} label: {
buttonRowContent(for: config)
}
} else {
buttonRowContent(for: config)
}
} else {
buttonRowContent(for: config)
}
.contextMenu {
Button(role: .destructive) {
if let index = viewModel.pillButtons.firstIndex(where: { $0.id == config.id }) {
viewModel.removePillButton(at: index)
}
} label: {
Label(
String(localized: "settings.playerControls.delete"),
systemImage: "trash"
)
}
}
}