Skip to content

Commit

Permalink
🚸 Notify when there are keybind conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Dec 28, 2024
1 parent fa33f69 commit 7a7a758
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Loop/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -20429,6 +20429,9 @@
}
}
}
},
"There are other keybinds that conflict with this key combination." : {

},
"Thickness" : {
"extractionState" : "manual",
Expand Down
17 changes: 17 additions & 0 deletions Loop/Luminare/Settings/Keybindings/KeybindItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ struct KeybindItemView: View {
.modifier(LuminareBordered())
} else {
HStack(spacing: 6) {
let hasConflicts = hasDuplicateKeybinds()

if hasConflicts {
LuminareInfoView(
"There are other keybinds that conflict with this key combination.",
.red
)
}

HStack {
ForEach(triggerKey.sorted().compactMap(\.systemImage), id: \.self) { image in
Text("\(Image(systemName: image))")
Expand All @@ -129,6 +138,7 @@ struct KeybindItemView: View {
Image(systemName: "plus")

Keycorder($keybind)
.opacity(hasConflicts ? 0.5 : 1)
}
.fixedSize()
}
Expand Down Expand Up @@ -182,6 +192,13 @@ struct KeybindItemView: View {
.help("Customize this keybind's action.")
}

/// Checks if there are any existing keybinds with the same key combination
func hasDuplicateKeybinds() -> Bool {
Defaults[.keybinds]
.filter { $0.keybind == keybind.keybind }
.count > 1
}

func directionPicker() -> some View {
VStack {
Button {
Expand Down

0 comments on commit 7a7a758

Please sign in to comment.