diff --git a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj index 4c49723e..ce80078d 100644 --- a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj +++ b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj @@ -10,9 +10,19 @@ 36BCF85424BA0C54005BEC29 /* BankList.json in Resources */ = {isa = PBXBuildFile; fileRef = 36BCF85324BA0C54005BEC29 /* BankList.json */; }; 36BCF85824BA4274005BEC29 /* BankingUiCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */; }; 36BCF85924BA4274005BEC29 /* BankingUiCommon.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 36BCF85E24BA4DA8005BEC29 /* MultiplatformUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85D24BA4DA8005BEC29 /* MultiplatformUtils.framework */; }; + 36BCF85F24BA4DA8005BEC29 /* MultiplatformUtils.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85D24BA4DA8005BEC29 /* MultiplatformUtils.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 36BCF86324BA5097005BEC29 /* SwiftUiRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF86224BA5097005BEC29 /* SwiftUiRouter.swift */; }; + 36BCF86924BA550D005BEC29 /* BankFinder.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF86824BA550D005BEC29 /* BankFinder.framework */; }; + 36BCF86A24BA550D005BEC29 /* BankFinder.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF86824BA550D005BEC29 /* BankFinder.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 36BCF86C24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF86B24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift */; }; + 36BCF86E24BA691B005BEC29 /* DependencyInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF86D24BA691B005BEC29 /* DependencyInjector.swift */; }; + 36BCF87024BB0F8A005BEC29 /* fints4kBankingClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */; }; + 36BCF87124BB0F8A005BEC29 /* fints4kBankingClient.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 36BCF87324BB2706005BEC29 /* BankingUiSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; }; + 36BCF87424BB2706005BEC29 /* BankingUiSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */; }; 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; }; - 36E7BA2124B9EAD200757859 /* BankFinder.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36E7BA2024B9EAD200757859 /* BankFinder.framework */; }; - 36E7BA2224B9EAD300757859 /* BankFinder.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36E7BA2024B9EAD200757859 /* BankFinder.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; }; 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; }; 36FC92A124B39A05002B12E9 /* BankingiOSApp.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929F24B39A05002B12E9 /* BankingiOSApp.xcdatamodeld */; }; @@ -25,7 +35,6 @@ 36FC92D024B39C47002B12E9 /* fints4k.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36FC92CF24B39C47002B12E9 /* fints4k.framework */; }; 36FC92D124B39C47002B12E9 /* fints4k.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36FC92CF24B39C47002B12E9 /* fints4k.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC92D524B3A3BA002B12E9 /* NSUrlWebClient.swift */; }; - 36FC92D824B3A3BA002B12E9 /* FinTsClientCallback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC92D624B3A3BA002B12E9 /* FinTsClientCallback.swift */; }; 36FC92DC24B3A4A0002B12E9 /* AccountsTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC92DB24B3A4A0002B12E9 /* AccountsTab.swift */; }; 36FC92E824B3B1DC002B12E9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 36FC92EA24B3B1DC002B12E9 /* Localizable.strings */; }; 36FC92EF24B3BB81002B12E9 /* AddAccountDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC92EE24B3BB81002B12E9 /* AddAccountDialog.swift */; }; @@ -55,9 +64,12 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 36BCF86A24BA550D005BEC29 /* BankFinder.framework in Embed Frameworks */, 36BCF85924BA4274005BEC29 /* BankingUiCommon.framework in Embed Frameworks */, - 36E7BA2224B9EAD300757859 /* BankFinder.framework in Embed Frameworks */, + 36BCF85F24BA4DA8005BEC29 /* MultiplatformUtils.framework in Embed Frameworks */, 36FC92D124B39C47002B12E9 /* fints4k.framework in Embed Frameworks */, + 36BCF87124BB0F8A005BEC29 /* fints4kBankingClient.framework in Embed Frameworks */, + 36BCF87424BB2706005BEC29 /* BankingUiSwift.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -67,9 +79,16 @@ /* Begin PBXFileReference section */ 36BCF85324BA0C54005BEC29 /* BankList.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = BankList.json; path = ../../../tools/BankFinder/src/commonMain/resources/BankList.json; sourceTree = ""; }; 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiCommon.framework; path = "../BankingUiCommon/build/xcode-frameworks/BankingUiCommon.framework"; sourceTree = ""; }; + 36BCF85D24BA4DA8005BEC29 /* MultiplatformUtils.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultiplatformUtils.framework; path = "../../common/build/xcode-frameworks/MultiplatformUtils.framework"; sourceTree = ""; }; + 36BCF86224BA5097005BEC29 /* SwiftUiRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUiRouter.swift; sourceTree = ""; }; + 36BCF86824BA550D005BEC29 /* BankFinder.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankFinder.framework; path = "../../tools/BankFinder/build/xcode-frameworks/BankFinder.framework"; sourceTree = ""; }; + 36BCF86B24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DispatchQueueAsyncRunner.swift; sourceTree = ""; }; + 36BCF86D24BA691B005BEC29 /* DependencyInjector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependencyInjector.swift; sourceTree = ""; }; + 36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = fints4kBankingClient.framework; path = "../fints4kBankingClient/build/xcode-frameworks/fints4kBankingClient.framework"; sourceTree = ""; }; + 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiSwift.framework; path = "../BankingUiNativeIntegration/build/xcode-frameworks/BankingUiSwift.framework"; sourceTree = ""; }; + 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlSessionWebClient.swift; sourceTree = ""; }; 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = ""; }; 36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = ""; }; - 36E7BA2024B9EAD200757859 /* BankFinder.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankFinder.framework; path = "../../tools/BankFinder/build/xcode-frameworks/BankFinder.framework"; sourceTree = ""; }; 36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36FC929B24B39A05002B12E9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -87,7 +106,6 @@ 36FC92C224B39A08002B12E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36FC92CF24B39C47002B12E9 /* fints4k.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = fints4k.framework; path = "../../fints4k/build/xcode-frameworks/fints4k.framework"; sourceTree = ""; }; 36FC92D524B3A3BA002B12E9 /* NSUrlWebClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSUrlWebClient.swift; sourceTree = ""; }; - 36FC92D624B3A3BA002B12E9 /* FinTsClientCallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FinTsClientCallback.swift; sourceTree = ""; }; 36FC92DB24B3A4A0002B12E9 /* AccountsTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTab.swift; sourceTree = ""; }; 36FC92EC24B3B371002B12E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; 36FC92ED24B3B3A2002B12E9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; @@ -99,9 +117,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 36BCF86924BA550D005BEC29 /* BankFinder.framework in Frameworks */, 36BCF85824BA4274005BEC29 /* BankingUiCommon.framework in Frameworks */, - 36E7BA2124B9EAD200757859 /* BankFinder.framework in Frameworks */, + 36BCF85E24BA4DA8005BEC29 /* MultiplatformUtils.framework in Frameworks */, 36FC92D024B39C47002B12E9 /* fints4k.framework in Frameworks */, + 36BCF87024BB0F8A005BEC29 /* fints4kBankingClient.framework in Frameworks */, + 36BCF87324BB2706005BEC29 /* BankingUiSwift.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -191,8 +212,11 @@ 36FC92CE24B39C47002B12E9 /* Frameworks */ = { isa = PBXGroup; children = ( + 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */, + 36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */, + 36BCF86824BA550D005BEC29 /* BankFinder.framework */, + 36BCF85D24BA4DA8005BEC29 /* MultiplatformUtils.framework */, 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */, - 36E7BA2024B9EAD200757859 /* BankFinder.framework */, 36E7BA1824B9E70C00757859 /* xcode-frameworks */, 36FC92CF24B39C47002B12E9 /* fints4k.framework */, ); @@ -202,8 +226,9 @@ 36FC92D424B3A389002B12E9 /* fints4k */ = { isa = PBXGroup; children = ( - 36FC92D624B3A3BA002B12E9 /* FinTsClientCallback.swift */, 36FC92D524B3A3BA002B12E9 /* NSUrlWebClient.swift */, + 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */, + 36BCF86B24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift */, ); path = fints4k; sourceTree = ""; @@ -213,6 +238,8 @@ children = ( 36FC92DA24B3A485002B12E9 /* views */, 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */, + 36BCF86224BA5097005BEC29 /* SwiftUiRouter.swift */, + 36BCF86D24BA691B005BEC29 /* DependencyInjector.swift */, ); path = ui; sourceTree = ""; @@ -373,7 +400,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\ncd \"../../fints4k/build/xcode-frameworks/\"\n./gradlew :fints4k:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n\ncd \"../../tools/BankFinder/build/xcode-frameworks/\"\n./gradlew :BankFinder:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n\ncd \"../../ui/BankingUiCommon/build/xcode-frameworks/\"\n./gradlew :BankingUiCommon:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n"; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\n#cd \"../../common/build/xcode-frameworks/\"\n#./gradlew :common:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n\n#cd \"../../fints4k/build/xcode-frameworks/\"\n#./gradlew :fints4k:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}#\n\n#cd \"../../tools/BankFinder/build/xcode-frameworks/\"\n#./gradlew :BankFinder:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n\ncd \"../../ui/BankingUiNativeIntegration/build/xcode-frameworks/\"\n./gradlew :BankingUiNativeIntegration:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -383,11 +410,14 @@ buildActionMask = 2147483647; files = ( 36FC92DC24B3A4A0002B12E9 /* AccountsTab.swift in Sources */, - 36FC92D824B3A3BA002B12E9 /* FinTsClientCallback.swift in Sources */, + 36BCF86E24BA691B005BEC29 /* DependencyInjector.swift in Sources */, 36FC92A124B39A05002B12E9 /* BankingiOSApp.xcdatamodeld in Sources */, 36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */, 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */, + 36BCF86C24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift in Sources */, + 36BCF86324BA5097005BEC29 /* SwiftUiRouter.swift in Sources */, 36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */, + 36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */, 36FC92A324B39A05002B12E9 /* ContentView.swift in Sources */, 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */, 36FC92EF24B3BB81002B12E9 /* AddAccountDialog.swift in Sources */, @@ -570,9 +600,12 @@ DEVELOPMENT_ASSET_PATHS = "\"BankingiOSApp/Preview Content\""; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = ( + "../../common/build/xcode-frameworks/", "../../fints4k/build/xcode-frameworks", - "../../tools/BankFinder/build/xcode-frameworks", "../../ui/BankingUiCommon/build/xcode-frameworks/", + "../../tools/BankFinder/build/xcode-frameworks/", + "../../ui/fints4kBankingClient/build/xcode-frameworks/", + "../../ui/BankingUiNativeIntegration/build/xcode-frameworks/", ); INFOPLIST_FILE = BankingiOSApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -595,9 +628,12 @@ DEVELOPMENT_ASSET_PATHS = "\"BankingiOSApp/Preview Content\""; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = ( + "../../common/build/xcode-frameworks/", "../../fints4k/build/xcode-frameworks", - "../../tools/BankFinder/build/xcode-frameworks", "../../ui/BankingUiCommon/build/xcode-frameworks/", + "../../tools/BankFinder/build/xcode-frameworks/", + "../../ui/fints4kBankingClient/build/xcode-frameworks/", + "../../ui/BankingUiNativeIntegration/build/xcode-frameworks/", ); INFOPLIST_FILE = BankingiOSApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/ui/BankingiOSApp/BankingiOSApp/AppDelegate.swift b/ui/BankingiOSApp/BankingiOSApp/AppDelegate.swift index 4621c98b..4b65a0dc 100644 --- a/ui/BankingiOSApp/BankingiOSApp/AppDelegate.swift +++ b/ui/BankingiOSApp/BankingiOSApp/AppDelegate.swift @@ -1,10 +1,21 @@ - import UIKit import CoreData +import BankingUiSwift + @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { + override init() { + let appDataFolder = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, .userDomainMask, true).first + ?? Bundle.main.resourceURL?.absoluteString ?? "" + + let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder)) + + let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), asyncRunner: DispatchQueueAsyncRunner()) + + DependencyInjector.register(dependency: presenter) + } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { diff --git a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift index 38773b3d..cd409753 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift @@ -1,4 +1,3 @@ - import SwiftUI struct ContentView: View { diff --git a/ui/BankingiOSApp/BankingiOSApp/SceneDelegate.swift b/ui/BankingiOSApp/BankingiOSApp/SceneDelegate.swift index 68b24bd1..4ccc3cce 100644 --- a/ui/BankingiOSApp/BankingiOSApp/SceneDelegate.swift +++ b/ui/BankingiOSApp/BankingiOSApp/SceneDelegate.swift @@ -1,4 +1,3 @@ - import UIKit import SwiftUI diff --git a/ui/BankingiOSApp/BankingiOSApp/fints4k/DispatchQueueAsyncRunner.swift b/ui/BankingiOSApp/BankingiOSApp/fints4k/DispatchQueueAsyncRunner.swift new file mode 100644 index 00000000..9d1f7bbe --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/fints4k/DispatchQueueAsyncRunner.swift @@ -0,0 +1,19 @@ +import Foundation +import MultiplatformUtils +import BankingUiSwift + + +class DispatchQueueAsyncRunner : BUCIAsyncRunner { + + func runAsync(runnable: @escaping () -> Void) { + let frozen = FreezerKt.freeze(obj: runnable) + + runnable() + + DispatchQueue(label: "DispatchQueueAsyncRunner", qos: .background).async { + runnable() + } + } + + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/fints4k/UrlSessionWebClient.swift b/ui/BankingiOSApp/BankingiOSApp/fints4k/UrlSessionWebClient.swift new file mode 100644 index 00000000..689296b5 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/fints4k/UrlSessionWebClient.swift @@ -0,0 +1,31 @@ +import Foundation +import BankingUiSwift +import MultiplatformUtils + + +class UrlSessionWebClient : Fints4kIWebClient { + + func post(url: String, body: String, contentType: String, userAgent: String, callback: @escaping (Fints4kWebClientResponse) -> Void) { + guard let requestUrl = URL(string: url) else { fatalError() } + + var request = URLRequest(url: requestUrl) + request.httpMethod = "POST" + request.httpBody = body.data(using: String.Encoding.utf8) + + let dataTask = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in + // we have to dispatch response back to main thread as in Kotlin/Native objects can only be changed on one thread -> do all logic on main thread only network access in backbackground thread + DispatchQueue.main.async { + var webClientResponse = Fints4kWebClientResponse(successful: false, responseCode: -1, error: KotlinException(message: error?.localizedDescription), body: nil) + + if let data = data, let httpResponse = response as? HTTPURLResponse { + webClientResponse = Fints4kWebClientResponse(successful: true, responseCode: Int32(httpResponse.statusCode), error: nil, body: String(data: data, encoding: .ascii)) + } + + callback(webClientResponse) + } + } + + dataTask.resume() + } + +} \ No newline at end of file diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift new file mode 100644 index 00000000..f41eb1ec --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift @@ -0,0 +1,27 @@ +import BankingUiSwift + + +class SwiftUiRouter : BUCIRouter { + + func showAddAccountDialog(presenter: BUCBankingPresenter) { + + } + + func getTanFromUserFromNonUiThread(customer: BUCCustomer, tanChallenge: BUCTanChallenge, presenter: BUCBankingPresenter) -> BUCEnterTanResult { + return BUCEnterTanResult(enteredTan: nil, changeTanProcedureTo: nil, changeTanMediumTo: nil, changeTanMediumResultCallback: nil) + } + + func getAtcFromUserFromNonUiThread(tanMedium: BUCTanGeneratorTanMedium) -> BUCEnterTanGeneratorAtcResult { + return BUCEnterTanGeneratorAtcResult(tan: nil, atc: nil) + } + + func showTransferMoneyDialog(presenter: BUCBankingPresenter, preselectedBankAccount: BUCBankAccount?, preselectedValues: BUCTransferMoneyData?) { + + } + + func showSendMessageLogDialog(presenter: BUCBankingPresenter) { + + } + + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift b/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift index ffa28958..cf2fc63f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift @@ -1,4 +1,3 @@ - import SwiftUI diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift index 13aa7ee3..c7cf229c 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift @@ -1,6 +1,6 @@ - import SwiftUI + struct AccountsTab: View { var body: some View { NavigationView { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift index 619079d9..53741b3c 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift @@ -1,6 +1,5 @@ import SwiftUI -import fints4k -import BankFinder +import BankingUiSwift struct AddAccountDialog: View { @@ -9,10 +8,10 @@ struct AddAccountDialog: View { @State private var customerId = "" @State private var password = "" - @State private var bank: BankInfo? = nil + @State private var bank: BankFinderBankInfo? = BankFinderBankInfo() - private let bankFinder = InMemoryBankFinder() + @Inject private var presenter: BankingPresenterSwift var body: some View { @@ -51,7 +50,7 @@ struct AddAccountDialog: View { func findBank() { - self.bank = bankFinder.findBankByNameBankCodeOrCity(query: enteredBank).first + self.bank = presenter.searchBanksByNameBankCodeOrCity(query: enteredBank).first } func isRequiredDataEntered() -> Bool { @@ -62,6 +61,12 @@ struct AddAccountDialog: View { func addAccount() { + if let bank = bank { + + presenter.addAccountAsync(bankInfo: bank, customerId: customerId, pin: password) { (response: BUCAddAccountResponse) in + NSLog("Is successful? \(response.isSuccessful), name = \(response.customer.customerName), \(response.customer.accounts.count) accounts, \(response.bookedTransactionsOfLast90Days.flatMap( { $1 }).count) transactions") + } + } } }