diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-25 15:25:27 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-25 15:25:27 -0600 |
commit | 4a85207614840d340167000e4d66649fdd462901 (patch) | |
tree | fd83161800f346615f211248df9e10de803d60d2 | |
parent | 52a5e19b28875a1943f672804f07f59291a38bc3 (diff) | |
download | etbsa-trackermap-mobile-4a85207614840d340167000e4d66649fdd462901.tar.gz etbsa-trackermap-mobile-4a85207614840d340167000e4d66649fdd462901.tar.bz2 etbsa-trackermap-mobile-4a85207614840d340167000e4d66649fdd462901.zip |
Latest test code
12 files changed, 134 insertions, 22 deletions
diff --git a/iosApp/Localizable.strings b/iosApp/Localizable.strings index 754e4ea..c863844 100644 --- a/iosApp/Localizable.strings +++ b/iosApp/Localizable.strings @@ -6,6 +6,8 @@ Copyright © 2022 orgName. All rights reserved. */ "app-name" = "TrackerMap"; +"app-server-url" = "https://etbsa.net/api"; + "username" = "Username"; "password" = "Password"; "server-url" = "Server URL"; diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index daef2d1..898c277 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -12,7 +12,7 @@ 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; 7555FF83242A565900829871 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* LoginView.swift */; }; E3E77EDF279D2B5A00150070 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E3E77EDE279D2B5A00150070 /* Localizable.strings */; }; - E3E77EE3279D44E200150070 /* Koin.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E77EE2279D44E200150070 /* Koin.swift */; }; + E3E77EE6279E6CE400150070 /* FlowCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E77EE5279E6CE400150070 /* FlowCollector.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -36,7 +36,7 @@ 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>"; }; E3E77EDE279D2B5A00150070 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; }; - E3E77EE2279D44E200150070 /* Koin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Koin.swift; sourceTree = "<group>"; }; + E3E77EE5279E6CE400150070 /* FlowCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowCollector.swift; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,7 +85,6 @@ 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, - E3E77EE2279D44E200150070 /* Koin.swift */, ); path = iosApp; sourceTree = "<group>"; @@ -108,6 +107,7 @@ E3E77EE1279D43C000150070 /* Shared */ = { isa = PBXGroup; children = ( + E3E77EE5279E6CE400150070 /* FlowCollector.swift */, ); path = Shared; sourceTree = "<group>"; @@ -159,6 +159,9 @@ "es-419", ); mainGroup = 7555FF72242A565900829871; + packageReferences = ( + E3E77EE4279E06C300150070 /* XCRemoteSwiftPackageReference "Swinject" */, + ); productRefGroup = 7555FF7C242A565900829871 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -206,7 +209,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - E3E77EE3279D44E200150070 /* Koin.swift in Sources */, + E3E77EE6279E6CE400150070 /* FlowCollector.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 7555FF83242A565900829871 /* LoginView.swift in Sources */, ); @@ -405,6 +408,17 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + E3E77EE4279E06C300150070 /* XCRemoteSwiftPackageReference "Swinject" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Swinject/Swinject.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ }; rootObject = 7555FF73242A565900829871 /* Project object */; } diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:"> + </FileRef> +</Workspace> diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IDEDidComputeMac32BitWarning</key> + <true/> +</dict> +</plist> diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..fc75d3e --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "Swinject", + "repositoryURL": "https://github.com/Swinject/Swinject.git", + "state": { + "branch": null, + "revision": "f10b6e9ebff440f985c43008f7c2d097639fcb81", + "version": "2.8.1" + } + } + ] + }, + "version": 1 +} diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate Binary files differnew file mode 100644 index 0000000..91ae71f --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/iosApp/iosApp.xcodeproj/xcuserdata/avalos.xcuserdatad/xcschemes/xcschememanagement.plist b/iosApp/iosApp.xcodeproj/xcuserdata/avalos.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..892de81 --- /dev/null +++ b/iosApp/iosApp.xcodeproj/xcuserdata/avalos.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>Sample-iOS (Playground) 1.xcscheme</key> + <dict> + <key>isShown</key> + <false/> + <key>orderHint</key> + <integer>2</integer> + </dict> + <key>Sample-iOS (Playground) 2.xcscheme</key> + <dict> + <key>isShown</key> + <false/> + <key>orderHint</key> + <integer>3</integer> + </dict> + <key>Sample-iOS (Playground).xcscheme</key> + <dict> + <key>isShown</key> + <false/> + <key>orderHint</key> + <integer>0</integer> + </dict> + <key>iosApp.xcscheme_^#shared#^_</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist> diff --git a/iosApp/iosApp/Authentication/LoginView.swift b/iosApp/iosApp/Authentication/LoginView.swift index 5014ca5..ba07753 100644 --- a/iosApp/iosApp/Authentication/LoginView.swift +++ b/iosApp/iosApp/Authentication/LoginView.swift @@ -11,9 +11,12 @@ struct LoginContainerView: View { usersApi: UsersApi(defaultBaseUrl: "https://etbsa.net/api")) init() { - sessionController.loginStateFlow.collect(collector: Kotlinx_coroutines_coreFlowCollector) { <#KotlinUnit?#>, <#Error?#> in - <#code#> + sessionController.loginStateFlow.collect(collector: Collector<SessionController.LoginState?> { state in + print("State is: \(state?.debugDescription ?? "")") + }) { (unit, error) in + } + sessionController.restoreSession() } var body: some View { diff --git a/iosApp/iosApp/Koin.swift b/iosApp/iosApp/Koin.swift deleted file mode 100644 index ffa0819..0000000 --- a/iosApp/iosApp/Koin.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// Koin.swift -// iosApp -// -// Created by Iván on 23/01/22. -// Copyright © 2022 orgName. All rights reserved. -// - -import Foundation -import shared - -func startKoin() { - let koinApplication = KoinIosKt. -} diff --git a/iosApp/iosApp/Shared/FlowCollector.swift b/iosApp/iosApp/Shared/FlowCollector.swift new file mode 100644 index 0000000..3fd6c60 --- /dev/null +++ b/iosApp/iosApp/Shared/FlowCollector.swift @@ -0,0 +1,25 @@ +// +// FlowCollector.swift +// iosApp +// +// Created by Iván on 23/01/22. +// Copyright © 2022 orgName. All rights reserved. +// + +import Foundation +import shared + +class Collector<T>: Kotlinx_coroutines_coreFlowCollector { + + let callback: (T) -> Void + + init(callback: @escaping (T) -> Void) { + self.callback = callback + } + + func emit(value: Any?, completionHandler: @escaping (KotlinUnit?, Error?) -> Void) { + callback(value as! T) + + completionHandler(KotlinUnit(), nil) + } +} diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift index 241beca..cbc2ffd 100644 --- a/iosApp/iosApp/iOSApp.swift +++ b/iosApp/iosApp/iOSApp.swift @@ -3,9 +3,24 @@ import shared @main struct iOSApp: App { + let defaultServer = "https://etbsa.net/" + + var sessionApi: SessionApi + var usersApi: UsersApi + var devicesApi: DevicesApi + var positionsApi: PositionsApi + var commandsApi: CommandsApi + var reportsApi: ReportsApi + var geofencesApi: GeofencesApi init() { - startKoin() + sessionApi = SessionApi(defaultBaseUrl: defaultServer) + usersApi = UsersApi(defaultBaseUrl: defaultServer) + devicesApi = DevicesApi(defaultBaseUrl: defaultServer) + positionsApi = PositionsApi(defaultBaseUrl: defaultServer) + commandsApi = CommandsApi(defaultBaseUrl: defaultServer) + reportsApi = ReportsApi(defaultBaseUrl: defaultServer) + geofencesApi = GeofencesApi(defaultBaseUrl: defaultServer) } var body: some Scene { diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt index dd61893..0638dc9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt @@ -56,6 +56,7 @@ open class ApiClient( serializer = KotlinxSerializer( KotlinJson { ignoreUnknownKeys = true + useAlternativeNames = false } ) } |