taler-ios

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

commit 8abb8bda005475d2567ba8af2d1b9b1130d1ed80
parent 50a02d308c5bd8a695f55e5d050d9f921e6c912c
Author: Marc Stibane <marc@taler.net>
Date:   Tue, 20 Jun 2023 09:22:40 +0200

Localization

Diffstat:
MTalerWallet1/Backend/Transaction.swift | 15+++++++++++++++
MTalerWallet1/Views/Balances/BalanceRowView.swift | 14++++++++++----
MTalerWallet1/Views/Exchange/ManualWithdraw.swift | 1+
MTalerWallet1/Views/Main/SideBarView.swift | 3++-
MTalerWallet1/Views/Payment/PaymentAcceptView.swift | 5+++--
MTalerWallet1/Views/Peer2peer/RequestPayment.swift | 12+++++++-----
MTalerWallet1/Views/Peer2peer/SendAmount.swift | 6++++--
MTalerWallet1/Views/Transactions/ThreeAmounts.swift | 2+-
MTalerWallet1/Views/Transactions/TransactionRowView.swift | 22+++-------------------
9 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/TalerWallet1/Backend/Transaction.swift b/TalerWallet1/Backend/Transaction.swift @@ -321,6 +321,21 @@ enum Transaction: Decodable, Hashable, Identifiable { var id: String { common.transactionId } + var localizedType: String { + switch common.type { + case .withdrawal: return String(localized: "Withdrawal") + case .deposit: return String(localized: "Deposit") + case .payment: return String(localized: "Payment") + case .refund: return String(localized: "Refund") + case .refresh: return String(localized: "Refresh") + case .reward: return String(localized: "Reward") + case .peerPushDebit: return String(localized: "P2P Send") + case .scanPushCredit: return String(localized: "P2P Receive") + case .peerPullCredit: return String(localized: "P2P Invoice") + case .scanPullDebit: return String(localized: "P2P Payment") + } + } + static func == (lhs: Transaction, rhs: Transaction) -> Bool { return lhs.id == rhs.id } diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -14,26 +14,32 @@ struct BalanceRowView: View { let recvAction: () -> Void let rowAction: () -> Void var body: some View { + let currency = amount.currencyStr HStack { Button("Request\nPayment", action: recvAction) .lineLimit(2) .disabled(false) .buttonStyle(TalerButtonStyle(type: .bordered, narrow: true, aligned: .leading)) - Button("Send\nCoins", action: sendAction) + Button("Send\n\(currency)", action: sendAction) .lineLimit(2) .disabled(amount.isZero) .buttonStyle(TalerButtonStyle(type: .bordered, narrow: true, aligned: .leading)) Button(action: rowAction) { - VStack(alignment: .trailing) { - Text("Balance") - .font(.footnote) + VStack(alignment: .trailing, spacing: 0) { + HStack(alignment: .firstTextBaseline, spacing: 0) { + Text("B") + .font(.title2) + Text("alance") + .font(.footnote).bold() .accessibility(sortPriority: 2) + } Text("\(amount.valueStr)") // TODO: CurrencyFormatter? .font(.title) .accessibility(sortPriority: 1) } } .disabled(false) .buttonStyle(TalerButtonStyle(type: .plain, aligned: .trailing)) +// .background(Color.yellow) } .fixedSize(horizontal: false, vertical: true) // should make all buttons equal height - but doesn't .accessibilityElement(children: .combine) diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift @@ -40,6 +40,7 @@ struct ManualWithdraw: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let currency = exchange.currency! + let navTitle = String(localized: "Withdraw \(currency)") let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) // becomeFirstResponder let agePicker = AgePicker(ageMenuList: $ageMenuList, selectedAge: $selectedAge) diff --git a/TalerWallet1/Views/Main/SideBarView.swift b/TalerWallet1/Views/Main/SideBarView.swift @@ -29,7 +29,8 @@ struct SideBarView: View { HStack { // sideView left, clear dismiss target right EqualIconWidthDomain { VStack(spacing: 10) { - Link("GNU Taler", destination: URL(string:"https://taler.net")!) + let gnuTaler = String("GNU Taler") // this should NOT be translated + Link(gnuTaler, destination: URL(string:"https://taler.net")!) .font(.largeTitle) //.bold() iOS 16 .padding(.top, 30) Image("taler-logo-2023-red") diff --git a/TalerWallet1/Views/Payment/PaymentAcceptView.swift b/TalerWallet1/Views/Payment/PaymentAcceptView.swift @@ -20,10 +20,11 @@ struct PaymentAcceptView: View { Group { let raw = detailsForUri.amountRaw let effective = detailsForUri.amountEffective + let currency = raw.currencyStr let fee = try! Amount.diff(raw, effective) // TODO: different currencies - ThreeAmountsView(topTitle: "Amount to pay:", + ThreeAmountsView(topTitle: String(localized: "Amount to pay:"), topAmount: raw, fee: fee, - bottomTitle: "Coins to be spent:", + bottomTitle: String(localized: "\(currency) to be spent:"), bottomAmount: effective, large: true, pending: false, incoming: false, baseURL: detailsForUri.contractTerms.exchanges.first?.url) diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift @@ -8,7 +8,6 @@ import SymLog struct RequestPayment: View { private let symLog = SymLogV() - let navTitle = String(localized: "Request Payment") var scopeInfo: ScopeInfo @Binding var centsToTransfer: UInt64 @@ -22,10 +21,13 @@ struct RequestPayment: View { let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let currencyField = CurrencyField(value: $centsToTransfer, currency: scopeInfo.currency) + let currency = scopeInfo.currency + let navTitle = String(localized: "Request \(currency)") + let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) VStack(alignment: .leading, spacing: 6) { - CurrencyInputView(currencyField: currencyField, title: "Amount to receive:") + CurrencyInputView(currencyField: currencyField, + title: String(localized: "Amount to receive:")) HStack { let disabled = centsToTransfer == 0 @@ -43,7 +45,7 @@ struct RequestPayment: View { deactivateAction() } }) { - Text("title2") + Text("Create invoice") } .buttonStyle(TalerButtonStyle(type: .prominent)) .disabled(disabled) @@ -52,9 +54,9 @@ struct RequestPayment: View { Spacer() } .frame(maxWidth: .infinity, alignment: .leading) - .navigationTitle(navTitle) .padding(.horizontal) .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) + .navigationTitle(navTitle) .onAppear { // make CurrencyField show the keyboard DebugViewC.shared.setViewID(VIEW_INVOICE_P2P) print("❗️Yikes \(navTitle) onAppear") diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift @@ -38,6 +38,7 @@ struct SendAmount: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let currency = amountAvailable.currencyStr + let navTitle = String(localized: "Send \(currency)") let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) let fee = fee(ppCheck: peerPushCheck) @@ -45,7 +46,8 @@ struct SendAmount: View { let available = amountAvailable.readableDescription Text("Available: \(available)") .font(.title3) - CurrencyInputView(currencyField: currencyField, title: "Amount to send:") + CurrencyInputView(currencyField: currencyField, + title: String(localized: "Amount to send:")) Text("+ \(fee) payment fee") .foregroundColor(.red) @@ -67,7 +69,7 @@ struct SendAmount: View { expireDays: $expireDays, deactivateAction: {}) }) { - Text(title2) + Text("To another wallet") } .buttonStyle(TalerButtonStyle(type: .prominent)) .disabled(disabled) diff --git a/TalerWallet1/Views/Transactions/ThreeAmounts.swift b/TalerWallet1/Views/Transactions/ThreeAmounts.swift @@ -64,7 +64,7 @@ struct ThreeAmountsView: View { large: large) if let baseURL { VStack { - Text(incoming ? "from Exchange" : "to Exchange") + Text(incoming ? "from Exchange:" : "to Exchange:") .font(.title3) Text(baseURL.trimURL()) .font(large ? .title : .title2) diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift @@ -38,30 +38,14 @@ struct TransactionRowView: View { : done ? WalletColors().transactionColor(incoming) : WalletColors().uncompletedColor - HStack { + HStack(spacing: 6) { Image(systemName: incoming ? "text.badge.plus" : "text.badge.minus") .foregroundColor(foreColor) - .padding(.trailing) .font(.largeTitle) .accessibility(hidden: true) - if transaction.isWithdrawal { - TransactionRowCenter(centerTop: String(localized: "Withdrawal"), centerBottom: dateString) - } else if transaction.isPayment { - TransactionRowCenter(centerTop: String(localized: "Payment"), centerBottom: dateString) - } else if transaction.isP2pOutgoing { - TransactionRowCenter(centerTop: String(localized: "P2P Send"), centerBottom: dateString) - } else if transaction.isP2pIncoming { - TransactionRowCenter(centerTop: String(localized: "P2P Receive"), centerBottom: dateString) - } else if transaction.isRefund { - TransactionRowCenter(centerTop: String(localized: "Refund"), centerBottom: dateString) - } else if transaction.isRefresh { - TransactionRowCenter(centerTop: String(localized: "Refresh"), centerBottom: dateString) - } else if keys.contains(EXCHANGEBASEURL) { - if let baseURL = details[EXCHANGEBASEURL] { - TransactionRowCenter(centerTop: baseURL.trimURL(), centerBottom: dateString) - } - } + TransactionRowCenter(centerTop: transaction.localizedType, + centerBottom: dateString) Spacer() VStack(alignment: .trailing) { let sign = incoming ? "+" : "-"