Fixed that account didn't reflect selected account

This commit is contained in:
dankito 2020-07-18 17:25:01 +02:00
parent 72242d2cf7
commit 90a0ad5b4a
1 changed files with 11 additions and 7 deletions

View File

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