[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 26/30: badge for button
From: |
gnunet |
Subject: |
[taler-taler-ios] 26/30: badge for button |
Date: |
Sun, 19 Nov 2023 23:53:50 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 74336e727e14e9830687e3046702795c45bb9b2a
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Nov 19 22:08:24 2023 +0100
badge for button
---
TalerWallet1/Controllers/PublicConstants.swift | 4 +-
TalerWallet1/Views/HelperViews/Buttons.swift | 66 +++++++++++-----------
.../Views/Transactions/TransactionDetailView.swift | 6 +-
.../Views/Transactions/TransactionRowView.swift | 4 +-
4 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/TalerWallet1/Controllers/PublicConstants.swift
b/TalerWallet1/Controllers/PublicConstants.swift
index 69da359..1b5c9ae 100644
--- a/TalerWallet1/Controllers/PublicConstants.swift
+++ b/TalerWallet1/Controllers/PublicConstants.swift
@@ -13,7 +13,9 @@ public let ONEDAY: UInt = 1 // 1..3
public let SEVENDAYS: UInt = 7 // 3..9
public let THIRTYDAYS: UInt = 30 // 10..30
-public let EMPTYSTRING = "" // avoid automatic
translation of empty "" textLiterals in Text()
+public let EMPTYSTRING = "" // avoid automatic
translation of empty "" textLiterals in Text()
+public let CONFIRM_BANK = "circle.fill" // badge in PendingRow,
TransactionRow and TransactionDetail
+public let NEEDS_KYC = "star.fill" // badge in PendingRow,
TransactionRow and TransactionDetail
public let HTTPS = "https://"
//public let DEMOBANK = HTTPS + "bAnK.dEmO.tAlEr.nEt" // should be
weird to read, but still work
//public let DEMOEXCHANGE = HTTPS + "eXcHaNgE.dEmO.tAlEr.nEt"
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift
b/TalerWallet1/Views/HelperViews/Buttons.swift
index 3e3884c..9ab4a4b 100644
--- a/TalerWallet1/Views/HelperViews/Buttons.swift
+++ b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -93,7 +93,7 @@ struct ReloadButton : View {
struct TalerButtonStyle: ButtonStyle {
@Environment(\.isEnabled) private var isEnabled: Bool
- func disabled() -> Bool { !isEnabled }
+ var disabled: Bool { !isEnabled }
enum TalerButtonStyleType {
case plain
@@ -105,6 +105,7 @@ struct TalerButtonStyle: ButtonStyle {
var dimmed: Bool = false
var narrow: Bool = false
var aligned: TextAlignment = .center
+ var badge: String = EMPTYSTRING
public func makeBody(configuration: ButtonStyle.Configuration) -> some
View {
// configuration.role = type == .prominent ? .primary : .normal
Only on macOS
@@ -113,36 +114,23 @@ struct TalerButtonStyle: ButtonStyle {
backColor: backColor(type: type, pressed:
configuration.isPressed),
dimmed: dimmed,
configuration: configuration,
- disabled: disabled(),
+ disabled: disabled,
narrow: narrow,
- aligned: aligned)
+ aligned: aligned,
+ badge: badge)
}
func foreColor(type: TalerButtonStyleType, pressed: Bool) -> Color {
-// return if type == .plain {
-// WalletColors().fieldForeground
-// } else {
-// WalletColors().buttonForeColor(pressed: pressed,
-// disabled: disabled(),
-// prominent: type == .prominent)
-// }
return type == .plain ? WalletColors().fieldForeground : //
primary text color
WalletColors().buttonForeColor(pressed: pressed,
- disabled: disabled(),
+ disabled: disabled,
prominent: type == .prominent,
balance: type == .balance)
}
func backColor(type: TalerButtonStyleType, pressed: Bool) -> Color {
-// return if type == .plain {
-// Color.clear
-// } else {
-// WalletColors().buttonBackColor(pressed: pressed,
-// disabled: disabled(),
-// prominent: type == .prominent)
-// }
return type == .plain && !pressed ? Color.clear :
WalletColors().buttonBackColor(pressed: pressed,
- disabled: disabled(),
+ disabled: disabled,
prominent: type == .prominent,
balance: type == .balance)
}
@@ -169,28 +157,40 @@ struct TalerButtonStyle: ButtonStyle {
let disabled: Bool
let narrow: Bool
let aligned: TextAlignment
+ var badge: String
var body: some View {
let aligned2: Alignment = (aligned == .center) ? Alignment.center
: (aligned == .leading) ? Alignment.leading
: Alignment.trailing
- configuration.label
- .multilineTextAlignment(aligned)
- .accessibilityFont(.title3)
-// narrow ? .title3 : .title2
- .frame(minWidth: 0, maxWidth: narrow ? nil : .infinity,
alignment: aligned2)
- .padding(.vertical, 10)
- .padding(.horizontal, 6)
- .foregroundColor(foreColor)
- .background(BackgroundView(color: backColor, dimmed: dimmed))
- .contentShape(Rectangle()) // make sure the button can be
pressed even if backgroundColor == clear
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- .animation(.spring(response: 0.1), value:
configuration.isPressed)
- .disabled(disabled)
+ let hasBadge = badge.count > 0
+ let buttonLabel = configuration.label
+ .multilineTextAlignment(aligned)
+ .accessibilityFont(.title3) //
narrow ? .title3 : .title2
+ .frame(maxWidth: narrow ? nil : .infinity,
alignment: aligned2)
+ .padding(.vertical, 10)
+ .padding(.horizontal, hasBadge ? 0 : 6)
+ .foregroundColor(foreColor)
+ .background(BackgroundView(color: backColor,
dimmed: dimmed))
+ .contentShape(Rectangle()) // make sure
the button can be pressed even if backgroundColor == clear
+ .scaleEffect(configuration.isPressed ? 0.95 :
1)
+ .animation(.spring(response: 0.1), value:
configuration.isPressed)
+ .disabled(disabled)
+ if !hasBadge {
+ buttonLabel
+ } else {
+ let badgeV = Image(systemName: badge)
+ .accessibilityFont(.caption)
+ HStack(alignment: .top, spacing: 0) {
+ badgeV.foregroundColor(.clear)
+ buttonLabel
+ badgeV.foregroundColor(.red)
+ }
+ }
}
}
}
-
+// MARK: -
#if DEBUG
fileprivate struct ContentView_Previews: PreviewProvider {
static var previews: some View {
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index 5d1c7f9..8d4c988 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -219,8 +219,7 @@ struct TransactionDetailView: View {
.listRowSeparator(.hidden)
}
Link("Confirm with bank",
destination: destination)
-
.buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, aligned:
.center))
- .padding(.horizontal)
+
.buttonStyle(TalerButtonStyle(type: .prominent, badge: CONFIRM_BANK))
}
}
}
@@ -235,8 +234,7 @@ struct TransactionDetailView: View {
.listRowSeparator(.hidden)
}
Link("Open KYC website",
destination: destination)
-
.buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, aligned:
.center))
- .padding(.horizontal)
+
.buttonStyle(TalerButtonStyle(type: .prominent, badge: NEEDS_KYC))
}
}
}
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index 79fc46b..b618c66 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -12,8 +12,8 @@ struct IconBadge: View {
let needsKYC: Bool
var body: some View {
- let badgeName = needsKYC ? "star.fill"
- : "circle.fill"
+ let badgeName = needsKYC ? NEEDS_KYC
+ : CONFIRM_BANK
HStack(alignment: .top, spacing: -8) { // TODO: adapt spacing to
dynamic fontsize
Image(systemName: imageName)
.foregroundColor(foreColor)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 04/30: cleanup, debugging, (continued)
- [taler-taler-ios] 04/30: cleanup, debugging, gnunet, 2023/11/19
- [taler-taler-ios] 05/30: ScrollVStack, cleanup, gnunet, 2023/11/19
- [taler-taler-ios] 01/30: Bugfix: Arithmetic error, gnunet, 2023/11/19
- [taler-taler-ios] 06/30: Notifications, gnunet, 2023/11/19
- [taler-taler-ios] 19/30: tabbed button strings, gnunet, 2023/11/19
- [taler-taler-ios] 18/30: cleanup, gnunet, 2023/11/19
- [taler-taler-ios] 07/30: KYC, gnunet, 2023/11/19
- [taler-taler-ios] 03/30: Dismiss keyboard, gnunet, 2023/11/19
- [taler-taler-ios] 23/30: unify P2P subject, gnunet, 2023/11/19
- [taler-taler-ios] 21/30: fix shortcuts, gnunet, 2023/11/19
- [taler-taler-ios] 26/30: badge for button,
gnunet <=
- [taler-taler-ios] 15/30: ScrollVStack, gnunet, 2023/11/19
- [taler-taler-ios] 25/30: cleanup, gnunet, 2023/11/19
- [taler-taler-ios] 24/30: cleanup P2P, gnunet, 2023/11/19
- [taler-taler-ios] 17/30: accessibilityAddTraits, gnunet, 2023/11/19
- [taler-taler-ios] 11/30: cleanup, gnunet, 2023/11/19
- [taler-taler-ios] 29/30: cleanup notifications, gnunet, 2023/11/19
- [taler-taler-ios] 30/30: Bump version to 0.9.3 (27), gnunet, 2023/11/19
- [taler-taler-ios] 27/30: Remove PendingOps, gnunet, 2023/11/19
- [taler-taler-ios] 12/30: leadingCurrencySymbol, gnunet, 2023/11/19
- [taler-taler-ios] 13/30: cleanup, gnunet, 2023/11/19