mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
Remap buttons mutual exclusivity
This commit is contained in:
parent
4aa481ecb1
commit
9d4c99e713
3 changed files with 73 additions and 8 deletions
|
|
@ -857,6 +857,8 @@ struct Media: View {
|
|||
@Default(.showShuffleAndRepeat) private var showShuffleAndRepeat
|
||||
@Default(.musicAuxLeftControl) private var musicAuxLeftControl
|
||||
@Default(.musicAuxRightControl) private var musicAuxRightControl
|
||||
@State private var previousLeftAuxControl: MusicAuxiliaryControl = Defaults[.musicAuxLeftControl]
|
||||
@State private var previousRightAuxControl: MusicAuxiliaryControl = Defaults[.musicAuxRightControl]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
|
|
@ -969,6 +971,42 @@ struct Media: View {
|
|||
Defaults[.enableFullscreenMediaDetection] = hideNotchOption != .never
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
ensureAuxControlsUnique()
|
||||
previousLeftAuxControl = musicAuxLeftControl
|
||||
previousRightAuxControl = musicAuxRightControl
|
||||
}
|
||||
.onChange(of: musicAuxLeftControl) { newValue in
|
||||
if newValue == musicAuxRightControl {
|
||||
let fallback = MusicAuxiliaryControl.alternative(
|
||||
excluding: newValue,
|
||||
preferring: previousLeftAuxControl
|
||||
)
|
||||
if fallback != musicAuxRightControl {
|
||||
musicAuxRightControl = fallback
|
||||
}
|
||||
}
|
||||
|
||||
previousLeftAuxControl = newValue
|
||||
}
|
||||
.onChange(of: musicAuxRightControl) { newValue in
|
||||
if newValue == musicAuxLeftControl {
|
||||
let fallback = MusicAuxiliaryControl.alternative(
|
||||
excluding: newValue,
|
||||
preferring: previousRightAuxControl
|
||||
)
|
||||
if fallback != musicAuxLeftControl {
|
||||
musicAuxLeftControl = fallback
|
||||
}
|
||||
}
|
||||
|
||||
previousRightAuxControl = newValue
|
||||
}
|
||||
.onChange(of: showShuffleAndRepeat) { isEnabled in
|
||||
if isEnabled {
|
||||
ensureAuxControlsUnique()
|
||||
}
|
||||
}
|
||||
.navigationTitle("Media")
|
||||
}
|
||||
|
||||
|
|
@ -980,6 +1018,15 @@ struct Media: View {
|
|||
return MediaControllerType.allCases
|
||||
}
|
||||
}
|
||||
|
||||
private func ensureAuxControlsUnique() {
|
||||
guard showShuffleAndRepeat, musicAuxLeftControl == musicAuxRightControl else { return }
|
||||
|
||||
let fallback = MusicAuxiliaryControl.alternative(excluding: musicAuxLeftControl)
|
||||
if fallback != musicAuxRightControl {
|
||||
musicAuxRightControl = fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CalendarSettings: View {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue