taler-ios

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

commit 5c96a507ef02010c51e0c0089c26da3b65111b56
parent 2f26f868c8e7a28dcba49ac5d0f3d30a9f0e1802
Author: Marc Stibane <marc@taler.net>
Date:   Wed, 23 Jul 2025 05:44:09 +0200

fix NavLink($historyTapped)

Diffstat:
MTalerWallet1/Views/Balances/BalanceCellV.swift | 16+++++++++++-----
MTalerWallet1/Views/Balances/BalancesListView.swift | 6+++---
MTalerWallet1/Views/Balances/BalancesPendingRowV.swift | 2--
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 6+++---
MTalerWallet1/Views/OIM/OIMbalances.swift | 12+++++++-----
5 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalanceCellV.swift b/TalerWallet1/Views/Balances/BalanceCellV.swift @@ -15,7 +15,8 @@ struct BalanceCellV: View { let amount: Amount // let sizeCategory: ContentSizeCategory // let rowAction: () -> Void - @Binding var historyTapped: Bool + @Binding var historyTapped: Int? + let balanceIndex: Int let balanceDest: TransactionsListView @Environment(\.colorScheme) private var colorScheme @@ -30,7 +31,7 @@ struct BalanceCellV: View { } } - private func buttonAction() { historyTapped = true } + private func buttonAction() { historyTapped = balanceIndex } /// Renders the Balance button. "Balance" leading, amountStr trailing. If it doesn't fit in one row then /// amount (trailing) goes underneath "Balance" (leading). @@ -53,8 +54,13 @@ struct BalanceCellV: View { strikethrough: false, large: true) .foregroundColor(.primary) - let hLayout = amountV - .frame(maxWidth: .infinity, alignment: .trailing) + let hLayout = HStack { + amountV + .frame(maxWidth: .infinity, alignment: .trailing) + Text(Image(systemName: "chevron.right")) + .talerFont(.table) + .foregroundColor(.secondary) + } let balanceCell = Group { if minimalistic { hLayout @@ -79,7 +85,7 @@ struct BalanceCellV: View { } } let actions = Group { - NavLink($historyTapped) { balanceDest } + NavLink(balanceIndex, $historyTapped) { balanceDest } } Button(action: buttonAction) { diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -26,7 +26,7 @@ struct BalancesListView: View { @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used @State private var summary = EMPTYSTRING - @State private var historyTapped = false + @State private var historyTapped: Int? = nil @Namespace var namespace private static func className() -> String {"\(self)"} @@ -54,11 +54,11 @@ struct BalancesListView: View { /// However, the user can select another balance (with the picker) in each action /// In OIM mode, the user selects a balance 'here' (in OIMView) when tapping on a savings box (representing the balance) Group { - List(controller.balances, id: \.self) { balance in + List(Array(controller.balances.enumerated()), id: \.element) { index, balance in BalancesSectionView(stack: stack.push("\(balance.scopeInfo.currency)"), balance: balance, // this is the currency to be used selectedBalance: $selectedBalance, // set in TransactionsListView - selectedChestIndex: selectedChestIndex, + balanceIndex: index, sectionCount: count, amountToTransfer: $amountToTransfer, // does still have the wrong currency summary: $summary, diff --git a/TalerWallet1/Views/Balances/BalancesPendingRowV.swift b/TalerWallet1/Views/Balances/BalancesPendingRowV.swift @@ -14,7 +14,6 @@ struct BalancesPendingRowV: View { let stack: CallStack let balance: Balance @Binding var selectedBalance: Balance? // <- return here the balance when we go to Transactions - let selectedChestIndex: Int? @Binding var pendingTransactions: [TalerTransaction] let reloadPending: (_ stack: CallStack) async -> () @@ -94,7 +93,6 @@ fileprivate struct BalancesPendingRowV_Previews: PreviewProvider { stack: CallStack("Preview"), balance: balance, selectedBalance: $selectedPreviewBalance, - selectedChestIndex: nil, // preview pendingTransactions: $previewTransactions, reloadPending: {stack in }) } diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -20,11 +20,11 @@ struct BalancesSectionView { let stack: CallStack let balance: Balance // this is the currency to be used @Binding var selectedBalance: Balance? // <- return here the balance when we go to Transactions - let selectedChestIndex: Int? + let balanceIndex: Int let sectionCount: Int @Binding var amountToTransfer: Amount // does still have the wrong currency @Binding var summary: String - @Binding var historyTapped: Bool + @Binding var historyTapped: Int? @Binding var reloadTransactions: Int @EnvironmentObject private var model: WalletModel @@ -112,6 +112,7 @@ extension BalancesSectionView: View { scope: balance.scopeInfo, amount: balance.available, historyTapped: $historyTapped, + balanceIndex: balanceIndex, balanceDest: balanceDest) // .listRowSeparator(.hidden) // .border(.red) @@ -121,7 +122,6 @@ extension BalancesSectionView: View { stack: stack.push(), balance: balance, selectedBalance: $selectedBalance, - selectedChestIndex: selectedChestIndex, pendingTransactions: $pendingTransactions, reloadPending: loadPending) .padding(.leading, ICONLEADING) diff --git a/TalerWallet1/Views/OIM/OIMbalances.swift b/TalerWallet1/Views/OIM/OIMbalances.swift @@ -32,7 +32,7 @@ struct OIMbalances: View { @Binding var selectedBalance: Balance? // return user's choice @Binding var selectedChestIndex: Int? // OIM TODO: use balance @Binding var qrButtonTapped: Bool - @Binding var historyTapped: Bool + @Binding var historyTapped: Int? @EnvironmentObject private var controller: Controller @EnvironmentObject private var wrapper: NamespaceWrapper @@ -48,6 +48,7 @@ struct OIMbalances: View { @State private var closing = false // after user tapped on the open chest func noAction() { } + @State private var balanceIndex: Int? = nil func requestTapped() { @@ -96,7 +97,7 @@ struct OIMbalances: View { } } - func openChest(_ index: Int, _ balance: Balance) { + func openChest(_ oimCurrency: OIMcurrency, _ index: Int, _ balance: Balance) { cash.clearFunds() print("❗️openChest❗️") let duration: TimeInterval @@ -113,7 +114,8 @@ struct OIMbalances: View { withAnimation(.basic1) { chestOpen = index selectedBalance = balance - selectedChestIndex = index + balanceIndex = index +// selectedChestIndex viewState = .chestIsOpen cash.setIndex(index) available = balance.available @@ -148,7 +150,7 @@ struct OIMbalances: View { var transaction = Transaction() transaction.disablesAnimations = true withTransaction(transaction) { - historyTapped = true // ==> go to transaction list + historyTapped = balanceIndex // ==> go to transaction list } DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { cash.moveBack() @@ -248,7 +250,7 @@ struct OIMbalances: View { if itsMe { closeChest() } else { - openChest(index, balance) + openChest(oimCurrency, index, balance) } } .frame(width: size, height: size)