mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user