Implemented showAddAccountDialog() and TransferMoneyDialog()

This commit is contained in:
dankito 2020-10-21 15:01:28 +02:00
parent 5a32ef4958
commit eff4e131df
2 changed files with 26 additions and 27 deletions

View File

@ -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) {

View File

@ -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)
}