diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift index 968b16e7..fbc2c8c2 100755 --- a/TalerWallet1/Views/Balances/BalancesSectionView.swift +++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -72,6 +72,14 @@ struct BalancesSectionView { withAnimation { completedTransactions = transactions } } } + /// The legitimization URL of whichever pending transaction in this + /// currency is waiting for one. + var pendingKycUrl: String? { + pendingTransactions.first { tx in + (tx.isPendingKYC || tx.isPendingKYCauth) && tx.common.kycUrl != nil + }?.common.kycUrl + } + @MainActor func loadPending(_ stack: CallStack) async -> () { if let transactions = try? await model.getTransactionsV2(stack.push("loadPending - \(balance.scopeInfo.url?.trimURL)"), @@ -134,6 +142,25 @@ extension BalancesSectionView: View { pendingTransactions: $pendingTransactions, reloadPending: loadPending) .padding(.leading, ICONLEADING) + // The legitimization control, on the screen the user is + // actually left on. Its own row, deliberately: the pending + // row IS a NavigationLink, and a button inside a row that + // navigates is not reliably tappable in SwiftUI -- the row + // swallows the tap and the user lands in the transaction + // list instead of the legitimization website. + // + // No new request for the URL: `loadPending` above already + // fetched this scope's pending transactions, so the URL the + // detail view's button uses is on this screen already and + // was simply never offered here. + // + // One button rather than one per transaction: the exchange + // runs one legitimization per account, so every one of them + // would lead to the same place. + if let kycUrl = pendingKycUrl { + KYCbutton(kycUrl: kycUrl) + .listRowSeparator(.hidden) + } } if !scannedTransactions.isEmpty { BalancesDialogRowV(stack: stack.push(), diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift b/TalerWallet1/Views/Balances/PendingRowView.swift index c42bfd39..d277c254 100644 --- a/TalerWallet1/Views/Balances/PendingRowView.swift +++ b/TalerWallet1/Views/Balances/PendingRowView.swift @@ -29,7 +29,42 @@ struct PendingRowView: View { let outTitle1 = String(localized: "TitleOutgoing_Full", defaultValue: "Pending\toutgoing", comment: "`Pending outgoing´ in Balances - set exactly 1 \\t for line break") + /// Why this row is waiting for the *user* rather than for the network. + /// + /// The badge already said this -- as a 􀋃 the size of a full stop, with + /// no text, inside an `accessibilityHidden(true)` HStack. A glyph and a + /// colour cannot carry "you have to do something" on their own, so a + /// transfer blocked on a legitimization check and one that is merely + /// slow read identically on the screen the user is left on. + var actionNeeded: String? { + if needsKYC { + // The existing keys, not new literals: `MinorState.kyc` is + // already translated and is the exact string the detail view's + // status line shows for this state, and the confirm wording is + // the one the withdrawal detail's own button carries. A new + // literal here would ship untranslated, which is bug 11946's + // family. + return TransactionMinorState.kyc.localizedState + } + if shouldConfirm { + return String(localized: "The bank is waiting for your authorization.") + } + return nil + } + var body: some View { + VStack(alignment: .leading, spacing: 2) { + amountLine + if let actionNeeded { + Text(actionNeeded) + .talerFont(.subheadline) + .foregroundColor(WalletColors().attention) + .frame(maxWidth: .infinity, alignment: .leading) + } + } + } + + @ViewBuilder var amountLine: some View { let pendingColor = WalletColors().pendingColor(incoming) let iconBadge = PendingIconBadge(foreColor: pendingColor, done: false, incoming: incoming, shouldConfirm: shouldConfirm, needsKYC: needsKYC) 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, diff --git a/TalerWallet1/Views/Main/WalletMain.swift b/TalerWallet1/Views/Main/WalletMain.swift index a7ae4b97..b7cfffe7 100755 --- a/TalerWallet1/Views/Main/WalletMain.swift +++ b/TalerWallet1/Views/Main/WalletMain.swift @@ -390,6 +390,22 @@ struct WalletMain: View { shouldReloadTransactions += 1 // selectedTab = .balances // automatically switch to Balances } + .onNotification(.TransactionStateTransition) { notification in + // Deleted, Expired, Scanned and Done were reloaded; a plain + // *transition* was not, so the Balances screen kept whatever + // `loadPending` last fetched. A transaction that moves from + // `pending/merge` to `pending/kyc` acquires both its minor + // state and its kycUrl in that transition, so the one screen + // the user is left on held a copy of the transaction from + // before it needed anything of them -- and could not have + // shown a legitimization hint even if asked to. + // + // `TransactionSummaryList` has listened to this all along + // (TransactionSummaryList.swift:423), which is why the detail + // view is right and the screen in front of it is not. + logger.info(".onNotification(.TransactionStateTransition) ==> reload transactions") + shouldReloadTransactions += 1 + } .onNotification(.TransactionError) { notification in // TODO: reload pending ?? } diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift index 236c96b8..b48c306b 100755 --- a/TalerWallet1/Views/Transactions/TransactionRowView.swift +++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift @@ -102,6 +102,23 @@ struct TransactionRowView: View { var isWorking: Bool { transaction.isWorking } var pending: Bool { transaction.isPending || common.isFinalizing } var needsKYC: Bool { transaction.isPendingKYC || transaction.isPendingKYCauth } + /// The visible twin of this row's `accessibilityValue`. + var actionNeeded: String? { + guard donePendingDialog else { return nil } + if needsKYC { + // The existing keys, not new literals: `MinorState.kyc` is + // already translated and is the exact string the detail view's + // status line shows for this state, and the confirm wording is + // the one the withdrawal detail's own button carries. A new + // literal here would ship untranslated, which is bug 11946's + // family. + return TransactionMinorState.kyc.localizedState + } + if shouldConfirm { + return String(localized: "The bank is waiting for your authorization.") + } + return nil + } var doneOrPending: Bool { done || pending } var donePendingDialog: Bool { doneOrPending || transaction.isDialog } var shouldConfirm: Bool { transaction.shouldConfirm } @@ -272,6 +289,15 @@ struct TransactionRowView: View { #if TALER_NIGHTLY .overlay { Color.clear.border(green) } #endif + // The row already put this in its accessibilityValue, so + // VoiceOver was told why the transaction is stuck and the screen + // was not. Shown only for the two states that are waiting for + // the user, so an ordinary row's layout is unchanged. + if let actionNeeded { + Text(actionNeeded) + .talerFont(.subheadline) + .foregroundColor(WalletColors().attention) + } } ZStack { row diff --git a/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift b/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift index 75efbdfb..d60906c5 100755 --- a/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift +++ b/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift @@ -134,6 +134,14 @@ struct TransactionTypeDetail: View { KYCauth(stack: stack.push(), common: common) } else if transaction.isPendingKYC { KYCbutton(kycUrl: common.kycUrl) + if common.kycUrl == nil { + // KYCbutton renders nothing at all without a URL, + // so without this the detail view -- the one place + // that explains why the deposit is stuck -- would + // be silent about it. PendingWithdrawalDetails + // has had this fallback all along. + Text("Legitimization procedure required", comment: "KYC") + } } ThreeAmountsSheet(stack: stack.push(), scope: scope, @@ -224,6 +232,10 @@ struct TransactionTypeDetail: View { let details = p2pTransaction.details if transaction.isPendingKYC { KYCbutton(kycUrl: common.kycUrl) + if common.kycUrl == nil { + // Same gap as the deposit case: no URL, no view. + Text("Legitimization procedure required", comment: "KYC") + } } if !transaction.isDone { ExpiresView(expiration: details.info.expiration) diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift index 05744938..17745677 100755 --- a/TalerWallet1/Views/Transactions/TransactionsListView.swift +++ b/TalerWallet1/Views/Transactions/TransactionsListView.swift @@ -59,6 +59,15 @@ struct TransactionsListView: View { let oimCash = OIMcash(oimCurrency) self._cash = StateObject(wrappedValue: { oimCash }()) } + /// The legitimization URL of whichever listed transaction is waiting + /// for one. Twin of `BalancesSectionView.pendingKycUrl`; same + /// reasoning, and the transactions are already loaded here too. + var kycUrl: String? { + transactions.first { tx in + (tx.isPendingKYC || tx.isPendingKYCauth) && tx.common.kycUrl != nil + }?.common.kycUrl + } + var body: some View { #if PRINT_CHANGES let _ = Self._printChanges() @@ -80,6 +89,16 @@ struct TransactionsListView: View { } else { let list = ScrollViewReader { scrollProxy in List { + // The button, on this screen too. A link inside a + // row would be nested in that row's NavigationLink + // and is not reliably tappable, so it goes above + // the rows -- which is also where it belongs: the + // exchange runs one legitimization per account, + // not one per transaction. + if let kycUrl { + KYCbutton(kycUrl: kycUrl) + .listRowSeparator(.hidden) + } let header = scope.url?.trimURL ?? scope.currency TransactionsArraySection(symLog: symLog, logger: logger,