commit 5c0e2e28e31941d575b1588314ed03fc1e47c0ee
parent 4531aab1e20165db8dad12e9f776b11991c3666b
Author: Marc Stibane <marc@taler.net>
Date: Sat, 13 Jul 2024 17:47:56 +0200
IconBadge
Diffstat:
4 files changed, 103 insertions(+), 36 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 4E0A71182C3AB099002485BB /* IconBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E0A71172C3AB099002485BB /* IconBadge.swift */; };
+ 4E0A71192C3AB099002485BB /* IconBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E0A71172C3AB099002485BB /* IconBadge.swift */; };
4E16E12329F3BB99008B9C86 /* CurrencySpecification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E16E12229F3BB99008B9C86 /* CurrencySpecification.swift */; };
4E18539A2BDAE6D40034F3BA /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 4E1853992BDAE6D40034F3BA /* LocalConsole */; };
4E18539C2BDAE6E50034F3BA /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 4E18539B2BDAE6E50034F3BA /* LocalConsole */; };
@@ -336,6 +338,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 4E0A71172C3AB099002485BB /* IconBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconBadge.swift; sourceTree = "<group>"; };
4E16E12229F3BB99008B9C86 /* CurrencySpecification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CurrencySpecification.swift; sourceTree = "<group>"; };
4E2254952A822B8100E41D29 /* payment_received.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = payment_received.m4a; sourceTree = "<group>"; };
4E2254962A822B8100E41D29 /* payment_sent.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = payment_sent.m4a; sourceTree = "<group>"; };
@@ -829,6 +832,7 @@
4EEC157229F8242800D46A03 /* QRGeneratorView.swift */,
4E5A88F42A38A4FD00072618 /* QRCodeDetailView.swift */,
4E6EDD862A363D8D0031D520 /* ListStyle.swift */,
+ 4E0A71172C3AB099002485BB /* IconBadge.swift */,
4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */,
4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */,
4EB095482989CBFE0043A8A1 /* TextFieldAlert.swift */,
@@ -1256,6 +1260,7 @@
4E6EF56B2B65A33300AF252A /* PaymentDone.swift in Sources */,
4EA076B32BC0607400685A10 /* DepositWithdrawV.swift in Sources */,
4E3EAE6E2A990778009F1BE8 /* Model+P2P.swift in Sources */,
+ 4E0A71182C3AB099002485BB /* IconBadge.swift in Sources */,
4E3EAE6F2A990778009F1BE8 /* TalerStrings.swift in Sources */,
4E3EAE702A990778009F1BE8 /* CurrencyInputView.swift in Sources */,
4E3EAE712A990778009F1BE8 /* URL+id+iban.swift in Sources */,
@@ -1380,6 +1385,7 @@
4E6EF56C2B65A33300AF252A /* PaymentDone.swift in Sources */,
4EA076B42BC0607400685A10 /* DepositWithdrawV.swift in Sources */,
4ECB62802A0BA6DF004ABBB7 /* Model+P2P.swift in Sources */,
+ 4E0A71192C3AB099002485BB /* IconBadge.swift in Sources */,
4EB0950A2989CB7C0043A8A1 /* TalerStrings.swift in Sources */,
4EA551252A2C923600FEC9A8 /* CurrencyInputView.swift in Sources */,
4E363CBC2A237E0900D7E98C /* URL+id+iban.swift in Sources */,
diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift b/TalerWallet1/Views/Balances/PendingRowView.swift
@@ -27,8 +27,8 @@ struct PendingRowView: View {
var body: some View {
let pendingColor = WalletColors().pendingColor(incoming)
- let iconBadge = IconBadge(foreColor: pendingColor, done: false, incoming: incoming,
- shouldConfirm: shouldConfirm, needsKYC: needsKYC)
+ let iconBadge = PendingIconBadge(foreColor: pendingColor, done: false, incoming: incoming,
+ shouldConfirm: shouldConfirm, needsKYC: needsKYC)
let inTitle = minimalistic ? inTitle0 : inTitle1
let outTitle = minimalistic ? outTitle0 : outTitle1
let pendingTitle = incoming ? inTitle : outTitle
diff --git a/TalerWallet1/Views/HelperViews/IconBadge.swift b/TalerWallet1/Views/HelperViews/IconBadge.swift
@@ -0,0 +1,88 @@
+/*
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
+ * See LICENSE.md
+ */
+/**
+ * @author Marc Stibane
+ */
+import SwiftUI
+
+struct PendingIconBadge: View {
+ let foreColor:Color
+ let done: Bool
+ let incoming: Bool
+ let shouldConfirm: Bool
+ let needsKYC: Bool
+
+ var body: some View {
+ let imageName = incoming && done ? DONE_INCOMING
+ : incoming ? PENDING_INCOMING
+ // since the money already left the wallet, show DONE
+ : DONE_OUTGOING // PENDING_OUTGOING
+ IconBadge(imageName: imageName,
+ foreColor: foreColor,
+ shouldConfirm: shouldConfirm,
+ needsKYC: needsKYC)
+ }
+}
+// MARK: -
+struct TransactionIconBadge: View {
+ var type: TransactionType
+ let foreColor:Color
+ let done: Bool
+ let incoming: Bool
+ let shouldConfirm: Bool
+ let needsKYC: Bool
+
+ var body: some View {
+ let imageName = type.iconName(done)
+ IconBadge(imageName: imageName,
+ foreColor: foreColor,
+ shouldConfirm: shouldConfirm,
+ needsKYC: needsKYC)
+ }
+}
+// MARK: -
+struct ButtonIconBadge: View {
+ var type: TransactionType
+ let foreColor:Color
+ let done: Bool
+
+ var body: some View {
+ let imageName = type.iconName(done)
+ IconBadge(imageName: imageName,
+ foreColor: foreColor,
+ shouldConfirm: false,
+ needsKYC: false)
+ }
+}
+// MARK: -
+struct IconBadge: View {
+ let imageName: String
+ let foreColor:Color
+// let pending: Bool
+ let shouldConfirm: Bool
+ let needsKYC: Bool
+
+ var body: some View {
+ let badgeName = needsKYC ? NEEDS_KYC
+ : CONFIRM_BANK
+ HStack(alignment: .top, spacing: -8) { // TODO: adapt spacing to dynamic fontsize
+ ZStack {
+ // "taler.turn.up.backward" is wider than all others
+ // ZStack centers the main icon, and the badge will always be at the same position
+ Image(ICONNAME_REFUND)
+ .foregroundColor(.clear)
+ Image(imageName)
+ .foregroundColor(foreColor)
+ }.talerFont(.title)
+ Image(systemName: badgeName)
+ .talerFont(.caption)
+ .foregroundColor((needsKYC || shouldConfirm) ? .red : .clear)
+ }.accessibilityHidden(true)
+ }
+}
+// MARK: -
+//#Preview {
+// IconBadge()
+//}
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -1,41 +1,13 @@
/*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
* See LICENSE.md
*/
+/**
+ * @author Marc Stibane
+ */
import SwiftUI
import taler_swift
-struct IconBadge: View {
- let foreColor:Color
- let done: Bool
-// let pending: Bool
- let incoming: Bool
- let shouldConfirm: Bool
- let needsKYC: Bool
-
- var body: some View {
- let imageName = incoming && done ? DONE_INCOMING
- : incoming ? PENDING_INCOMING
- // since the money already left the wallet, show DONE
- : DONE_OUTGOING // PENDING_OUTGOING
- let badgeName = needsKYC ? NEEDS_KYC
- : CONFIRM_BANK
- HStack(alignment: .top, spacing: -8) { // TODO: adapt spacing to dynamic fontsize
- ZStack {
- // "plus.diamond" is wider than "plus.circle.fill"
- // ZStack centers the main icon, and the badge will always be at the same position
- Image(systemName: PENDING_INCOMING)
- .foregroundColor(.clear)
- Image(systemName: imageName)
- .foregroundColor(foreColor)
- }.talerFont(.largeTitle)
- Image(systemName: badgeName)
- .talerFont(.caption)
- .foregroundColor((needsKYC || shouldConfirm) ? .red : .clear)
- }.accessibilityHidden(true)
- }
-}
-
struct TransactionRowView: View {
let transaction : Transaction
@@ -78,8 +50,9 @@ struct TransactionRowView: View {
: increasedContrast ? Color(.darkGray)
: .secondary // Color(.tertiaryLabel)
- let iconBadge = IconBadge(foreColor: foreColor, done: done, incoming: incoming,
- shouldConfirm: shouldConfirm, needsKYC: needsKYC)
+ let iconBadge = TransactionIconBadge(type: common.type, foreColor: foreColor,
+ done: done, incoming: incoming,
+ shouldConfirm: shouldConfirm, needsKYC: needsKYC)
let amountV = AmountV(common.amountEffective)
.foregroundColor(foreColor)