diff --git a/TalerWallet1/Views/Settings/Bank/BankEditView.swift b/TalerWallet1/Views/Settings/Bank/BankEditView.swift index c77b9f01..4e8b6e61 100755 --- a/TalerWallet1/Views/Settings/Bank/BankEditView.swift +++ b/TalerWallet1/Views/Settings/Bank/BankEditView.swift @@ -35,6 +35,10 @@ struct BankEditView: View { @State private var iban: String = EMPTYSTRING @State private var ibanValid = false @State private var xTaler: String = EMPTYSTRING + @State private var xTalerHost: String = EMPTYSTRING // new x-taler-bank account: bank… + @State private var xTalerAccount: String = EMPTYSTRING // …and account name, xTaler = host/account + @State private var methods: [PaytoType] = [.iban, .xTalerBank] + @State private var talerBankHosts: [String] = [] @State private var accountLabel: String = EMPTYSTRING @State private var paytoType: PaytoType = .iban @State private var selected = 0 @@ -96,7 +100,33 @@ struct BankEditView: View { } } } else { + // offer only the account types the user's payment services can deposit to + if let details = try? await model.depositWireTypes(nil) { + var supported: [PaytoType] = [] + for detail in details where [PaytoType.iban, .xTalerBank].contains(detail.paymentTargetType) { + if !supported.contains(detail.paymentTargetType) { + supported.append(detail.paymentTargetType) + } + for host in detail.talerBankHostnames ?? [] where !talerBankHosts.contains(host) { + talerBankHosts.append(host) + } + } + if !supported.isEmpty { + methods = supported + selected = 0 + paytoType = supported[0] + } + if let host = talerBankHosts.first { + xTalerHost = host + } + } + } + } + private func composeXTaler() { + xTaler = xTalerAccount.isEmpty ? EMPTYSTRING : xTalerHost + "/" + xTalerAccount + if userTyped { + unchanged = false } } @@ -167,7 +197,6 @@ struct BankEditView: View { // let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let methods = [PaytoType.iban, PaytoType.xTalerBank] List { if kycCompleted // || true { Section { @@ -228,7 +257,7 @@ struct BankEditView: View { .talerFont(.picker) .accessibilityHidden(true) .padding(.bottom, -12) - } else { + } else if methods.count > 1 { // this is a NEW bank account - choose a payment method Picker(EMPTYSTRING, selection: $selected) { ForEach(0..