diff options
author | Marc Stibane <marc@taler.net> | 2024-02-04 14:18:20 +0100 |
---|---|---|
committer | Marc Stibane <marc@taler.net> | 2024-02-04 14:21:06 +0100 |
commit | 35d875213d6a56cdbdf4087de57f659d182d128d (patch) | |
tree | 124bc880b0c944553577569a2e93e837a04ae366 | |
parent | d5038ac7de016493dfe7d2f13bde6526e7172b95 (diff) | |
download | taler-ios-35d875213d6a56cdbdf4087de57f659d182d128d.tar.gz taler-ios-35d875213d6a56cdbdf4087de57f659d182d128d.tar.bz2 taler-ios-35d875213d6a56cdbdf4087de57f659d182d128d.zip |
Past Tense
-rw-r--r-- | TalerWallet1/Model/Transaction.swift | 16 | ||||
-rw-r--r-- | TalerWallet1/Views/Transactions/TransactionRowView.swift | 12 | ||||
-rw-r--r-- | TalerWallet1/Views/Transactions/TransactionSummaryV.swift | 10 |
3 files changed, 34 insertions, 4 deletions
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift index 4fb492b..a2956f8 100644 --- a/TalerWallet1/Model/Transaction.swift +++ b/TalerWallet1/Model/Transaction.swift @@ -255,6 +255,19 @@ struct TransactionCommon: Decodable, Sendable { comment: "TransactionType, scan invoice to pay to another wallet") } } + func localizedTypePast(_ type: TransactionType) -> String { + switch type { + case .peerPushDebit: return String(localized: "Sent Money", + comment: "TransactionType, sent coins to another wallet") + case .scanPushCredit: return String(localized: "Received Money", + comment: "TransactionType, received coins sent from another wallet") + case .peerPullCredit: return String(localized: "Requested Money", // Invoice? + comment: "TransactionType, sent invoice to another wallet") + case .scanPullDebit: return String(localized: "Paid Request", // Pay Invoice is the same as Payment + comment: "TransactionType, paid invoice from another wallet") + default: return localizedType(type) + } + } func fee() -> Amount { do { @@ -469,6 +482,9 @@ enum Transaction: Decodable, Hashable, Identifiable, Sendable { var localizedType: String { common.localizedType(common.type) } + var localizedTypePast: String { + common.localizedTypePast(common.type) + } static func == (lhs: Transaction, rhs: Transaction) -> Bool { return lhs.id == rhs.id diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift index 1b80bc2..3b7042e 100644 --- a/TalerWallet1/Views/Transactions/TransactionRowView.swift +++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift @@ -47,6 +47,16 @@ struct TransactionRowView: View { available < (contentWidth + valueWidth + 40) } + func topString() -> String { + switch transaction { + case .payment(let paymentTransaction): + return paymentTransaction.details.info.merchant.name + default: + return transaction.isDone ? transaction.localizedTypePast + : transaction.localizedType + } + } + var body: some View { let common = transaction.common let pending = transaction.isPending @@ -71,7 +81,7 @@ struct TransactionRowView: View { let amountV = AmountV(common.amountEffective) .foregroundColor(foreColor) - let topString = transaction.localizedType + let topString = topString() let centerTop = Text(topString) .foregroundColor(textColor) .strikethrough(!doneOrPending, color: .red) diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift index 38bb311..8ad761d 100644 --- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift +++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift @@ -99,7 +99,8 @@ struct TransactionSummaryV: View { let locale = TalerDater.shared.locale let (dateString, date) = TalerDater.dateString(from: common.timestamp) let accessibilityDate = TalerDater.accessibilityDate(date) ?? dateString - let navTitle2 = transaction.localizedType + let navTitle2 = transaction.isDone ? transaction.localizedTypePast + : transaction.localizedType VStack { List { if developerMode { @@ -332,8 +333,11 @@ struct TransactionSummaryV: View { } } let colon = ":" - ThreeAmountsSheet(common: common, topAbbrev: transaction.localizedType + colon, - topTitle: transaction.localizedType + colon, + let localizedType = transaction.isDone ? transaction.localizedTypePast + : transaction.localizedType + ThreeAmountsSheet(common: common, + topAbbrev: localizedType + colon, + topTitle: localizedType + colon, baseURL: details.exchangeBaseUrl, large: false, summary: details.info.summary) } // p2p |