diff options
Diffstat (limited to 'iosApp/iosApp/Devices/DevicesView.swift')
-rw-r--r-- | iosApp/iosApp/Devices/DevicesView.swift | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/iosApp/iosApp/Devices/DevicesView.swift b/iosApp/iosApp/Devices/DevicesView.swift index 07951fd..48458ca 100644 --- a/iosApp/iosApp/Devices/DevicesView.swift +++ b/iosApp/iosApp/Devices/DevicesView.swift @@ -12,33 +12,24 @@ struct DevicesView: View { @StateObject var unitsViewModel: UnitsViewModel var body: some View { - List(selection: $unitsViewModel.selectedUnit) { - ForEach(unitsViewModel.units, id: \.device.id) { unit in - DeviceRow(unit: unit, callback: { action in - switch action { - case .details: - print ("Selected details of \(unit.device.name)") - case .reports: - print ("Selected reports of \(unit.device.name)") - case .commands: - print ("Selected commands of \(unit.device.name)") - } - }) - } - } - - .navigationTitle("devices") - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button(action: unitsViewModel.toggleDisplayMode) { - Image(systemName: "map") + List(unitsViewModel.units, id: \.device.id) { unit in + DeviceRow(unit: unit, callback: { action in + switch action { + case .details: + print ("Selected details of \(unit.device.name)") + case .reports: + print ("Selected reports of \(unit.device.name)") + case .commands: + print ("Selected commands of \(unit.device.name)") } - } - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: {}) { - Image(systemName: "person") + }) + .onTapGesture { + unitsViewModel.searchQuery = "" + unitsViewModel.isEditing = false + unitsViewModel.unitsDisplayMode = .map + unitsViewModel.selectedUnit = unit + UIApplication.shared.endEditing() } - } } } } |