summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-10-13 23:05:08 +0200
committerMarc Stibane <marc@taler.net>2023-10-13 23:33:06 +0200
commit86b0ee41a5af71b3e9c3a1f5019982ea7e2ac0e0 (patch)
treebc9edbcf1769f348e0e89f00fa4395d5a9c890fc
parentfb7b78be9bc06ca86e74bb10b042b815c1fb5e9d (diff)
downloadtaler-ios-86b0ee41a5af71b3e9c3a1f5019982ea7e2ac0e0.tar.gz
taler-ios-86b0ee41a5af71b3e9c3a1f5019982ea7e2ac0e0.tar.bz2
taler-ios-86b0ee41a5af71b3e9c3a1f5019982ea7e2ac0e0.zip
cleanup
-rw-r--r--TalerWallet1/Views/Balances/BalanceRowView.swift32
-rw-r--r--TalerWallet1/Views/Balances/BalancesSectionView.swift60
-rw-r--r--TalerWallet1/Views/Exchange/ExchangeSectionView.swift26
3 files changed, 57 insertions, 61 deletions
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift
index bb919c2..c3168d9 100644
--- a/TalerWallet1/Views/Balances/BalanceRowView.swift
+++ b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -14,9 +14,10 @@ struct BalanceButton: View {
var body: some View {
Button(action: rowAction) {
- VStack(alignment: .trailing, spacing: 0) {
- Text("Balance", comment: "Balance in main view")
- .bold() // in iOS-15 defined for Text, but not for Font (only iOS-16)
+ HStack() {
+ Text("Balance:", comment: "Balance in main view")
+ .accessibilityFont(.title)
+ Spacer()
Text(verbatim: "\(amount.valueStr)") // TODO: CurrencyFormatter?
.accessibilityFont(.title)
.monospacedDigit()
@@ -64,26 +65,17 @@ struct BalanceRowView: View {
}
var body: some View {
- Group {
- let requestTitle = requestTitle1 + "\n" + requestTitle2
+ VStack (alignment: .trailing) {
+ BalanceButton(amount: amount, rowAction: rowAction)
let sendTitle = sendTitle1 + "\n" + sendTitle2
+ let requestTitle = requestTitle1 + "\n" + requestTitle2
+ let twoRowButtons = TwoRowButtons(sendTitle: sendTitle, recvTitle: requestTitle,
+ lineLimit: 5, sendDisabled: amount.isZero,
+ sendAction: sendAction, recvAction: recvAction)
if needVStack(amount) {
- VStack (alignment: .trailing) {
- BalanceButton(amount: amount, rowAction: rowAction)
- HStack {
- }
- TwoRowButtons(sendTitle: sendTitle, recvTitle: requestTitle,
- lineLimit: 5, sendDisabled: amount.isZero,
- sendAction: sendAction, recvAction: recvAction)
- }
+ VStack { twoRowButtons }
} else {
- HStack {
- BalanceButton(amount: amount, rowAction: rowAction)
- TwoRowButtons(sendTitle: sendTitle, recvTitle: requestTitle,
- lineLimit: 5, sendDisabled: amount.isZero,
- sendAction: sendAction, recvAction: recvAction)
- }
-// .fixedSize(horizontal: true, vertical: true) // should make all buttons equal height - but doesn't
+ HStack { twoRowButtons }
}
}
.accessibilityElement(children: .combine)
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index dfeffcd..75cc0a1 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -74,22 +74,22 @@ extension BalancesSectionView: View {
.accessibilityFont(.body)
.multilineTextAlignment(.leading)
}
- NavigationLinksView(stack: stack.push(),
- balance: balance,
- centsToTransfer: $centsToTransfer,
- summary: $summary,
-// buttonSelected: $buttonSelected,
- completedTransactions: $completedTransactions,
- reloadAllAction: reloadCompleted,
- reloadOneAction: reloadOneAction)
+ BalancesNavigationLinksView(stack: stack.push(),
+ balance: balance,
+ centsToTransfer: $centsToTransfer,
+ summary: $summary,
+// buttonSelected: $buttonSelected,
+ completedTransactions: $completedTransactions,
+ reloadAllAction: reloadCompleted,
+ reloadOneAction: reloadOneAction)
let hasPending = pendingTransactions.count > 0
if hasPending {
- SectionPendingRowView(symLog: symLog,
- stack: stack.push(),
- currency: currency,
- pendingTransactions: $pendingTransactions,
- reloadPending: reloadPending,
- reloadOneAction: reloadOneAction)
+ BalancesPendingRowView(symLog: symLog,
+ stack: stack.push(),
+ currency: currency,
+ pendingTransactions: $pendingTransactions,
+ reloadPending: reloadPending,
+ reloadOneAction: reloadOneAction)
}
let hasUncompleted = uncompletedTransactions.count > 0
if hasUncompleted {
@@ -110,7 +110,7 @@ extension BalancesSectionView: View {
}
} header: {
- HStack (alignment: .bottom, spacing: 10) {
+ HStack (alignment: .center, spacing: 10) {
BarGraph(transactions: $completedTransactions, barHeight: 10)
Text(currency)
.accessibilityFont(.title2)
@@ -118,8 +118,8 @@ extension BalancesSectionView: View {
}.id(sectionID)
.task {
// if shownSectionID != sectionID {
- symLog.log("task for \(sectionID) - reload Transactions")
- let response = await model.transactionsT(stack.push("task for \(sectionID) - reload Transactions"), currency: currency)
+ symLog.log(".task for BalancesSectionView - reload Transactions")
+ let response = await model.transactionsT(stack.push(".task - reload Transactions"), currency: currency)
transactions = response
pendingTransactions = WalletModel.pendingTransactions(response)
uncompletedTransactions = WalletModel.uncompletedTransactions(response)
@@ -155,9 +155,9 @@ extension BalancesSectionView: View {
}
}
} // body
-}
+} // extension BalancesSectionView
-fileprivate struct SectionPendingRowView: View {
+fileprivate struct BalancesPendingRowView: View {
let symLog: SymLogV?
let stack: CallStack
let currency: String
@@ -218,10 +218,10 @@ fileprivate struct SectionPendingRowView: View {
}
}
- }
-}
+ } // body
+} // BalancesPendingRowView
-fileprivate struct NavigationLinksView: View {
+fileprivate struct BalancesNavigationLinksView: View {
let stack: CallStack
let balance: Balance
// let sectionCount: Int
@@ -233,6 +233,18 @@ fileprivate struct NavigationLinksView: View {
@State private var buttonSelected: Int? = nil
+ func selectAndUpdate(_ button: Int) {
+ buttonSelected = button // will trigger NavigationLink
+ // while navigation animation runs, contact Exchange to update Fees
+// Task { // runs on MainActor
+// do {
+// try await model.updateExchange(scopeInfo: balance.scopeInfo)
+// } catch { // TODO: error handling - couldn't updateExchange
+// symLog.log("error: \(error)")
+// }
+// }
+ }
+
var body: some View {
let currency = balance.available.currencyStr
HStack(spacing: 0) {
@@ -264,9 +276,9 @@ fileprivate struct NavigationLinksView: View {
) { EmptyView() }.frame(width: 0).opacity(0).hidden() // TransactionsListView
BalanceRowView(amount: balance.available, sendAction: {
- buttonSelected = 1 // will trigger SendAmount NavigationLink
+ selectAndUpdate(1) // will trigger SendAmount NavigationLink
}, recvAction: {
- buttonSelected = 2 // will trigger RequestPayment NavigationLink
+ selectAndUpdate(2) // will trigger RequestPayment NavigationLink
}, rowAction: {
buttonSelected = 3 // will trigger TransactionList NavigationLink
})
diff --git a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
index 3e3d73d..cbb8528 100644
--- a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
@@ -54,28 +54,20 @@ struct ExchangeRowView: View {
) { EmptyView() }.frame(width: 0).opacity(0)
}.listRowSeparator(.hidden)
- let sendTitle = depositTitle + "\n" + currency // TODO: amount.currencyStr
- let recvTitle = withdrawTitle + "\n" + currency // TODO: amount.currencyStr
+ let sendTitle = depositTitle + "\n" + currency // TODO: amount.currencyStr
+ let recvTitle = withdrawTitle + "\n" + currency // TODO: amount.currencyStr
+ let twoRowButtons = TwoRowButtons(sendTitle: sendTitle, recvTitle: recvTitle,
+ lineLimit: 5, sendDisabled: true, // TODO: amount.isZero
+ sendAction: { selectAndUpdate(1) },
+ recvAction: { selectAndUpdate(2) })
if needVStack(currency) {
- VStack {
- TwoRowButtons(sendTitle: sendTitle,
- recvTitle: recvTitle,
- lineLimit: 5, sendDisabled: true, // TODO: amount.isZero
- sendAction: { selectAndUpdate(1) },
- recvAction: { selectAndUpdate(2) })
- }
+ VStack { twoRowButtons }
} else {
- HStack { // buttons just set "buttonSelected" so the NavigationLink will trigger
- TwoRowButtons(sendTitle: sendTitle,
- recvTitle: recvTitle,
- lineLimit: 5, sendDisabled: true, // TODO: amount.isZero
- sendAction: { selectAndUpdate(1) },
- recvAction: { selectAndUpdate(2) })
-
- }
+ HStack { twoRowButtons }
}
}
}
+// MARK: -
/// This view shows the currency name in an exchange section
/// currency
/// [Deposit Coins] [Withdraw Coins]