Add Unselected Controller menu to Settings

This commit is contained in:
Stossy11 2024-12-18 08:26:47 +11:00
parent 3e657d7229
commit 06f3c6d20e
2 changed files with 27 additions and 9 deletions

View File

@ -123,6 +123,33 @@ struct SettingsView: View {
// Input Selector // Input Selector
Section { Section {
if !controllersList.filter({ !currentControllers.contains($0) }).isEmpty {
DisclosureGroup("Unselected Controllers") {
ForEach(controllersList.filter { !currentControllers.contains($0) }) { controller in
var customBinding: Binding<Bool> {
Binding(
get: { currentControllers.contains(controller) },
set: { bool in
if !bool {
currentControllers.removeAll(where: { $0.id == controller.id })
} else {
currentControllers.append(controller)
}
}
)
}
Toggle(isOn: customBinding) {
Text(controller.name)
.font(.body)
}
.tint(.blue)
}
}
}
ForEach(controllersList) { controller in ForEach(controllersList) { controller in
var customBinding: Binding<Bool> { var customBinding: Binding<Bool> {
@ -154,15 +181,6 @@ struct SettingsView: View {
Text("Player \(controller)") Text("Player \(controller)")
} }
} else {
Toggle(isOn: customBinding) {
HStack {
Text(controller.name)
.font(.body)
}
}
.tint(.blue)
} }
} }
} header: { } header: {