taler-ios

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

commit 6aef0c3b58db09b716fdfec3a10e18bb4407bd19
parent 348a090cb7505d688f11e1feb7eb36b9a9cf2400
Author: Marc Stibane <marc@taler.net>
Date:   Sat,  9 Nov 2024 11:02:50 +0100

cleanup

Diffstat:
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 26++++++++++----------------
MTalerWallet1/Views/HelperViews/Buttons.swift | 23+++++++++++------------
MTalerWallet1/Views/HelperViews/IconBadge.swift | 13+++++++------
MTalerWallet1/Views/Main/MainView.swift | 2+-
MTalerWallet1/Views/Settings/AboutView.swift | 8++------
5 files changed, 31 insertions(+), 41 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -41,7 +41,6 @@ struct BalancesSectionView { @State private var completedTransactions: [Transaction] = [] @State private var recentTransactions: [Transaction] = [] @State private var pendingTransactions: [Transaction] = [] - @State private var currencyInfo = CurrencyInfo.zero(UNKNOWN) private static func className() -> String {"\(self)"} @@ -96,23 +95,20 @@ extension BalancesSectionView: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let scopeInfo = balance.scopeInfo - let currency = scopeInfo.currency - let balanceDest = TransactionsListView(stack: stack.push("\(Self.className())()"), + Group { + let balanceDest = TransactionsListView(stack: stack.push("\(Self.className())()"), scope: scopeInfo, - balance: balance, - selectedBalance: $selectedBalance, - navTitle: currency, // String(localized: "Transactions", comment: "ViewTitle of TransactionList"), - transactions: $completedTransactions, - reloadAllAction: loadCompleted, - reloadOneAction: reloadOneAction) - - Section { + balance: balance, + selectedBalance: $selectedBalance, + navTitle: nil, // will use scopeInfo.currency + transactions: $completedTransactions, + reloadAllAction: loadCompleted, + reloadOneAction: reloadOneAction) + Section { BalanceCellV(stack: stack.push("BalanceCell"), scope: balance.scopeInfo, amount: balance.available, -// sizeCategory: sizeCategory, -// rowAction: { buttonSelected = 3 }, // trigger TransactionList NavigationLink balanceDest: balanceDest) // .listRowSeparator(.hidden) // .border(.red) @@ -133,9 +129,6 @@ extension BalancesSectionView: View { shouldReloadBalances: $shouldReloadBalances) }.id(sectionID) .listRowSeparator(.hidden) - .task(id: controller.currencyTicker) { - currencyInfo = controller.info2(for: currency, controller.currencyTicker) - } .task(id: shouldReloadBalances + 1_000_000) { symLog.log(".task for BalancesSectionView - load recent+completed+pending") await loadRecent(stack.push(".task - load recent")) @@ -164,6 +157,7 @@ extension BalancesSectionView: View { } } } // recent transactions + } } // body } // BalancesSectionView // MARK: - diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -213,15 +213,14 @@ struct TalerButtonStyle: ButtonStyle { public func makeBody(configuration: ButtonStyle.Configuration) -> some View { // configuration.role = type == .prominent ? .primary : .normal Only on macOS - MyBigButton(//type: type, - foreColor: foreColor(type: type, pressed: configuration.isPressed, disabled: disabled), - backColor: backColor(type: type, pressed: configuration.isPressed, disabled: disabled), - dimmed: dimmed, - configuration: configuration, - disabled: disabled, - narrow: narrow, - aligned: aligned, - badge: badge) + MyBigButton(foreColor: foreColor(type: type, pressed: configuration.isPressed, disabled: disabled), + backColor: backColor(type: type, pressed: configuration.isPressed, disabled: disabled), + dimmed: dimmed, + configuration: configuration, + disabled: disabled, + narrow: narrow, + aligned: aligned, + badge: badge) } func foreColor(type: TalerButtonStyleType, pressed: Bool, disabled: Bool) -> Color { @@ -284,9 +283,7 @@ struct TalerButtonStyle: ButtonStyle { .scaleEffect(configuration.isPressed ? 0.95 : 1) .animation(.spring(response: 0.1), value: configuration.isPressed) .disabled(disabled) - if !hasBadge { - buttonLabel - } else { + if hasBadge { let badgeV = Image(systemName: badge) .talerFont(.caption) HStack(alignment: .top, spacing: 0) { @@ -294,6 +291,8 @@ struct TalerButtonStyle: ButtonStyle { buttonLabel badgeV.foregroundColor(.red) } + } else { + buttonLabel } } } diff --git a/TalerWallet1/Views/HelperViews/IconBadge.swift b/TalerWallet1/Views/HelperViews/IconBadge.swift @@ -15,10 +15,10 @@ struct PendingIconBadge: View { let needsKYC: Bool var body: some View { - let image = incoming && done ? Image(DONE_INCOMING) // "plus.circle.fill" - : incoming ? Image(PENDING_INCOMING) // "plus" - // since the money already left the wallet, show DONE and not PENDING_OUTGOING - : Image(DONE_OUTGOING) // "minus.circle" + let image = incoming && done ? Image(systemName: DONE_INCOMING) // "plus.circle.fill" + : incoming ? Image(systemName: PENDING_INCOMING) // "plus" + // since outgoing money already left the wallet, show DONE_ and not PENDING_OUTGOING + : Image(systemName: DONE_OUTGOING) // "minus.circle" IconBadge(image: image, done: false, foreColor: foreColor, @@ -59,7 +59,7 @@ struct ButtonIconBadge: View { shouldConfirm: false, needsKYC: false, wideIcon: TransactionType.peerPushDebit.icon()) - // button never is payment or refund + // button is send/receive/withdraw/deposit, never payment or refund } } // MARK: - @@ -69,7 +69,8 @@ struct IconBadge: View { let foreColor:Color let shouldConfirm: Bool let needsKYC: Bool - let wideIcon: Image? + let wideIcon: Image? // cheating: ZStack with widest icon to ensure all have the same width + // TODO: EqualIconWidth... @ScaledMetric var spacing = 8 // relative to fontSize diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -97,7 +97,7 @@ struct MainView: View { urlToOpen: url)) Sheet(stack: stack.push(), sheetView: sheet) } - .sheet(isPresented: $model.showError) { + .sheet(isPresented: $model.showError) { // TODO: switch to alert/overlay model.setError(nil) } content: { if let error2 = model.error2 { diff --git a/TalerWallet1/Views/Settings/AboutView.swift b/TalerWallet1/Views/Settings/AboutView.swift @@ -103,16 +103,12 @@ struct AboutView: View { .navigationTitle(navTitle) .task { onboarding = (tapped < TAPPED || dragged < DRAGGED) +// try? await Task.sleep(nanoseconds: 1_000_000_000 * UInt64(5)) +// rotationEnabled.toggle() } .onAppear() { DebugViewC.shared.setViewID(VIEW_ABOUT, stack: stack.push()) } - .onDisappear() { - } -// .task { -// try? await Task.sleep(nanoseconds: 1_000_000_000 * UInt64(5)) -// rotationEnabled.toggle() -// } } } extension Bundle {