commit ce3280d636edd0d0e60c67b6561492261bc86ef3
parent 546cd3ba2945fb88b1c4e9c97c475cc130dcb3ab
Author: Marc Stibane <marc@taler.net>
Date: Fri, 14 Aug 2026 11:51:28 +0200
decode base64 images lazy
Diffstat:
2 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/IconBadge.swift b/TalerWallet1/Views/HelperViews/IconBadge.swift
@@ -40,6 +40,8 @@ struct TransactionIconBadge: View {
let needsKYC: Bool
let imageBase64: String?
+ @State private var image: Image? = nil
+
init(type: TransactionType, foreColor: Color, done: Bool, incoming: Bool,
shouldConfirm: Bool, needsKYC: Bool, imageBase64: String? = nil
) {
@@ -83,22 +85,31 @@ struct TransactionIconBadge: View {
}
var body: some View {
- if let imageBase64, let image = Image(imageBase64: imageBase64) {
- image
- .resizable()
- .aspectRatio(contentMode: .fit)
- .frame(maxHeight: 40)
+ let badge = 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 {
+ if let image {
+ image
+ .resizable()
+ .aspectRatio(contentMode: .fit)
+ .frame(maxHeight: 40)
+ } else {
+ badge
+ .opacity(0.3)
+ .task {
+ image = Image(imageBase64: imageBase64)
+ }
+ }
} 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
+ badge
}
}
}
diff --git a/TalerWallet1/Views/Transactions/PaymentTransactionView.swift b/TalerWallet1/Views/Transactions/PaymentTransactionView.swift
@@ -13,6 +13,8 @@ import SymLog
struct MerchantHeader: View {
let terms: MerchantContractTerms?
+ @State private var image: Image? = nil
+
func summary(_ terms: MerchantContractTerms) -> String {
if let i18nDict = terms.summaryI18n {
if !i18nDict.isEmpty {
@@ -35,8 +37,8 @@ struct MerchantHeader: View {
HStack {
Spacer()
VStack(alignment: .center) {
- if let imageBase64 = terms.merchant.logo {
- if let image = Image(imageBase64: imageBase64) {
+ if terms.merchant.logo != nil {
+ if let image {
image
.resizable()
.aspectRatio(contentMode: .fit)
@@ -53,7 +55,12 @@ struct MerchantHeader: View {
let merchant = terms.merchant.name
Text(merchant)
.talerFont(.title3)
- }.foregroundStyle(Color(.primary))
+ } .foregroundStyle(Color(.primary))
+ .task {
+ if let imageBase64 = terms.merchant.logo {
+ image = Image(imageBase64: imageBase64)
+ }
+ }
Spacer()
}
}