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] = [] private var accountsSupportingTransferringMoney: [BUCBankAccount] = []
@State private var selectedAccountIndex = 0 @State private var selectedAccountIndex = 0
private var account: BUCBankAccount? = nil
@State private var remitteeName: String = "" @State private var remitteeName: String = ""
@State private var isValidRemitteeNameEntered = false @State private var isValidRemitteeNameEntered = false
@ -32,30 +31,35 @@ struct TransferMoneyDialog: View {
@State private var instantPayment = false @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 { private var supportsInstantPayment: Bool {
return self.account?.supportsInstantPaymentMoneyTransfer ?? false return self.account?.supportsInstantPaymentMoneyTransfer ?? false
} }
@State private var transferMoneyResponseMessage: Message? = nil
@Inject private var presenter: BankingPresenterSwift @Inject private var presenter: BankingPresenterSwift
init() { init() {
self.accountsSupportingTransferringMoney = self.presenter.bankAccounts.filter({ $0.supportsTransferringMoney }) self.accountsSupportingTransferringMoney = self.presenter.bankAccounts.filter({ $0.supportsTransferringMoney })
self.account = self.accountsSupportingTransferringMoney.first
self.showAccounts = self.accountsSupportingTransferringMoney.count > 1 self.showAccounts = self.accountsSupportingTransferringMoney.count > 1
} }
var body: some View { var body: some View {
Form { Form {
if (showAccounts) { if showAccounts {
Section { Section {
Picker("Account", selection: $selectedAccountIndex) { Picker("Account", selection: $selectedAccountIndex) {
ForEach(0 ..< self.accountsSupportingTransferringMoney.count) { accountIndex in ForEach(0 ..< self.accountsSupportingTransferringMoney.count) { accountIndex in