commit 25f2384a08f23d8495c23392586ed4e32febb367
parent 4a5313073b28e35139d11e759e0a04c66b4e162c
Author: Marc Stibane <marc@taler.net>
Date: Thu, 6 Aug 2026 22:12:02 +0200
show merchant icon
Diffstat:
2 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/IconBadge.swift b/TalerWallet1/Views/HelperViews/IconBadge.swift
@@ -38,17 +38,23 @@ struct TransactionIconBadge: View {
let incoming: Bool
let shouldConfirm: Bool
let needsKYC: Bool
+ let imageBase64: String?
- init(type: TransactionType, foreColor: Color, done: Bool, incoming: Bool, shouldConfirm: Bool, needsKYC: Bool) {
+ init(type: TransactionType, foreColor: Color, done: Bool, incoming: Bool,
+ shouldConfirm: Bool, needsKYC: Bool, imageBase64: String? = nil
+ ) {
self.type = type
self.foreColor = foreColor
self.done = done
self.incoming = incoming
self.shouldConfirm = shouldConfirm
self.needsKYC = needsKYC
+ self.imageBase64 = imageBase64
}
- init(from transaction: TalerTransaction, isDark: Bool, _ increasedContrast: Bool) {
+ init(from transaction: TalerTransaction, isDark: Bool, _ increasedContrast: Bool,
+ imageBase64: String? = nil
+ ) {
let common = transaction.common
self.type = common.type
let done = transaction.isDone
@@ -73,19 +79,27 @@ struct TransactionIconBadge: View {
: done ? WalletColors().transactionColor(incoming)
: WalletColors().uncompletedColor
self.foreColor = foreColor
+ self.imageBase64 = imageBase64
}
var body: some View {
- IconBadge(image: type.icon(done),
- done: true,
- foreColor: foreColor,
- shouldConfirm: shouldConfirm,
- needsKYC: needsKYC,
- phase: 0,
- firstImage: nil,
- secondImage: nil,
- wideIcon: TransactionType.refund.icon())
- // "arrowshape.turn.up.backward" is wider than all others
+ if let imageBase64, let image = Image(imageBase64: imageBase64) {
+ image
+ .resizable()
+ .aspectRatio(contentMode: .fit)
+ .frame(maxHeight: 40)
+ } else {
+ IconBadge(image: type.icon(done),
+ done: true,
+ foreColor: foreColor,
+ shouldConfirm: shouldConfirm,
+ needsKYC: needsKYC,
+ phase: 0,
+ firstImage: nil,
+ secondImage: nil,
+ wideIcon: TransactionType.refund.icon())
+ // "arrowshape.turn.up.backward" is wider than all others
+ }
}
}
// MARK: -
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -39,6 +39,7 @@ struct TransactionRowView: View {
@Environment(\.sizeCategory) var sizeCategory
@Environment(\.colorScheme) private var colorScheme
@Environment(\.colorSchemeContrast) private var colorSchemeContrast
+ @EnvironmentObject private var model: WalletModel
@AppStorage("minimalistic") var minimalistic: Bool = false
#if DEBUG
@AppStorage("developerMode") var developerMode: Bool = true
@@ -47,6 +48,7 @@ struct TransactionRowView: View {
#endif
@AppStorage("debugViews") var debugViews: Bool = false
+ @State private var merchantLogo: String? = nil
@State private var layoutStati0: [Int: Bool] = [:]
@State private var layoutStati1: [Int: Bool] = [:]
@@ -134,7 +136,8 @@ struct TransactionRowView: View {
done: done,
incoming: incoming,
shouldConfirm: shouldConfirm && pending,
- needsKYC: needsKYC && pending)
+ needsKYC: needsKYC && pending,
+ imageBase64: merchantLogo)
}
var topA11y: String { topString(forA11y: true)! }
var a11yLabel: String { donePendingDialog ? topA11y
@@ -312,11 +315,41 @@ struct TransactionRowView: View {
}
#endif
+ func merchantLogo(talerTx: TalerTransaction) -> String? {
+ switch talerTx {
+ case .payment(let paymentTransaction):
+ if let terms = paymentTransaction.details.contractTerms {
+ return terms.merchant.logo
+ }
+ default: break
+ }
+ return nil
+ }
+ private func viewDidLoad() async {
+ if transaction.isPayment {
+ let txId = transaction.id
+ if merchantLogo == nil {
+ symLog.log("loading merchantLogo for \(txId)")
+ if let fullTx = try? await model.getTransactionById(txId, includeContractTerms: true) {
+ if let logo = merchantLogo(talerTx: fullTx) {
+ symLog("found terms.merchant.logo for \(txId)")
+ merchantLogo = logo
+ } else {
+ symLog("no logo")
+ }
+ } else {
+ symLog.log("loading \(txId) failed")
+ }
+ } else {
+ symLog.log("There is already a merchantLogo for \(txId)")
+ }
+ }
+ }
var body: some View {
#if DEBUG
// let _ = Self._printChanges()
- let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
+// let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
// let details = transaction.detailsToShow()
// let keys = details.keys
@@ -344,6 +377,9 @@ struct TransactionRowView: View {
: shouldConfirm ? String(localized: ". Needs bank authorization", comment: "a11y")
: EMPTYSTRING)
.accessibilityHint(String(localized: "Will go to detail view.", comment: "a11y"))
+ .task {
+ await viewDidLoad()
+ }
}
}
// MARK: -