Injecting now AuthenticationService
This commit is contained in:
parent
8b2a210269
commit
79d746a395
|
@ -15,9 +15,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||||
|
|
||||||
setupBankingUi()
|
let authenticationService = setupBankingUi()
|
||||||
|
|
||||||
let authenticationService = AuthenticationService()
|
|
||||||
|
|
||||||
if let windowScene = scene as? UIWindowScene {
|
if let windowScene = scene as? UIWindowScene {
|
||||||
let window = UIWindow(windowScene: windowScene)
|
let window = UIWindow(windowScene: windowScene)
|
||||||
|
@ -36,11 +34,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupBankingUi() {
|
private func setupBankingUi() -> AuthenticationService {
|
||||||
let appDataFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
|
let appDataFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
|
||||||
?? Bundle.main.resourceURL?.absoluteString ?? ""
|
?? Bundle.main.resourceURL?.absoluteString ?? ""
|
||||||
|
|
||||||
let persistence = CoreDataBankingPersistence()
|
let persistence = CoreDataBankingPersistence()
|
||||||
|
let authenticationService = AuthenticationService()
|
||||||
self.persistence = persistence
|
self.persistence = persistence
|
||||||
|
|
||||||
let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder))
|
let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder))
|
||||||
|
@ -48,6 +47,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), persistence: persistence, transactionPartySearcher: persistence, bankIconFinder: SwiftBankIconFinder(), serializer: NoOpSerializer(), asyncRunner: DispatchQueueAsyncRunner())
|
let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), persistence: persistence, transactionPartySearcher: persistence, bankIconFinder: SwiftBankIconFinder(), serializer: NoOpSerializer(), asyncRunner: DispatchQueueAsyncRunner())
|
||||||
|
|
||||||
DependencyInjector.register(dependency: presenter)
|
DependencyInjector.register(dependency: presenter)
|
||||||
|
DependencyInjector.register(dependency: authenticationService)
|
||||||
|
|
||||||
|
return authenticationService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ struct AddAccountDialog: View {
|
||||||
|
|
||||||
@Inject private var presenter: BankingPresenterSwift
|
@Inject private var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
|
@Inject private var authenticationService: AuthenticationService
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
@ -107,7 +109,6 @@ struct AddAccountDialog: View {
|
||||||
DispatchQueue.main.async { // dispatch async as may EnterTanDialog is still displayed so dismiss() won't dismiss this view
|
DispatchQueue.main.async { // dispatch async as may EnterTanDialog is still displayed so dismiss() won't dismiss this view
|
||||||
self.closeDialog()
|
self.closeDialog()
|
||||||
|
|
||||||
let authenticationService = AuthenticationService()
|
|
||||||
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
|
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
|
||||||
|
|
||||||
UIAlert("Secure data?", "Secure data with password or %@?".localize(authenticationService.supportedBiometricAuthenticationLocalizedName),
|
UIAlert("Secure data?", "Secure data with password or %@?".localize(authenticationService.supportedBiometricAuthenticationLocalizedName),
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct LoginDialog: View {
|
||||||
private let needsTouchIDToUnlockApp: Bool
|
private let needsTouchIDToUnlockApp: Bool
|
||||||
|
|
||||||
|
|
||||||
init(_ authenticationService: AuthenticationService = AuthenticationService(), allowCancellingLogin: Bool = false, loginReason: LocalizedStringKey? = nil, loginResult: @escaping (Bool) -> Void) {
|
init(_ authenticationService: AuthenticationService, allowCancellingLogin: Bool = false, loginReason: LocalizedStringKey? = nil, loginResult: @escaping (Bool) -> Void) {
|
||||||
|
|
||||||
self.authenticationService = authenticationService
|
self.authenticationService = authenticationService
|
||||||
self.allowCancellingLogin = allowCancellingLogin
|
self.allowCancellingLogin = allowCancellingLogin
|
||||||
|
@ -130,7 +130,7 @@ struct LoginDialog: View {
|
||||||
struct LoginDialog_Previews: PreviewProvider {
|
struct LoginDialog_Previews: PreviewProvider {
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
LoginDialog { _ in }
|
LoginDialog(AuthenticationService()) { _ in }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ struct ProtectAppSettingsDialog: View {
|
||||||
|
|
||||||
@Environment(\.presentationMode) var presentation
|
@Environment(\.presentationMode) var presentation
|
||||||
|
|
||||||
|
@Inject private var authenticationService: AuthenticationService
|
||||||
|
|
||||||
private let authenticationService = AuthenticationService()
|
|
||||||
|
|
||||||
private var supportedAuthenticationTypes: [AuthenticationType] = []
|
private var supportedAuthenticationTypes: [AuthenticationType] = []
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ struct SettingsDialog: View {
|
||||||
@ObservedObject var data: AppData
|
@ObservedObject var data: AppData
|
||||||
|
|
||||||
@Inject var presenter: BankingPresenterSwift
|
@Inject var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
|
@Inject private var authenticationService: AuthenticationService
|
||||||
|
|
||||||
|
|
||||||
@State private var updateAccountsAutomatically: Bool = true
|
@State private var updateAccountsAutomatically: Bool = true
|
||||||
|
@ -116,8 +118,6 @@ struct SettingsDialog: View {
|
||||||
|
|
||||||
|
|
||||||
private func navigateToProtectAppSettingsDialog() {
|
private func navigateToProtectAppSettingsDialog() {
|
||||||
let authenticationService = AuthenticationService()
|
|
||||||
|
|
||||||
if authenticationService.needsAuthenticationToUnlockApp == false {
|
if authenticationService.needsAuthenticationToUnlockApp == false {
|
||||||
SceneDelegate.navigateToView(ProtectAppSettingsDialog())
|
SceneDelegate.navigateToView(ProtectAppSettingsDialog())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue