aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Details/DetailsView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Details/DetailsView.swift')
-rw-r--r--iosApp/iosApp/Details/DetailsView.swift37
1 files changed, 15 insertions, 22 deletions
diff --git a/iosApp/iosApp/Details/DetailsView.swift b/iosApp/iosApp/Details/DetailsView.swift
index 25c8611..2c7418b 100644
--- a/iosApp/iosApp/Details/DetailsView.swift
+++ b/iosApp/iosApp/Details/DetailsView.swift
@@ -19,37 +19,30 @@ import SwiftUI
import shared
struct DetailsView: View {
- @ObservedObject var detailsViewModel = DetailsViewModel()
-
@Binding var isPresented: Bool
@State var action: DeviceRow.Action
- var id: Int32?
+ var unit: UnitInformation?
- init(isPresented: Binding<Bool>, action: DeviceRow.Action, forId id: Int32?) {
+ init(isPresented: Binding<Bool>, action: DeviceRow.Action, for unit: UnitInformation?) {
self._isPresented = isPresented
self.action = action
- self.id = id
- if let id = id {
- self.detailsViewModel.fetchUnit(id: id)
- }
+ self.unit = unit
}
var body: some View {
NavigationView {
VStack {
- if id != nil {
- if let unit = detailsViewModel.unit {
- switch action {
- case .details:
- UnitInformationView(unit: unit)
- case .reports:
- UnitReportsView(unit: unit)
- case .commands:
- UnitCommandsView(unit: unit)
- }
- } else {
- LoadingView()
+ if let unit = unit {
+ switch action {
+ case .details:
+ UnitInformationView(unit: unit)
+ case .reports:
+ UnitReportsView(unit: unit)
+ case .commands:
+ UnitCommandsView(unit: unit)
}
+ } else {
+ LoadingView()
}
}
.navigationBarTitleView(
@@ -61,11 +54,11 @@ struct DetailsView: View {
EmptyView()
}.pickerStyle(SegmentedPickerStyle())
)
- .navigationTitle(detailsViewModel.unit?.device.name ?? NSLocalizedString("loading", comment: ""))
+ .navigationTitle(unit?.device.name ?? NSLocalizedString("loading", comment: ""))
.navigationBarTitleDisplayMode(.large)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
- if let category = detailsViewModel.unit?.device.category {
+ if let category = unit?.device.category {
let type = Marker.companion
.categoryToMarkerType(category: category)
Image(MarkerTransformations.markerTypeToImageName(markerType: type))