commit ffd9996f2be305a5351ddb225122c8046ecf4174
parent 475120e5587e7802331bd99575a7fcc07937cd30
Author: Marc Stibane <marc@taler.net>
Date: Mon, 23 Nov 2026 19:38:41 +0100
AI: 12064 new x-Taler account
Diffstat:
1 file changed, 58 insertions(+), 3 deletions(-)
diff --git 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
+ @State private var xTalerAccount: String = EMPTYSTRING
+ @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
@@ -103,7 +107,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
}
}
@@ -173,8 +203,6 @@ struct BankEditView: View {
let _ = Self._printChanges()
// 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 {
@@ -235,7 +263,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..<methods.count, id: \.self) { index in
@@ -265,6 +293,33 @@ struct BankEditView: View {
}
}
}
+ } else if paytoType == .xTalerBank && accountID == nil && !talerBankHosts.isEmpty {
+ // NEW x-taler-bank account: the bank comes from the payment service,
+ // the user only types the account name
+ let bankTitle = String(localized: "Bank")
+ Picker(bankTitle, selection: $xTalerHost) {
+ ForEach(talerBankHosts, id: \.self) { host in
+ Text(host).tag(host)
+ }
+ }
+ .talerFont(.title3)
+ .onChange(of: xTalerHost) { _ in composeXTaler() }
+ let accountColon = String(localized: "Account:")
+ if !minimalistic {
+ Text(accountColon)
+ .talerFont(.picker)
+ .accessibilityHidden(true)
+ .padding(.bottom, -12)
+ }
+ TextField(minimalistic ? accountColon : EMPTYSTRING, text: $xTalerAccount)
+ .accessibilityLabel(accountColon)
+ .focused($focus, equals: .xTaler)
+ .talerFont(.title3)
+ .foregroundColor(WalletColors().fieldForeground) // text color
+ .background(WalletColors().fieldBackground)
+ .textFieldStyle(.roundedBorder)
+ .padding(.bottom)
+ .onChange(of: xTalerAccount) { _ in composeXTaler() }
} else if paytoType == .xTalerBank {
TextField("BANK-HOST/ACCOUNT", text: $xTaler)
.accessibilityLabel(paytoColon)