diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-31 23:41:31 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-31 23:41:31 -0600 |
commit | 3d926c76f41f9fb40a4a17322d53eb2fd3383b69 (patch) | |
tree | 7b7ca05e7a4dbb5d5b24b48b37da6b5d0db44ca3 /iosApp | |
parent | 90a9f7028053b3c4a56b88fcc52de675db5b9ab9 (diff) | |
download | etbsa-trackermap-mobile-3d926c76f41f9fb40a4a17322d53eb2fd3383b69.tar.gz etbsa-trackermap-mobile-3d926c76f41f9fb40a4a17322d53eb2fd3383b69.tar.bz2 etbsa-trackermap-mobile-3d926c76f41f9fb40a4a17322d53eb2fd3383b69.zip |
- Adapter iOS app to changes in UnitsController
- Added getHourmeter() method to UnitInformation
- Added missing license headers
Diffstat (limited to 'iosApp')
-rw-r--r-- | iosApp/iosApp/Devices/DeviceRow.swift | 16 | ||||
-rw-r--r-- | iosApp/iosApp/Units/UnitsViewModel.swift | 8 |
2 files changed, 15 insertions, 9 deletions
diff --git a/iosApp/iosApp/Devices/DeviceRow.swift b/iosApp/iosApp/Devices/DeviceRow.swift index 9873c8e..e7966d2 100644 --- a/iosApp/iosApp/Devices/DeviceRow.swift +++ b/iosApp/iosApp/Devices/DeviceRow.swift @@ -104,15 +104,13 @@ struct DeviceRow: View { } /* Hourmeter */ - if let hourmeter = unit.position?.attributes["hours"] { - if let hourmeter = Serialization.companion.longOrNull(json: hourmeter) { - HStack { - Label(Formatter.companion.formatHours( - millis: Int64(truncating: hourmeter)), - systemImage: "timer") - .labelStyle(SmallLabelStyle()) - Spacer() - } + if let hourmeter = unit.getHourmeter() { + HStack { + Label(Formatter.companion.formatHours( + millis: Int64(truncating: hourmeter)), + systemImage: "timer") + .labelStyle(SmallLabelStyle()) + Spacer() } } diff --git a/iosApp/iosApp/Units/UnitsViewModel.swift b/iosApp/iosApp/Units/UnitsViewModel.swift index 33f9729..04c0436 100644 --- a/iosApp/iosApp/Units/UnitsViewModel.swift +++ b/iosApp/iosApp/Units/UnitsViewModel.swift @@ -23,6 +23,8 @@ class UnitsViewModel: ObservableObject { @Inject var unitsController: UnitsController @Inject var geofenceController: GeofencesController + let mainScope = MainScope.companion.createMainScope() + enum UnitsDisplayMode { case map case list @@ -54,9 +56,14 @@ class UnitsViewModel: ObservableObject { @Published var camera: Camera = Camera() init() { + unitsController.fetchUnits(scope: mainScope) setupObservers() } + deinit { + MainScope.companion.cancelScope(scope: mainScope) + } + private func setupObservers() { let unitsCollector = Collector<[UnitInformation]>(callback: setUnits) unitsController.displayedUnitsFlow.collect(collector: unitsCollector) { unit, error in } @@ -66,6 +73,7 @@ class UnitsViewModel: ObservableObject { } private func setUnits(units: [UnitInformation]) { + print("Positions") self.units = units } |