commit c7a01b5d257f4f67a5472a22fa86815192e55d93
parent fe01d878e7601400eb30256c7ffc62e407d73259
Author: Marc Stibane <marc@taler.net>
Date: Sat, 13 Jul 2024 18:36:21 +0200
TwoRowButtons with icons
Diffstat:
3 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -1,7 +1,10 @@
/*
- * 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
@@ -71,16 +74,17 @@ struct BalanceRowView: View {
@AppStorage("minimalistic") var minimalistic: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
- let sendTitle0 = String(localized: "SendButton_Short", defaultValue: "Send",
- comment: "Abbreviation of button `Send Money´")
- let sendTitle1 = String(localized: "SendButton_Full", defaultValue: "Send\tMoney",
- comment: "`Send Money´ in Balances - set exactly 1 \\t for line break")
-
- let requestTitle0 = String(localized: "RequestButton_Short", defaultValue: "Request",
- comment: "Abbreviation of button `Request Payment´")
- let requestTitle1 = String(localized: "RequestButton_Full", defaultValue: "Request\tPayment",
- comment: "`Request Payment´ in Balances - set exactly 1 \\t for line break")
var body: some View {
+ let currency = amount.currencyStr
+ let sendTitle0 = String(localized: "SendButton_Short", defaultValue: "Send",
+ comment: "Abbreviation of button `Send (currency)´")
+ let sendTitle1 = String(localized: "SendButton_Full", defaultValue: "Send\t\(currency)",
+ comment: "`Send (currency)´ in Balances - must have ONE \\t and ONE %@")
+
+ let requestTitle0 = String(localized: "RequestButton_Short", defaultValue: "Request",
+ comment: "Abbreviation of button `Request (currency)´")
+ let requestTitle1 = String(localized: "RequestButton_Full", defaultValue: "Request\t\(currency)",
+ comment: "`Request (currency)´ in Balances - must have ONE \\t and ONE %@")
VStack (alignment: .trailing, spacing: 6) {
BalanceCell(amount: amount,
sizeCategory: sizeCategory,
@@ -92,8 +96,10 @@ struct BalanceRowView: View {
let requTitle = minimalistic ? requestTitle0 : requestTitle1
let twoRowButtons = TwoRowButtons(stack: stack.push(),
sendTitle: sendTitle,
+ sendType: .peerPushDebit,
sendA11y: sendTitle.tabbed(oneLine: true),
recvTitle: requTitle,
+ recvType: .peerPullCredit,
recvA11y: requTitle.tabbed(oneLine: true),
fitsSideBySide: false,
lineLimit: 5,
diff --git a/TalerWallet1/Views/Balances/TwoRowButtons.swift b/TalerWallet1/Views/Balances/TwoRowButtons.swift
@@ -1,15 +1,20 @@
/*
- * 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 TwoRowButtons: View {
let stack: CallStack
let sendTitle: String
+ var sendType: TransactionType
let sendA11y: String
let recvTitle: String
+ var recvType: TransactionType
let recvA11y: String
let fitsSideBySide: Bool
let lineLimit: Int
@@ -21,8 +26,10 @@ struct TwoRowButtons: View {
func makeCopy(fitsSideBySide: Bool) -> TwoRowButtons {
TwoRowButtons(stack: stack.push(),
sendTitle: sendTitle,
+ sendType: sendType,
sendA11y: sendA11y,
recvTitle: recvTitle,
+ recvType: recvType,
recvA11y: recvA11y,
fitsSideBySide: fitsSideBySide,
lineLimit: lineLimit,
@@ -34,7 +41,14 @@ struct TwoRowButtons: View {
var body: some View {
Group {
let sendButtonTitle = sendTitle.tabbed(oneLine: !fitsSideBySide)
- Button(sendButtonTitle, action: sendAction)
+ Button(action: sendAction) {
+ HStack {
+ ButtonIconBadge(type: sendType, foreColor: .accentColor, done: false)
+ Spacer()
+ Text(sendButtonTitle)
+ Spacer()
+ }
+ }
.accessibilityLabel(Text(sendA11y))
.lineLimit(lineLimit)
.disabled(sendDisabled)
@@ -43,7 +57,14 @@ struct TwoRowButtons: View {
disabled: sendDisabled,
aligned: .center))
let recvButtonTitle = recvTitle.tabbed(oneLine: !fitsSideBySide)
- Button(recvButtonTitle, action: recvAction)
+ Button(action: recvAction) {
+ HStack {
+ ButtonIconBadge(type: recvType, foreColor: .accentColor, done: false)
+ Spacer()
+ Text(recvButtonTitle)
+ Spacer()
+ }
+ }
.accessibilityLabel(Text(recvA11y))
.lineLimit(lineLimit)
.disabled(false)
@@ -60,8 +81,10 @@ struct TwoRowButtons_Previews: PreviewProvider {
List {
TwoRowButtons(stack: CallStack("Preview"),
sendTitle: "Send " + TESTCURRENCY,
+ sendType: .peerPushDebit,
sendA11y: "Send " + TESTCURRENCY,
recvTitle: "Request " + LONGCURRENCY,
+ recvType: .peerPullCredit,
recvA11y: "Request " + LONGCURRENCY,
fitsSideBySide: false,
lineLimit: 2, sendDisabled: true,
@@ -69,8 +92,10 @@ struct TwoRowButtons_Previews: PreviewProvider {
.listRowSeparator(.hidden)
TwoRowButtons(stack: CallStack("Preview"),
sendTitle: "Send " + DEMOCURRENCY,
+ sendType: .peerPushDebit,
sendA11y: "Send " + DEMOCURRENCY,
recvTitle: "Request " + DEMOCURRENCY,
+ recvType: .peerPullCredit,
recvA11y: "Request " + DEMOCURRENCY,
fitsSideBySide: true,
lineLimit: 2, sendDisabled: true,
diff --git a/TalerWallet1/Views/Banking/DepositWithdrawV.swift b/TalerWallet1/Views/Banking/DepositWithdrawV.swift
@@ -40,12 +40,12 @@ struct DepositWithdrawV: View {
var body: some View {
let depositTitle0 = String(localized: "DepositButton_Short", defaultValue: "Deposit",
- comment: "Abbreviation of `Deposit (currency)´")
+ comment: "Abbreviation of button `Deposit (currency)´")
let depositTitle1 = String(localized: "Deposit\t\(currency)",
comment: "Button `Deposit (currency)´, must have ONE \\t and ONE %@")
let withdrawTitle0 = String(localized: "WithdrawButton_Short", defaultValue: "Withdraw",
- comment: "Abbreviation of `Withdraw (currency)´")
+ comment: "Abbreviation of button `Withdraw (currency)´")
let withdrawTitle1 = String(localized: "Withdraw\t\(currency)",
comment: "Button `Withdraw (currency)´, must have ONE \\t and ONE %@")
let deposit = LazyView {
@@ -67,8 +67,10 @@ struct DepositWithdrawV: View {
let disableDeposit = amountAvailable?.isZero ?? false
let twoRowButtons = TwoRowButtons(stack: stack.push(),
sendTitle: minimalistic ? depositTitle0 : depositTitle1,
+ sendType: .deposit,
sendA11y: depositTitle1.tabbed(oneLine: true),
recvTitle: minimalistic ? withdrawTitle0 : withdrawTitle1,
+ recvType: .withdrawal,
recvA11y: withdrawTitle1.tabbed(oneLine: true),
fitsSideBySide: false,
lineLimit: 5,