From eff4e131df8eaf51258a07a2eecb59889596fb55 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 21 Oct 2020 15:01:28 +0200 Subject: [PATCH] Implemented showAddAccountDialog() and TransferMoneyDialog() --- .../BankingiOSApp/ui/SwiftUiRouter.swift | 4 +- .../ui/dialogs/TransferMoneyDialog.swift | 49 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift index 9aabac6f..4fb0c278 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftUiRouter.swift @@ -6,7 +6,7 @@ class SwiftUiRouter : IRouter { func showAddAccountDialog(presenter: BankingPresenter) { - + SceneDelegate.navigateToView(AddAccountDialog()) } func getTanFromUserFromNonUiThread(bank: IBankData, tanChallenge: TanChallenge, presenter: BankingPresenter, callback: @escaping (EnterTanResult) -> Void) { @@ -20,7 +20,7 @@ class SwiftUiRouter : IRouter { } func showTransferMoneyDialog(presenter: BankingPresenter, preselectedValues: TransferMoneyData?) { - + SceneDelegate.navigateToView(TransferMoneyDialog(preselectedValues)) } func showSendMessageLogDialog(presenter: BankingPresenter) { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/TransferMoneyDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/TransferMoneyDialog.swift index 917ecf28..2a721b43 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/TransferMoneyDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/TransferMoneyDialog.swift @@ -70,37 +70,36 @@ struct TransferMoneyDialog: View { @Inject private var presenter: BankingPresenterSwift - init() { + init(_ preselectedValues: TransferMoneyData? = nil) { self.accountsSupportingTransferringMoney = self.presenter.accountsSupportingTransferringMoneySortedByDisplayIndex self.showAccounts = self.accountsSupportingTransferringMoney.count > 1 - } - - init(preselectedValues: TransferMoneyData) { - self.init() - let preselectedBankAccount = preselectedValues.account - self._selectedAccountIndex = State(initialValue: accountsSupportingTransferringMoney.firstIndex(where: { account in account == preselectedBankAccount }) ?? 0) + if let preselectedValues = preselectedValues { - self._recipientName = State(initialValue: preselectedValues.recipientName) - self._recipientBic = State(initialValue: preselectedValues.recipientBankCode) - self._recipientIban = State(initialValue: preselectedValues.recipientAccountId) - - if recipientBic.isBlank && recipientIban.isNotBlank { - tryToGetBicFromIban(recipientIban) + let preselectedBankAccount = preselectedValues.account + self._selectedAccountIndex = State(initialValue: accountsSupportingTransferringMoney.firstIndex(where: { account in account == preselectedBankAccount }) ?? 0) + + self._recipientName = State(initialValue: preselectedValues.recipientName) + self._recipientBic = State(initialValue: preselectedValues.recipientBankCode) + self._recipientIban = State(initialValue: preselectedValues.recipientAccountId) + + if recipientBic.isBlank && recipientIban.isNotBlank { + tryToGetBicFromIban(recipientIban) + } + + self._reference = State(initialValue: preselectedValues.reference) + + if preselectedValues.amount.decimal != NSDecimalNumber.zero { + self._amount = State(initialValue: preselectedValues.amount.format(countDecimalPlaces: 2)) + } + + if preselectedBankAccount.supportsRealTimeTransfer { + self._realTimeTransfer = State(initialValue: preselectedValues.realTimeTransfer) + } + + _validateDataWhenShowingDialog = State(initialValue: true) } - - self._reference = State(initialValue: preselectedValues.reference) - - if preselectedValues.amount.decimal != NSDecimalNumber.zero { - self._amount = State(initialValue: preselectedValues.amount.format(countDecimalPlaces: 2)) - } - - if preselectedBankAccount.supportsRealTimeTransfer { - self._realTimeTransfer = State(initialValue: preselectedValues.realTimeTransfer) - } - - _validateDataWhenShowingDialog = State(initialValue: true) }