From 4a85207614840d340167000e4d66649fdd462901 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 25 Jan 2022 15:25:27 -0600 Subject: Latest test code --- iosApp/Localizable.strings | 2 ++ iosApp/iosApp.xcodeproj/project.pbxproj | 24 +++++++++++--- .../project.xcworkspace/contents.xcworkspacedata | 7 +++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ .../xcshareddata/swiftpm/Package.resolved | 16 ++++++++++ .../UserInterfaceState.xcuserstate | Bin 0 -> 30445 bytes .../xcschemes/xcschememanagement.plist | 35 +++++++++++++++++++++ iosApp/iosApp/Authentication/LoginView.swift | 7 +++-- iosApp/iosApp/Koin.swift | 14 --------- iosApp/iosApp/Shared/FlowCollector.swift | 25 +++++++++++++++ iosApp/iosApp/iOSApp.swift | 17 +++++++++- .../TrackerMap/client/infrastructure/ApiClient.kt | 1 + 12 files changed, 134 insertions(+), 22 deletions(-) create mode 100644 iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 iosApp/iosApp.xcodeproj/xcuserdata/avalos.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 iosApp/iosApp/Koin.swift create mode 100644 iosApp/iosApp/Shared/FlowCollector.swift 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 = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E3E77EDE279D2B5A00150070 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; - E3E77EE2279D44E200150070 /* Koin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Koin.swift; sourceTree = ""; }; + E3E77EE5279E6CE400150070 /* FlowCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowCollector.swift; sourceTree = ""; }; /* 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 = ""; @@ -108,6 +107,7 @@ E3E77EE1279D43C000150070 /* Shared */ = { isa = PBXGroup; children = ( + E3E77EE5279E6CE400150070 /* FlowCollector.swift */, ); path = Shared; sourceTree = ""; @@ -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 @@ + + + + + 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 @@ + + + + + IDEDidComputeMac32BitWarning + + + 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 new file mode 100644 index 0000000..91ae71f Binary files /dev/null and b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate differ 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 @@ + + + + + SchemeUserState + + Sample-iOS (Playground) 1.xcscheme + + isShown + + orderHint + 2 + + Sample-iOS (Playground) 2.xcscheme + + isShown + + orderHint + 3 + + Sample-iOS (Playground).xcscheme + + isShown + + orderHint + 0 + + iosApp.xcscheme_^#shared#^_ + + orderHint + 0 + + + + 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 { 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: 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 } ) } -- cgit v1.2.3