commit 4ae2fddf0403975d3f116a06101b9d57783c972f
parent df9b7e60b8c6cad130093923f31681f06fa0568d
Author: Marc Stibane <marc@taler.net>
Date: Wed, 23 Jul 2025 08:23:06 +0200
convenience init
Diffstat:
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/IconBadge.swift b/TalerWallet1/Views/HelperViews/IconBadge.swift
@@ -30,12 +30,48 @@ struct PendingIconBadge: View {
// MARK: -
struct TransactionIconBadge: View {
var type: TransactionType
- let foreColor:Color
+ var foreColor: Color
let done: Bool
let incoming: Bool
let shouldConfirm: Bool
let needsKYC: Bool
+ init(type: TransactionType, foreColor: Color, done: Bool, incoming: Bool, shouldConfirm: Bool, needsKYC: Bool) {
+ self.type = type
+ self.foreColor = foreColor
+ self.done = done
+ self.incoming = incoming
+ self.shouldConfirm = shouldConfirm
+ self.needsKYC = needsKYC
+ }
+
+ init(from transaction: TalerTransaction, isDark: Bool, _ increasedContrast: Bool) {
+ let common = transaction.common
+ self.type = common.type
+ let done = transaction.isDone
+ self.done = done
+ let incoming = common.incoming()
+ self.incoming = incoming
+ let needsKYC = transaction.isPendingKYC || transaction.isPendingKYCauth
+ self.needsKYC = needsKYC
+ self.shouldConfirm = transaction.shouldConfirm
+ let pending = transaction.isPending || transaction.common.isFinalizing
+ self.foreColor = .primary
+
+ let doneOrPending = done || pending
+ let isZero = common.amountEffective.isZero
+ let refreshZero = common.type.isRefresh && isZero
+ let textColor = doneOrPending ? .primary
+ : isDark ? .secondary
+ : increasedContrast ? Color(.darkGray)
+ : .secondary // Color(.tertiaryLabel)
+ let foreColor = refreshZero ? textColor
+ : pending ? WalletColors().pendingColor(incoming)
+ : done ? WalletColors().transactionColor(incoming)
+ : WalletColors().uncompletedColor
+ self.foreColor = foreColor
+ }
+
var body: some View {
IconBadge(image: type.icon(done),
done: true,
@@ -81,7 +117,7 @@ struct IconBadge: View {
wideIcon.foregroundColor(.clear)
}
image.foregroundColor(foreColor)
- }.talerFont(.title2)
+ }
// ZStack centers the main icon, so the badge will always be at the same position
let badgeName = needsKYC ? NEEDS_KYC
: CONFIRM_BANK