diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-02-06 03:48:54 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-02-06 03:48:54 -0600 |
commit | a2387a76bb3b343862baa57e3fe28ed893f6cbda (patch) | |
tree | ce4fc6c18491dd808274e5ec819b6030aeca570b /iosApp/iosApp/Devices/DevicesView.swift | |
parent | 3913ab898f2c2ecc3b638eca4681957b1cf74330 (diff) | |
download | etbsa-trackermap-mobile-a2387a76bb3b343862baa57e3fe28ed893f6cbda.tar.gz etbsa-trackermap-mobile-a2387a76bb3b343862baa57e3fe28ed893f6cbda.tar.bz2 etbsa-trackermap-mobile-a2387a76bb3b343862baa57e3fe28ed893f6cbda.zip |
Implemented details view with details tab
Diffstat (limited to 'iosApp/iosApp/Devices/DevicesView.swift')
-rw-r--r-- | iosApp/iosApp/Devices/DevicesView.swift | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/iosApp/iosApp/Devices/DevicesView.swift b/iosApp/iosApp/Devices/DevicesView.swift index e971ac6..d3a361e 100644 --- a/iosApp/iosApp/Devices/DevicesView.swift +++ b/iosApp/iosApp/Devices/DevicesView.swift @@ -19,26 +19,35 @@ import SwiftUI struct DevicesView: View { @StateObject var unitsViewModel: UnitsViewModel + @State var shouldShowView = false + @State var action: DeviceRow.Action = .details + @State var id: Int32? var body: some View { - 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)") - } - }) - .onTapGesture { - unitsViewModel.searchQuery = "" - unitsViewModel.isEditing = false - unitsViewModel.unitsDisplayMode = .map - unitsViewModel.selectedUnit = unit - UIApplication.shared.endEditing() - } + VStack { + List(unitsViewModel.units, id: \.device.id) { unit in + DeviceRow(unit: unit, callback: { action in + self.action = action + id = unit.device.id + shouldShowView = true + }) + .onTapGesture { + unitsViewModel.searchQuery = "" + unitsViewModel.isEditing = false + unitsViewModel.unitsDisplayMode = .map + unitsViewModel.selectedUnit = unit + UIApplication.shared.endEditing() + } + } + } + .sheet(isPresented: $shouldShowView) { + print("Dismissed") + } content: { + if let id = id { + DetailsView(isPresented: $shouldShowView, + action: action, + forId: id) + } } } } |