taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit f3e6874b0563dc10862cc40387dfd61ff326e9a5
parent 63e15c1e4fc77af870f2bd4b3121f6bc09ef5f47
Author: Marc Stibane <marc@taler.net>
Date:   Wed,  4 Dec 2024 07:08:31 +0100

A11y textfield label

Diffstat:
MTalerWallet1/Views/Actions/Banking/DepositAmountView.swift | 7+++++--
MTalerWallet1/Views/Actions/Banking/ManualWithdraw.swift | 7+++++--
MTalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift | 5+++--
MTalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift | 2++
MTalerWallet1/Views/HelperViews/AmountInputV.swift | 2++
MTalerWallet1/Views/HelperViews/CurrencyInputView.swift | 17+++++++++++------
MTalerWallet1/Views/HelperViews/ScopePicker.swift | 12+++++++++---
MTalerWallet1/Views/Sheets/Payment/PayTemplateV.swift | 4+++-
MTalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift | 4+++-
9 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift @@ -136,12 +136,15 @@ struct DepositAmountView: View { Text("Available:\t\(availableStr)") .talerFont(.title3) .padding(.bottom, 2) + let a11yLabel = String(localized: "Amount to deposit:", comment: "accessibility, no abbreviations") + let amountLabel = minimalistic ? String(localized: "Amount:") + : a11yLabel CurrencyInputView(scope: scopeInfo, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: nil, // amountAvailable, - title: minimalistic ? String(localized: "Amount:") - : String(localized: "Amount to deposit:"), + title: amountLabel, + a11yTitle: a11yLabel, shortcutAction: nil) .padding(.horizontal) diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift @@ -209,12 +209,15 @@ struct ManualWithdrawContent: View { let tosAccepted = (exchange?.tosStatus == .accepted) ?? false if tosAccepted { + let a11yLabel = String(localized: "Amount to withdraw:", comment: "accessibility, no abbreviations") + let amountLabel = minimalistic ? String(localized: "Amount:") + : a11yLabel CurrencyInputView(scope: scope, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: nil, - title: minimalistic ? String(localized: "Amount:") - : String(localized: "Amount to withdraw:"), + title: amountLabel, + a11yTitle: a11yLabel, shortcutAction: nil) .padding(.top) .task(id: amountToTransfer.value) { // re-run this whenever amountToTransfer changes diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift @@ -251,13 +251,14 @@ struct RequestPaymentContent: View { } let tosAccepted = (exchange?.tosStatus == .accepted) ?? false if tosAccepted { + let a11yLabel = String(localized: "Amount to request:", comment: "accessibility, no abbreviations") let amountLabel = minimalistic ? String(localized: "Amount:") - : String(localized: "Amount to request:") -// Text(amountLabel) + : a11yLabel AmountInputV(stack: stack.push(), scope: balance.scopeInfo, amountAvailable: $amountZero, // incoming needs no available amountLabel: amountLabel, + a11yLabel: a11yLabel, amountToTransfer: $amountToTransfer, amountLastUsed: amountLastUsed, wireFee: nil, diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift @@ -160,10 +160,12 @@ struct SendAmountView: View { NavLink($buttonSelected) { inputDestination } NavLink($shortcutSelected) { shortcutDestination } } + let a11yLabel = String(localized: "Amount to send:", comment: "accessibility, no abbreviations") AmountInputV(stack: stack.push(), scope: balance.scopeInfo, amountAvailable: $amountAvailable, amountLabel: nil, // will use "Available for transfer: xxx", trailing + a11yLabel: a11yLabel, amountToTransfer: $amountToTransfer, amountLastUsed: amountLastUsed, wireFee: nil, diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift @@ -35,6 +35,7 @@ struct AmountInputV: View { let scope: ScopeInfo? @Binding var amountAvailable: Amount let amountLabel: String? + let a11yLabel: String @Binding var amountToTransfer: Amount let amountLastUsed: Amount let wireFee: Amount? @@ -92,6 +93,7 @@ struct AmountInputV: View { amountLastUsed: amountLastUsed, available: amountAvailable, title: amountLabel, + a11yTitle: a11yLabel, shortcutAction: shortcutAction) // .accessibility(sortPriority: 2) diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift @@ -66,6 +66,7 @@ struct CurrencyInputView: View { let amountLastUsed: Amount let available: Amount? let title: String? + let a11yTitle: String let shortcutAction: ((_ amount: Amount) -> Void)? @EnvironmentObject private var controller: Controller @@ -114,20 +115,23 @@ struct CurrencyInputView: View { return buttons } + func availableString(_ availableStr: String) -> String { + String(localized: "Available for transfer: \(availableStr)") + } + + var a11yLabel: String { // format currency for a11y + availableString(available?.readableDescription ?? String(localized: "unknown")) + } + func heading() -> String? { if let title { return title } if let available { - let availableStr = available.formatted(scope, isNegative: false) - return String(localized: "Available for transfer: \(availableStr)") + return availableString(available.formatted(scope, isNegative: false)) } return nil } - var a11yLabel: String { // format currency for a11y - let availableStr = available?.readableDescription ?? String(localized: "unknown") - return String(localized: "Available: \(availableStr)") - } func currencyInfo() -> CurrencyInfo { if let scope { @@ -158,6 +162,7 @@ struct CurrencyInputView: View { .padding(.bottom, -6) } currencyField + .accessibilityLabel(a11yTitle) .frame(maxWidth: .infinity, alignment: .trailing) .foregroundColor(WalletColors().fieldForeground) // text color // .background(WalletColors().fieldBackground) // problem: white corners diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift b/TalerWallet1/Views/HelperViews/ScopePicker.swift @@ -42,7 +42,7 @@ struct ScopePicker: View { let available = balance.available let availableA11y = available.formatted(currencyInfo, isNegative: false, useISO: true, a11y: ".") let url = balance.scopeInfo.url?.trimURL ?? EMPTYSTRING - let a11yLabel = url + ", " + availableA11y +// let a11yLabel = url + ", " + availableA11y HStack(alignment: .firstTextBaseline) { let disabled = (count == 1) @@ -68,11 +68,12 @@ struct ScopePicker: View { .frame(maxWidth: .infinity) // .border(.red) // debugging .pickerStyle(.menu) +// .accessibilityLabel(a11yLabel) .labelsHidden() // be sure to use valid labels for a11y } } .talerFont(.picker) - .accessibilityLabel(a11yLabel) +// .accessibilityLabel(a11yLabel) .accessibilityHint(String(localized: "Choose the payment service.", comment: "a11y")) .task() { withAnimation { selected = value } @@ -105,10 +106,13 @@ struct ScopeDropDown: View { @ViewBuilder func dropDownRow(_ balance: Balance, _ currencyInfo: CurrencyInfo, _ first: Bool = false) -> some View { - let text = Text(urlOrCurrency(balance)) + let urlOrCurrency = urlOrCurrency(balance) + let text = Text(urlOrCurrency) let amount = Text(formattedAmount(balance, currencyInfo).nbs) + let a11yAmount = balance.available.readableDescription if first { text + .accessibilityLabel("via \(urlOrCurrency)") } else { let hLayout = HStack(alignment: .firstTextBaseline) { text @@ -127,6 +131,8 @@ struct ScopeDropDown: View { hLayout vLayout } + .accessibilityElement(children: .combine) + .accessibilityLabel("\(urlOrCurrency), \(a11yAmount)") } } diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift @@ -129,8 +129,9 @@ struct PayTemplateV: View { var body: some View { if let templateContract { // preparePayResult // let currency = templateContract.currency ?? templateContract.amount?.currencyStr ?? UNKNOWN + let a11yLabel = String(localized: "Amount to pay:", comment: "accessibility, no abbreviations") let amountLabel = minimalistic ? String(localized: "Amount:") - : String(localized: "Amount to pay:") + : a11yLabel // final destination with amountToTransfer, after user input of amount let finalDestinationI = PaymentView(stack: stack.push(), url: url, @@ -178,6 +179,7 @@ struct PayTemplateV: View { scope: scope, amountAvailable: $amountAvailable, amountLabel: amountLabel, + a11yLabel: a11yLabel, amountToTransfer: $amountToTransfer, amountLastUsed: amountLastUsed, wireFee: nil, diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift @@ -160,13 +160,15 @@ struct WithdrawURIView: View { NavLink($shortcutSelected) { shortcutDest } NavLink($buttonSelected) { acceptDestination } } + let a11yLabel = String(localized: "Amount to withdraw:", comment: "accessibility, no abbreviations") let amountLabel = minimalistic ? String(localized: "Amount:") // maxAmount - : String(localized: "Amount to withdraw:") + : a11yLabel // TODO: input amount, then AmountInputV(stack: stack.push(), scope: exchange.scopeInfo, amountAvailable: $amountZero, amountLabel: amountZero.isZero ? amountLabel : nil, + a11yLabel: a11yLabel, amountToTransfer: $amountToTransfer, amountLastUsed: amountLastUsed, wireFee: wireFee,