diff --git a/Yattee/Views/Settings/PlayerControls/MiniPlayerEditorView.swift b/Yattee/Views/Settings/PlayerControls/MiniPlayerEditorView.swift index a2e15605..719ae5eb 100644 --- a/Yattee/Views/Settings/PlayerControls/MiniPlayerEditorView.swift +++ b/Yattee/Views/Settings/PlayerControls/MiniPlayerEditorView.swift @@ -105,17 +105,31 @@ struct MiniPlayerEditorView: View { @ViewBuilder private func buttonRow(for config: ControlButtonConfiguration) -> some View { - if config.buttonType.hasSettings { - NavigationLink { - MiniPlayerButtonConfigurationView( - buttonID: config.id, - viewModel: viewModel - ) - } label: { + Group { + if config.buttonType.hasSettings { + NavigationLink { + MiniPlayerButtonConfigurationView( + 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.miniPlayerButtons.firstIndex(where: { $0.id == config.id }) { + viewModel.removeMiniPlayerButton(at: index) + } + } label: { + Label( + String(localized: "settings.playerControls.delete"), + systemImage: "trash" + ) + } } } diff --git a/Yattee/Views/Settings/PlayerControls/PlayerPillEditorView.swift b/Yattee/Views/Settings/PlayerControls/PlayerPillEditorView.swift index 7c67b4fd..7ef0bce3 100644 --- a/Yattee/Views/Settings/PlayerControls/PlayerPillEditorView.swift +++ b/Yattee/Views/Settings/PlayerControls/PlayerPillEditorView.swift @@ -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" + ) + } } } diff --git a/Yattee/Views/Settings/PlayerControls/SectionEditorView.swift b/Yattee/Views/Settings/PlayerControls/SectionEditorView.swift index f9590c93..a409dcfb 100644 --- a/Yattee/Views/Settings/PlayerControls/SectionEditorView.swift +++ b/Yattee/Views/Settings/PlayerControls/SectionEditorView.swift @@ -81,6 +81,18 @@ struct SectionEditorView: View { } label: { ButtonRow(configuration: button) } + .contextMenu { + if viewModel.canEditActivePreset { + Button(role: .destructive) { + removeButton(id: button.id) + } label: { + Label( + String(localized: "settings.playerControls.delete"), + systemImage: "trash" + ) + } + } + } } .onMove { source, destination in // Update local state immediately @@ -93,16 +105,10 @@ struct SectionEditorView: View { ) } .onDelete { indexSet in - // Get button IDs before removing from local state let buttonIDs = indexSet.map { buttons[$0].id } - // Update local state immediately - buttons.remove(atOffsets: indexSet) - // Sync to view model for id in buttonIDs { - viewModel.removeButtonSync(id, from: sectionType) + removeButton(id: id) } - // Update available types - syncAvailableTypes() } } header: { Text(String(localized: "settings.playerControls.addedButtons")) @@ -175,6 +181,15 @@ struct SectionEditorView: View { } } + private func removeButton(id: UUID) { + // Update local state immediately + buttons.removeAll { $0.id == id } + // Sync to view model + viewModel.removeButtonSync(id, from: sectionType) + // Update available types + syncAvailableTypes() + } + private func addButton(_ buttonType: ControlButtonType) { // Create new config and add to local state immediately let config = ControlButtonConfiguration.defaultConfiguration(for: buttonType)