aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iosApp/iosApp.xcodeproj/project.pbxproj8
-rw-r--r--iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstatebin29011 -> 36126 bytes
-rw-r--r--iosApp/iosApp/Authentication/LoginView.swift12
-rw-r--r--iosApp/iosApp/Shared/Inject.swift25
-rw-r--r--iosApp/iosApp/Shared/Resolver.swift36
-rw-r--r--iosApp/iosApp/iOSApp.swift42
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt3
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt3
29 files changed, 160 insertions, 32 deletions
diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj
index 898c277..60172de 100644
--- a/iosApp/iosApp.xcodeproj/project.pbxproj
+++ b/iosApp/iosApp.xcodeproj/project.pbxproj
@@ -11,6 +11,8 @@
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
7555FF83242A565900829871 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* LoginView.swift */; };
+ E38F241527A242870069FC45 /* Inject.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38F241427A242870069FC45 /* Inject.swift */; };
+ E38F241727A242C70069FC45 /* Resolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38F241627A242C70069FC45 /* Resolver.swift */; };
E3E77EDF279D2B5A00150070 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E3E77EDE279D2B5A00150070 /* Localizable.strings */; };
E3E77EE6279E6CE400150070 /* FlowCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E77EE5279E6CE400150070 /* FlowCollector.swift */; };
/* End PBXBuildFile section */
@@ -35,6 +37,8 @@
7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
7555FF82242A565900829871 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ E38F241427A242870069FC45 /* Inject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Inject.swift; sourceTree = "<group>"; };
+ E38F241627A242C70069FC45 /* Resolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Resolver.swift; sourceTree = "<group>"; };
E3E77EDE279D2B5A00150070 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
E3E77EE5279E6CE400150070 /* FlowCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowCollector.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -108,6 +112,8 @@
isa = PBXGroup;
children = (
E3E77EE5279E6CE400150070 /* FlowCollector.swift */,
+ E38F241427A242870069FC45 /* Inject.swift */,
+ E38F241627A242C70069FC45 /* Resolver.swift */,
);
path = Shared;
sourceTree = "<group>";
@@ -209,6 +215,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ E38F241727A242C70069FC45 /* Resolver.swift in Sources */,
+ E38F241527A242870069FC45 /* Inject.swift in Sources */,
E3E77EE6279E6CE400150070 /* FlowCollector.swift in Sources */,
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* LoginView.swift in Sources */,
diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
index a056117..fe8ed03 100644
--- a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/iosApp/iosApp/Authentication/LoginView.swift b/iosApp/iosApp/Authentication/LoginView.swift
index 7b1e63e..9e7a64f 100644
--- a/iosApp/iosApp/Authentication/LoginView.swift
+++ b/iosApp/iosApp/Authentication/LoginView.swift
@@ -2,21 +2,13 @@ import SwiftUI
import shared
struct LoginContainerView: View {
+ @Inject private var sessionController: SessionController
+
@State private var username = ""
@State private var password = ""
@State private var server = ""
- private let sessionManager = SessionManager(
- defaultBaseUrl: "https://etbsa.net/api"
- )
-
- private var sessionController: SessionController
-
init() {
- sessionController = SessionController(
- sessionApi: SessionApi(sessionManager: sessionManager),
- usersApi: UsersApi(sessionManager: sessionManager))
-
sessionController.loginStateFlow.collect(collector: Collector<SessionController.LoginState?> { state in
print("State is: \(state?.debugDescription ?? "")")
}) { (unit, error) in
diff --git a/iosApp/iosApp/Shared/Inject.swift b/iosApp/iosApp/Shared/Inject.swift
new file mode 100644
index 0000000..0aaa388
--- /dev/null
+++ b/iosApp/iosApp/Shared/Inject.swift
@@ -0,0 +1,25 @@
+//
+// Inject.swift
+// iosApp
+//
+// Created by Iván on 26/01/22.
+// Copyright © 2022 orgName. All rights reserved.
+//
+
+import Foundation
+import shared
+
+// Source: https://www.kiloloco.com/articles/004-dependency-injection-via-property-wrappers/
+// Source: https://medium.com/swlh/c1f02f06cd51
+@propertyWrapper
+struct Inject<T: Injectable> {
+ var injectable: T
+
+ init() {
+ injectable = Resolver.shared.resolve()
+ }
+
+ public var wrappedValue: T {
+ get { return injectable }
+ }
+}
diff --git a/iosApp/iosApp/Shared/Resolver.swift b/iosApp/iosApp/Shared/Resolver.swift
new file mode 100644
index 0000000..411dc13
--- /dev/null
+++ b/iosApp/iosApp/Shared/Resolver.swift
@@ -0,0 +1,36 @@
+//
+// Resolver.swift
+// iosApp
+//
+// Created by Iván on 26/01/22.
+// Copyright © 2022 orgName. All rights reserved.
+//
+
+import Foundation
+import shared
+
+// Source: https://www.kiloloco.com/articles/004-dependency-injection-via-property-wrappers/
+// Source: https://medium.com/swlh/c1f02f06cd51
+class Resolver {
+
+ private var storage = [String: (Resolver) -> Injectable]()
+
+ static let shared = Resolver()
+ private init() {}
+
+ func add(_ type: Injectable.Type, factory: @escaping (Resolver) -> Injectable) {
+ let key = String(reflecting: type.self)
+ storage[key] = factory
+ }
+
+ func resolve<T: Injectable>() -> T {
+ let key = String(reflecting: T.self)
+
+ guard let injectable = storage[key]?(self) as? T else {
+ fatalError("\(key) has not been added as an injectable object.")
+ }
+
+ return injectable
+ }
+
+}
diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift
index 26c93f1..61c6afc 100644
--- a/iosApp/iosApp/iOSApp.swift
+++ b/iosApp/iosApp/iOSApp.swift
@@ -1,8 +1,50 @@
+import Foundation
import SwiftUI
import shared
@main
struct iOSApp: App {
+
+ init() {
+ /* Dependency injections */
+
+ Resolver.shared.add(SessionManager.self) { resolver in
+ return SessionManager(defaultBaseUrl: NSLocalizedString("app-server-url", comment: ""))
+ }
+ Resolver.shared.add(SessionApi.self) { resolver in
+ return SessionApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(UsersApi.self) { resolver in
+ return UsersApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(DevicesApi.self) { resolver in
+ return DevicesApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(PositionsApi.self) { resolver in
+ return PositionsApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(CommandsApi.self) { resolver in
+ return CommandsApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(ReportsApi.self) { resolver in
+ return ReportsApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(GeofencesApi.self) { resolver in
+ return GeofencesApi(sessionManager: resolver.resolve())
+ }
+ Resolver.shared.add(SessionController.self) { resolver in
+ return SessionController(sessionApi: resolver.resolve(), usersApi: resolver.resolve())
+ }
+ Resolver.shared.add(UnitsController.self) { resolver in
+ return UnitsController(devicesApi: resolver.resolve(), positionsApi: resolver.resolve())
+ }
+ Resolver.shared.add(GeofencesController.self) { resolver in
+ return GeofencesController(geofencesApi: resolver.resolve())
+ }
+ Resolver.shared.add(ReportController.self) { resolver in
+ return ReportController(reportsApi: resolver.resolve(), geofencesApi: resolver.resolve())
+ }
+ }
var body: some Scene {
WindowGroup {
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt
new file mode 100644
index 0000000..a7467d6
--- /dev/null
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt
@@ -0,0 +1,3 @@
+package mx.trackermap.TrackerMap
+
+interface Injectable \ No newline at end of file
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt
index c324f4c..1da9831 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Attribute
import mx.trackermap.TrackerMap.client.infrastructure.*
-class AttributesApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class AttributesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Attributes
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt
index 7a9bd38..c666dc3 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Calendar
import mx.trackermap.TrackerMap.client.infrastructure.*
-class CalendarsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class CalendarsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Calendars
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt
index ffdb699..eb1718c 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt
@@ -11,12 +11,13 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Command
import mx.trackermap.TrackerMap.client.models.CommandType
import mx.trackermap.TrackerMap.client.infrastructure.*
-class CommandsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class CommandsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Saved Commands
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt
index eff69bd..8b839aa 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt
@@ -11,12 +11,13 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Device
import mx.trackermap.TrackerMap.client.models.DeviceAccumulators
import mx.trackermap.TrackerMap.client.infrastructure.*
-class DevicesApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class DevicesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Devices
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt
index f050bbe..bff61c2 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Driver
import mx.trackermap.TrackerMap.client.infrastructure.*
-class DriversApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class DriversApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Drivers
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt
index 572fdd0..87f8dce 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Event
import mx.trackermap.TrackerMap.client.infrastructure.*
-class EventsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class EventsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
*
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt
index 25996fe..049aee9 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Geofence
import mx.trackermap.TrackerMap.client.infrastructure.*
-class GeofencesApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class GeofencesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Geofences
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt
index 032b7fc..07b3b05 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Group
import mx.trackermap.TrackerMap.client.infrastructure.*
-class GroupsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class GroupsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Groups
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt
index 6dd10ec..e28a728 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Maintenance
import mx.trackermap.TrackerMap.client.infrastructure.*
-class MaintenanceApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class MaintenanceApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Maintenance
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt
index c27a532..f311fdb 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt
@@ -11,12 +11,13 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Notification
import mx.trackermap.TrackerMap.client.models.NotificationType
import mx.trackermap.TrackerMap.client.infrastructure.*
-class NotificationsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class NotificationsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Notifications
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt
index 0fb7651..76fd4a8 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Permission
import mx.trackermap.TrackerMap.client.infrastructure.*
-class PermissionsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class PermissionsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Unlink an Object from another Object
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt
index 3373448..6ad74cb 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Position
import mx.trackermap.TrackerMap.client.infrastructure.*
-class PositionsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class PositionsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetches a list of Positions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
index 67bff68..64ef8ea 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
@@ -13,6 +13,7 @@ package mx.trackermap.TrackerMap.client.apis
import io.ktor.content.*
import kotlinx.datetime.LocalDateTime
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Event
import mx.trackermap.TrackerMap.client.models.Position
import mx.trackermap.TrackerMap.client.models.Stop
@@ -21,7 +22,7 @@ import mx.trackermap.TrackerMap.client.models.ReportTrips
import mx.trackermap.TrackerMap.client.infrastructure.*
-class ReportsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class ReportsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Events within the time period for the Devices or Groups
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt
index ea7b911..5672543 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Server
import mx.trackermap.TrackerMap.client.infrastructure.*
-class ServerApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class ServerApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch Server information
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
index 6d9dbea..a22d2d9 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
@@ -11,10 +11,11 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.User
import mx.trackermap.TrackerMap.client.infrastructure.*
-class SessionApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class SessionApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Close the Session
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt
index 1c7c5f5..0b9c766 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt
@@ -12,11 +12,12 @@
package mx.trackermap.TrackerMap.client.apis
import kotlinx.datetime.LocalDateTime
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.Statistics
import mx.trackermap.TrackerMap.client.infrastructure.*
-class StatisticsApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class StatisticsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch server Statistics
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt
index 21e4bd3..90dd9f6 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt
@@ -11,11 +11,12 @@
*/
package mx.trackermap.TrackerMap.client.apis
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.models.User
import mx.trackermap.TrackerMap.client.infrastructure.*
-class UsersApi(sessionManager: SessionManager) : ApiClient(sessionManager) {
+class UsersApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable {
/**
* Fetch a list of Users
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt
index 6287b0c..caf2da1 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt
@@ -3,10 +3,11 @@ package mx.trackermap.TrackerMap.client.infrastructure
import com.russhwolf.settings.Settings
import com.russhwolf.settings.get
import com.russhwolf.settings.set
+import mx.trackermap.TrackerMap.Injectable
class SessionManager(
private val defaultBaseUrl: String
-) {
+): Injectable {
companion object {
const val SERVER_URL_KEY = "server_url"
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt
index 0e4c5c9..e16bb72 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt
@@ -21,13 +21,14 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.apis.GeofencesApi
import mx.trackermap.TrackerMap.client.models.Geofence
@DelicateCoroutinesApi
class GeofencesController(
private val geofencesApi: GeofencesApi
-) {
+): Injectable {
val geofencesFlow = MutableStateFlow<Map<Int,Geofence>>(emptyMap())
init {
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
index b60a034..46bc445 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
@@ -21,6 +21,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.apis.GeofencesApi
import mx.trackermap.TrackerMap.client.apis.ReportsApi
import mx.trackermap.TrackerMap.client.models.EventInformation
@@ -32,7 +33,7 @@ import mx.trackermap.TrackerMap.utils.ReportDates
class ReportController(
private val reportsApi: ReportsApi,
private val geofencesApi: GeofencesApi
-) {
+): Injectable {
sealed class Report {
class PositionsReport(val positions: Array<Position>) : Report()
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
index 2f196f1..d3deca1 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
@@ -22,6 +22,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.JsonPrimitive
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.apis.SessionApi
import mx.trackermap.TrackerMap.client.apis.UsersApi
import mx.trackermap.TrackerMap.client.models.SessionBody
@@ -31,7 +32,7 @@ import mx.trackermap.TrackerMap.client.models.User
class SessionController(
private val sessionApi: SessionApi,
private val usersApi: UsersApi
-) {
+): Injectable {
sealed class LoginState {
object Nothing: LoginState()
object Loading: LoginState()
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt
index b282a34..fd1e950 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt
@@ -25,6 +25,7 @@ import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
+import mx.trackermap.TrackerMap.Injectable
import mx.trackermap.TrackerMap.client.apis.DevicesApi
import mx.trackermap.TrackerMap.client.apis.PositionsApi
import mx.trackermap.TrackerMap.client.models.Position
@@ -38,7 +39,7 @@ import kotlin.time.ExperimentalTime
class UnitsController(
private val devicesApi: DevicesApi,
private val positionsApi: PositionsApi
-) {
+): Injectable {
private companion object {
const val UPDATE_TIME = 20
}