taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit a622afd518f9adf02a9f856bb70bf406c3512184
parent cb6b58838245ed1b21096f5139c54c3ad61939ec
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 14 Oct 2023 09:13:54 +0200

Balance button

Diffstat:
MTalerWallet1/Helper/WalletColors.swift | 12++++++++----
MTalerWallet1/Views/Balances/BalanceRowView.swift | 8+++++---
MTalerWallet1/Views/HelperViews/Buttons.swift | 21+++++++++++++--------
MTalerWallet1/Views/Settings/SettingsView.swift | 2+-
4 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/TalerWallet1/Helper/WalletColors.swift b/TalerWallet1/Helper/WalletColors.swift @@ -14,14 +14,18 @@ public struct WalletColors { let gray5 = Color(.systemGray5) let gray6 = Color(.systemGray6) - func buttonForeColor(pressed: Bool, disabled: Bool, prominent: Bool = false) -> Color { - disabled ? gray2 + func buttonForeColor(pressed: Bool, disabled: Bool, + prominent: Bool = false, balance: Bool = false) -> Color { + balance ? Color.primary + : disabled ? gray2 : !prominent ? tint : pressed ? gray6 : gray5 } - func buttonBackColor(pressed: Bool, disabled: Bool, prominent: Bool = false) -> Color { - disabled ? gray5 + func buttonBackColor(pressed: Bool, disabled: Bool, + prominent: Bool = false, balance: Bool = false) -> Color { + balance ? (pressed ? gray5 : gray6) + : disabled ? gray5 : prominent ? tint : pressed ? gray5 : gray4 } diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -11,12 +11,14 @@ import taler_swift struct BalanceButton: View { let amount: Amount let rowAction: () -> Void + @AppStorage("iconOnly") var iconOnly: Bool = false var body: some View { Button(action: rowAction) { - HStack() { + HStack(alignment: .lastTextBaseline) { Text("Balance:", comment: "Balance in main view") - .accessibilityFont(.title) + .accessibilityFont(.title2) + .foregroundColor(iconOnly ? .clear : .secondary) // hide if iconOnly Spacer() Text(verbatim: "\(amount.valueStr)") // TODO: CurrencyFormatter? .accessibilityFont(.title) @@ -26,7 +28,7 @@ struct BalanceButton: View { } .disabled(false) .accessibilityElement(children: /*@START_MENU_TOKEN@*/.ignore/*@END_MENU_TOKEN@*/) .accessibilityLabel("Balance \(amount.readableDescription)") // TODO: CurrencyFormatter! - .buttonStyle(TalerButtonStyle(type: .plain, aligned: .trailing)) + .buttonStyle(TalerButtonStyle(type: iconOnly ? .plain : .balance, aligned: .trailing)) // .background(Color.yellow) } } diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -23,6 +23,7 @@ struct HamburgerButton : View { var body: some View { Button(action: action) { Image(systemName: "line.3.horizontal") +// Image(systemName: "sidebar.squares.leading") } .accessibilityFont(.title) .accessibilityLabel("Main Menu") @@ -97,6 +98,7 @@ struct TalerButtonStyle: ButtonStyle { enum TalerButtonStyleType { case plain + case balance case bordered case prominent } @@ -106,7 +108,7 @@ struct TalerButtonStyle: ButtonStyle { var aligned: TextAlignment = .center public func makeBody(configuration: ButtonStyle.Configuration) -> some View { - MyBigButton(type: type, + MyBigButton(//type: type, foreColor: foreColor(type: type, pressed: configuration.isPressed), backColor: backColor(type: type, pressed: configuration.isPressed), dimmed: dimmed, @@ -124,10 +126,11 @@ struct TalerButtonStyle: ButtonStyle { // disabled: disabled(), // prominent: type == .prominent) // } - return type == .plain ? WalletColors().fieldForeground : + return type == .plain ? WalletColors().fieldForeground : // primary text color WalletColors().buttonForeColor(pressed: pressed, - disabled: disabled(), - prominent: type == .prominent) + disabled: disabled(), + prominent: type == .prominent, + balance: type == .balance) } func backColor(type: TalerButtonStyleType, pressed: Bool) -> Color { // return if type == .plain { @@ -137,11 +140,13 @@ struct TalerButtonStyle: ButtonStyle { // disabled: disabled(), // prominent: type == .prominent) // } - return type == .plain ? Color.clear : + return type == .plain && !pressed ? Color.clear : WalletColors().buttonBackColor(pressed: pressed, - disabled: disabled(), - prominent: type == .prominent) + disabled: disabled(), + prominent: type == .prominent, + balance: type == .balance) } + struct BackgroundView: View { let color: Color let dimmed: Bool @@ -156,7 +161,7 @@ struct TalerButtonStyle: ButtonStyle { } struct MyBigButton: View { - var type: TalerButtonStyleType +// var type: TalerButtonStyleType let foreColor: Color let backColor: Color let dimmed: Bool diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -101,7 +101,7 @@ struct SettingsView: View { description: String(localized: "When a transaction finished")) SettingsFont(title: String(localized: "Font:"), value: talerFont, action: redraw) SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle) - SettingsToggle(name: String(localized: "Icon Only"), value: $iconOnly, + SettingsToggle(name: String(localized: "Minimalistic"), value: $iconOnly, description: String(localized: "Omit text where possible")) if diagnosticModeEnabled { SettingsToggle(name: String(localized: "Developer Mode"), value: $developerMode,