aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Devices/DevicesView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Devices/DevicesView.swift')
-rw-r--r--iosApp/iosApp/Devices/DevicesView.swift45
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)
+ }
}
}
}