diff --git a/TalerCommon/HelperViews/CurrencyInputView.swift b/TalerCommon/HelperViews/CurrencyInputView.swift index c3c5697b..8fc4a835 100644 --- a/TalerCommon/HelperViews/CurrencyInputView.swift +++ b/TalerCommon/HelperViews/CurrencyInputView.swift @@ -129,6 +129,11 @@ struct CurrencyInputView: View { availableString(available?.readableDescription ?? String(localized: "unknown")) } + /// Why the amount cannot be sent -- `DepositAmountView`'s string. + var insufficientHint: String { + String(localized: "You don't have enough \(currencyInfo().specs.name).") + } + func heading() -> (String, String)? { if let title { return (title, a11yTitle) @@ -166,6 +171,32 @@ struct CurrencyInputView: View { .accessibilityLabel(heading.1) .padding(.bottom, -6) } + if insufficient, available != nil { + // Turning the heading red was the whole message: no words + // for a sighted user, and nothing at all for VoiceOver, + // which reads the unchanged `heading.1`. + // + // DepositAmountView already prints exactly this sentence in + // exactly this colour for exactly this condition + // (DepositAmountView.swift:100,127-133). Copying its + // wording rather than inventing one keeps the two screens + // saying the same thing and needs no new translation. + // + // `available != nil` is load-bearing, not defensive. The + // withdrawal amount screen reaches this view with + // `available` nil and reuses the same `insufficient` flag + // for a different condition -- more than the *bank's* + // maximum, not more than the wallet holds + // (WithdrawUriScan.swift:85-92). "You don't have enough + // KUDOS" would be a false statement there. That screen + // needs its own sentence and does not have one either; + // this patch does not invent it. + Text(insufficientHint) + .padding(.horizontal, 4) + .frame(maxWidth: .infinity, alignment: title != nil ? .leading : .trailing) + .talerFont(.body) + .foregroundColor(WalletColors().attention) + } currencyField .frame(maxWidth: .infinity, alignment: .trailing) .foregroundColor(WalletColors().fieldForeground) // text color diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift index 87482845..15387c5b 100644 --- a/TalerWallet1/Views/HelperViews/AmountInputV.swift +++ b/TalerWallet1/Views/HelperViews/AmountInputV.swift @@ -106,7 +106,18 @@ struct AmountInputV: View { let currency = amountToTransfer.currencyStr let coinData = CoinData(coins: numCoins, fee: feeAmount) let flags = checkAvailable(coinData) - let hint = String(localized: "enabled when amount is non-zero", comment: "a11y") + // One hint for three different reasons was wrong twice over: a + // VoiceOver user with too high an amount was told the button needs a + // non-zero one, and the real reason was never spoken at all. The + // longer string is DepositAmountView's own + // (DepositAmountView.swift:134) -- already translated, and already + // the right sentence for a button gated on the balance as well as + // on zero. A new literal here would ship untranslated, which is + // bug 11946's family. + let hint = ((flags.insufficient && !isIncoming) || coinData.tooMany) + ? String(localized: "enabled when amount is non-zero, but not higher than your available amount", + comment: "a11y") + : String(localized: "enabled when amount is non-zero", comment: "a11y") ScrollView { VStack(alignment: .trailing) { CurrencyInputView(scope: scope, amount: $amountToTransfer,