From 90a0ad5b4a2ae6a9e2d3d59e8f53c7d61e7d5d5f Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 18 Jul 2020 17:25:01 +0200 Subject: [PATCH] Fixed that account didn't reflect selected account --- .../ui/views/TransferMoneyDialog.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift index ce1d6c36..12302909 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift @@ -13,7 +13,6 @@ struct TransferMoneyDialog: View { private var accountsSupportingTransferringMoney: [BUCBankAccount] = [] @State private var selectedAccountIndex = 0 - private var account: BUCBankAccount? = nil @State private var remitteeName: String = "" @State private var isValidRemitteeNameEntered = false @@ -32,30 +31,35 @@ struct TransferMoneyDialog: View { @State private var instantPayment = false + @State private var transferMoneyResponseMessage: Message? = nil + + + private var account: BUCBankAccount? { + if (self.selectedAccountIndex < self.accountsSupportingTransferringMoney.count) { + return self.accountsSupportingTransferringMoney[selectedAccountIndex] + } + + return self.accountsSupportingTransferringMoney.first + } private var supportsInstantPayment: Bool { return self.account?.supportsInstantPaymentMoneyTransfer ?? false } - @State private var transferMoneyResponseMessage: Message? = nil - - @Inject private var presenter: BankingPresenterSwift init() { self.accountsSupportingTransferringMoney = self.presenter.bankAccounts.filter({ $0.supportsTransferringMoney }) - self.account = self.accountsSupportingTransferringMoney.first - self.showAccounts = self.accountsSupportingTransferringMoney.count > 1 } var body: some View { Form { - if (showAccounts) { + if showAccounts { Section { Picker("Account", selection: $selectedAccountIndex) { ForEach(0 ..< self.accountsSupportingTransferringMoney.count) { accountIndex in