taler-ios

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

commit 6264bb40424dee62ff3a11a308f2e1429b17b81f
parent 6e73588e3154da90e008658414e09f591f0bf5ff
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 26 Mar 2026 13:20:46 +0100

cleanup

Diffstat:
MTalerWallet1/Controllers/PublicConstants.swift | 4++--
MTalerWallet1/Views/Actions/ActionsSheet.swift | 16++++++++--------
MTalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift | 17+++++++++--------
MTalerWallet1/Views/Balances/BalancesListView.swift | 6+++---
MTalerWallet1/Views/HelperViews/ScopePicker.swift | 7++++---
MTalerWallet1/Views/Main/MainView.swift | 4++--
MTalerWallet1/Views/Transactions/ManualDetailsV.swift | 7++++---
MTalerWallet1/Views/Transactions/TransactionsListView.swift | 1-
8 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/TalerWallet1/Controllers/PublicConstants.swift b/TalerWallet1/Controllers/PublicConstants.swift @@ -31,8 +31,8 @@ public let DRAGDELAY = 0.5 public let DRAGDURATION = 0.45 public let DRAGSPEED = 0.1 public let MAXRECENT = 4 // # of rows in Recent Transactions -public let SCANDETENT = 0.666 // 2/3 height - in the rest is a (invisible) dismiss button, also for VoiceOver -public let ACTIONDETENT = 0.999 +public let HALFDETENT = 0.666 // 2/3 height - in the rest is a (invisible) dismiss button, also for VoiceOver +public let FULLDETENT = 0.999 // leave 0.001 space for dismiss public let ICONLEADING = CGFloat(-8) public let HSPACING = CGFloat(10) // space between items in HStack diff --git a/TalerWallet1/Views/Actions/ActionsSheet.swift b/TalerWallet1/Views/Actions/ActionsSheet.swift @@ -203,14 +203,14 @@ struct DualHeightSheet: View { @State private var innerHeight: CGFloat = .zero @State private var sheetHeight: CGFloat = .zero - let scanDetent: PresentationDetent = .fraction(SCANDETENT) - let actionDetent: PresentationDetent = .fraction(ACTIONDETENT) + let halfDetent: PresentationDetent = .fraction(HALFDETENT) + let fullDetent: PresentationDetent = .fraction(FULLDETENT) func updateDetentsWithDelay() { Task { //(1 second = 1_000_000_000 nanoseconds) try? await Task.sleep(nanoseconds: 80_000_000) - let detent = minimalistic ? scanDetent : actionDetent + let detent = minimalistic ? halfDetent : fullDetent guard selectedDetent == detent else { return } detents = [detent] logger.trace("❗️detents = [scanDetent]") // 0.999 % @@ -237,7 +237,7 @@ struct DualHeightSheet: View { qrButtonTapped = true // tell our caller withAnimation(Animation.easeIn(duration: 0.6)) { // animate this sheet to full height - let detent = minimalistic ? scanDetent : actionDetent + let detent = minimalistic ? halfDetent : fullDetent selectedDetent = detent } } @@ -258,9 +258,9 @@ struct DualHeightSheet: View { } .presentationDetents(detents, selection: $selectedDetent) .onChange(of: selectedDetent) { newValue in - let detent = minimalistic ? scanDetent : actionDetent + let detent = minimalistic ? halfDetent : fullDetent if newValue == detent { // user swiped the sheet up to activate QR scanner - logger.trace("onChange❗️selectedDetent = \(SCANDETENT)") + logger.trace("onChange❗️selectedDetent == (detent) ==> updateDetentsWithDelay()") updateDetentsWithDelay() qrButtonTapped = true // tell our caller } else { // SwiftUI "innerHeight" determined how big the half sheet should be @@ -285,8 +285,8 @@ struct DualHeightSheet: View { let qrSheet = AnyView(QRSheet(stack: stack.push(".sheet"), selectedBalance: selectedBalance, scannedSomething: $scannedCode)) - let detent: PresentationDetent = .fraction(scannedCode ? ACTIONDETENT - : minimalistic ? SCANDETENT : ACTIONDETENT) + let detent: PresentationDetent = .fraction(scannedCode ? FULLDETENT + : minimalistic ? HALFDETENT : FULLDETENT) Sheet(stack: stack.push(), sheetView: qrSheet) .presentationDetents([detent]) .transition(.opacity) diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift @@ -132,21 +132,22 @@ struct P2PSubjectV: View { .foregroundColor(WalletColors().fieldForeground) // text color .background(WalletColors().fieldBackground) .textFieldStyle(.roundedBorder) - Text(verbatim: "\(summary.count)/100") // maximum 100 characters + let numChars = summary.count + Text(verbatim: "\(numChars)/100") // maximum 100 characters .frame(maxWidth: .infinity, alignment: .trailing) .talerFont(.body) .accessibilityLabel(EMPTYSTRING) - .accessibilityValue(String(localized: "\(summary.count) characters of 100")) + .accessibilityValue(String(localized: "\(numChars) characters of 100")) - // TODO: compute max Expiration day from peerPushCheck to disable 30 (and even 7) - SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS, outgoing: outgoing) - .disabled(false) - .padding(.bottom) + // TODO: compute max Expiration day from peerPushCheck to disable 30 (and even 7) + SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS, outgoing: outgoing) + .disabled(false) + .padding(.bottom) - let disabled = (expireDays == 0) // || (summary.count < 1) // TODO: check amountAvailable + let disabled = (expireDays == 0) // || (numChars < 1) // TODO: check amountAvailable let destination = P2PReadyV(stack: stack.push(), scope: scope, - summary: summary.count > 0 ? summary : placeHolder, + summary: numChars > 0 ? summary : placeHolder, iconID: iconID, expireDays: expireDays, outgoing: outgoing, diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -44,7 +44,6 @@ struct BalancesListView: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif // Group { - let count = controller.balances.count if controller.balances.isEmpty { let talerLogo = HStack(spacing: 2) { Image(TALER_LOGO_FULL) @@ -74,6 +73,7 @@ struct BalancesListView: View { /// In standard mode, selectedBalance just sets a "preference" which balance to pre-select for Actions. /// 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) + let count = controller.balances.count Group { List(Array(controller.balances.enumerated()), id: \.element) { index, balance in BalancesSectionView(stack: stack.push("\(balance.scopeInfo.currency)"), @@ -90,7 +90,7 @@ struct BalancesListView: View { DebugViewC.shared.setViewID(VIEW_BALANCES, stack: stack.push("onAppear")) if !controller.oimModeActive { print("🚩BalancesListView.onAppear() reset selectedBalance") -// if controller.balances.count > 1 { +// if count > 1 { selectedBalance = nil // reset // } } @@ -103,7 +103,7 @@ struct BalancesListView: View { .onChange(of: controller.oimModeActive) { oimModeActive in if !oimModeActive { print("🚩BalancesListView.onChange(of: oimModeActive) reset selectedBalance") -// if controller.balances.count > 1 { +// if count > 1 { selectedBalance = nil // reset // } } diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift b/TalerWallet1/Views/HelperViews/ScopePicker.swift @@ -238,16 +238,17 @@ struct ScopeDropDown: View { // .border(.red) if (showDropdown) { if #available(iOS 17.0, *) { -// let toomany = controller.balances.count > maxItemDisplayed + let count = controller.balances.count +// let toomany = count > maxItemDisplayed // let scrollViewHeight = buttonHeight * CGFloat(toomany ? maxItemDisplayed -// : controller.balances.count) +// : count) ScrollView { theList .scrollTargetLayout() } // .border(.red) .scrollPosition(id: $scrollPosition) - .scrollDisabled(controller.balances.count <= 3) + .scrollDisabled(count <= 3) // .frame(height: scrollViewHeight) .onAppear { scrollPosition = selection diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -195,8 +195,8 @@ struct MainView: View { scannedSomething: $scannedCode)) // let _ = logger.trace("❗️showScanner: \(SCANDETENT)❗️") if #available(iOS 16.4, *) { - let detent: PresentationDetent = .fraction(scannedCode ? ACTIONDETENT - : minimalistic ? SCANDETENT : ACTIONDETENT) + let detent: PresentationDetent = .fraction(scannedCode ? FULLDETENT + : minimalistic ? HALFDETENT : FULLDETENT) Sheet(stack: stack.push(), sheetView: qrSheet) .presentationDetents([detent]) .transition(.opacity) diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift @@ -49,7 +49,8 @@ struct ManualDetailsV: View { var body: some View { if let accountDetails = details.exchangeCreditAccountDetails { let validDetails = validDetails(accountDetails) - if validDetails.count > 0 { + let validCount = validDetails.count + if validCount > 0 { let account = validDetails[accountID] if let amount = account.transferAmount { let specs = account.currencySpecification @@ -63,8 +64,8 @@ struct ManualDetailsV: View { .multilineTextAlignment(.leading) .listRowSeparator(.hidden) } - if validDetails.count > 1 { - if validDetails.count > 3 { // too many for SegmentControl + if validCount > 1 { + if validCount > 3 { // too many for SegmentControl AccountPicker(title: String(localized: "Bank"), value: $accountID, accountDetails: validDetails, diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift @@ -73,7 +73,6 @@ struct TransactionsListView: View { } else { // Group { ScrollViewReader { scrollProxy in - let count = transactions.count List { Section { TransactionsArraySliceV(symLog: symLog,