taler-ios

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

commit a907d9ee57deabda85bd3ef1fead99bc0e73b161
parent eb28e131c2bbdc67a221f172b7c578a56a6dbd97
Author: Marc Stibane <marc@taler.net>
Date:   Tue,  8 Oct 2024 06:36:11 +0200

cleanup

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 2+-
MTalerWallet1/Views/Actions/ActionsSheet.swift | 3+--
MTalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift | 2--
MTalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift | 12++----------
MTalerWallet1/Views/Actions/SendRequestV.swift | 1-
MTalerWallet1/Views/Balances/BalancesListView.swift | 5+----
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 1-
MTalerWallet1/Views/HelperViews/BarGraph.swift | 3+--
MTalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift | 5+++--
MTalerWallet1/Views/Main/MainView.swift | 9+++------
MTalerWallet1/Views/Sheets/Sheet.swift | 10++++++----
MTalerWallet1/Views/Transactions/TransactionSummaryV.swift | 6+++---
12 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -892,8 +892,8 @@ children = ( 4E2B337C2C8B1D5500186A3E /* ActionsSheet.swift */, 4EB095362989CBFE0043A8A1 /* SendRequestV.swift */, - 4ECB627E2A0BA4DA004ABBB7 /* Peer2peer */, 4EA076B22BC0607400685A10 /* DepositWithdrawV.swift */, + 4ECB627E2A0BA4DA004ABBB7 /* Peer2peer */, ); path = Actions; sourceTree = "<group>"; diff --git a/TalerWallet1/Views/Actions/ActionsSheet.swift b/TalerWallet1/Views/Actions/ActionsSheet.swift @@ -81,8 +81,7 @@ struct ActionsSheet: View { SendRequestV(stack: stack.push(), balances: $balances, amountToTransfer: $amountToTransfer, // does still have the wrong currency - summary: $summary, - cameraAction: cameraAction) + summary: $summary) DepositWithdrawV(stack: stack.push(), balances: $balances, diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift @@ -16,7 +16,6 @@ struct RequestPayment: View { @Binding var amountToTransfer: Amount @Binding var summary: String let scopeInfo: ScopeInfo - let cameraAction: () -> Void @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel @@ -169,7 +168,6 @@ struct RequestPayment: View { .onDisappear { symLog.log("❗️ \(navTitle) onDisappear") } - .navigationBarItems(trailing: QRButton(action: cameraAction)) // .task(id: amountToTransfer.value) { // if exchange == nil { // if let url = scopeInfo.url { diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift @@ -17,7 +17,6 @@ struct SendAmountV: View { @Binding var selectedBalance: Balance? // selected balance when the action button is tapped in Transactions @Binding var amountToTransfer: Amount @Binding var summary: String - let cameraAction: () -> Void @State private var balanceIndex = 0 @State private var nonZeroBalances: [Balance] = [] @@ -50,8 +49,7 @@ struct SendAmountV: View { balance: $balance, balanceIndex: $balanceIndex, amountToTransfer: $amountToTransfer, - summary: $summary, - cameraAction: cameraAction) + summary: $summary) } // ScrollView .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) // .scrollBounceBehavior(.basedOnSize) needs iOS 16.4 @@ -87,7 +85,6 @@ struct SendAmountContent: View { @Binding var balanceIndex: Int @Binding var amountToTransfer: Amount @Binding var summary: String - let cameraAction: () -> Void // TODO: call getMaxPeerPushDebitAmountM @@ -265,7 +262,6 @@ struct SendAmountContent: View { .onDisappear { symLog.log("❗️ \(navTitle) onDisappear") } - .navigationBarItems(trailing: QRButton(action: cameraAction)) .task(id: balanceIndex + (1000 * controller.currencyTicker)) { if let balance { scopeInfo = balance.scopeInfo @@ -327,9 +323,6 @@ fileprivate struct Preview_Content: View { @State private var currencyInfoL: CurrencyInfo = CurrencyInfo.zero(DEMOCURRENCY) @State private var noBalance: Balance? = nil - private func checkCameraAvailable() -> Void { - // Open Camera when QR-Button was tapped - } var body: some View { let amount = Amount(currency: DEMOCURRENCY, cent: 1000) let pending = Amount(currency: DEMOCURRENCY, cent: 0) @@ -352,8 +345,7 @@ fileprivate struct Preview_Content: View { balances: [balance], selectedBalance: $noBalance, amountToTransfer: $amountToPreview, - summary: $summary, - cameraAction: checkCameraAvailable) + summary: $summary) } } diff --git a/TalerWallet1/Views/Actions/SendRequestV.swift b/TalerWallet1/Views/Actions/SendRequestV.swift @@ -18,7 +18,6 @@ struct SendRequestV: View { // let currency: String // this is the currency to be used @Binding var amountToTransfer: Amount // does still have the wrong currency @Binding var summary: String - let cameraAction: () -> Void @EnvironmentObject private var model: WalletModel @EnvironmentObject private var controller: Controller diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -18,7 +18,6 @@ struct BalancesListView: View { @Binding var selectedBalance: Balance? // @Binding var shouldReloadPending: Int @Binding var shouldReloadBalances: Int - let cameraAction: () -> Void @EnvironmentObject private var model: WalletModel @EnvironmentObject private var controller: Controller @@ -63,8 +62,7 @@ struct BalancesListView: View { sectionCount: count, amountToTransfer: $amountToTransfer, // does still have the wrong currency summary: $summary, - shouldReloadBalances: $shouldReloadBalances, - cameraAction: cameraAction) + shouldReloadBalances: $shouldReloadBalances) } .onAppear() { DebugViewC.shared.setViewID(VIEW_BALANCES, stack: stack.push("onAppear")) @@ -83,7 +81,6 @@ struct BalancesListView: View { } } #endif - .navigationBarItems(trailing: QRButton(action: cameraAction)) .task(id: shouldReloadBalances) { symLog.log(".task shouldReloadBalances \(shouldReloadBalances)") let invalidateCache = (lastReloadedBalances != shouldReloadBalances) diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -24,7 +24,6 @@ struct BalancesSectionView { @Binding var amountToTransfer: Amount // does still have the wrong currency @Binding var summary: String @Binding var shouldReloadBalances: Int - let cameraAction: () -> Void @EnvironmentObject private var model: WalletModel @Environment(\.colorScheme) private var colorScheme diff --git a/TalerWallet1/Views/HelperViews/BarGraph.swift b/TalerWallet1/Views/HelperViews/BarGraph.swift @@ -39,8 +39,7 @@ struct BarGraphHeader: View { // .headerProminence(.increased) // unfortunately this is not useful .task(id: shouldReloadBalances + 2_000_000) { if let scopeInfo { - symLog.log(".task for BarGraphHeader(\(scopeInfo.currency)) - reload Transactions") - // TODO: only load the 10 most recent transactions + symLog.log(".task for BarGraphHeader(\(scopeInfo.currency)) - load \(MAXBARS) Transactions") if let response = try? await model.transactionsT2(stack.push("BarGraphHeader - \(scopeInfo.url?.trimURL)"), scopeInfo: scopeInfo, filterByState: .done, diff --git a/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift b/TalerWallet1/Views/HelperViews/View+fixedInnerHeight.swift @@ -1,5 +1,6 @@ /* MIT License - * Copyright (c) 2023 mevmev + * Copyright (c) 2023 mevmev, Rahul Bir + Michal Šrůtek, jnpdx + * https://stackoverflow.com/questions/74471576/make-sheet-the-exact-size-of-the-content-inside * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,7 +24,7 @@ import SwiftUI import UIKit struct InnerHeightPreferenceKey: PreferenceKey { - static var defaultValue: CGFloat = 200 + static var defaultValue: CGFloat = .zero static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = nextValue() } diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -339,16 +339,14 @@ extension MainView { balances: balances, selectedBalance: $selectedBalance, // if nil shows currency picker amountToTransfer: $amountToTransfer, // currency needs to be updated! - summary: $summary, - cameraAction: cameraAction) + summary: $summary) let requestDest = RequestPayment(stack: stack.push("\(Self.className())()"), balances: balances, selectedBalance: $selectedBalance, amountToTransfer: $amountToTransfer, // currency needs to be updated! summary: $summary, - scopeInfo: scope, - cameraAction: cameraAction) + scopeInfo: scope) let depositDest = DepositIbanV(stack: stack.push(), balances: balances, @@ -374,8 +372,7 @@ extension MainView { balances: $balances, selectedBalance: $selectedBalance, // shouldReloadPending: $shouldReloadPending, - shouldReloadBalances: $shouldReloadBalances, - cameraAction: cameraAction) + shouldReloadBalances: $shouldReloadBalances) .navigationTitle(balancesTitle) .background( Group { NavigationLink(destination: sendDest, tag: 1, selection: $navModel.actionSelected) diff --git a/TalerWallet1/Views/Sheets/Sheet.swift b/TalerWallet1/Views/Sheets/Sheet.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 SymLog import os.log @@ -9,19 +12,18 @@ import os.log struct Sheet: View { private let symLog = SymLogV(0) let stack: CallStack + var sheetView: AnyView + @Environment(\.dismiss) var dismiss // call dismiss() to get rid of the sheet @EnvironmentObject private var debugViewC: DebugViewC @EnvironmentObject private var model: WalletModel @AppStorage("talerFontIndex") var talerFontIndex: Int = 0 - #if DEBUG @AppStorage("developerMode") var developerMode: Bool = true #else @AppStorage("developerMode") var developerMode: Bool = false #endif - var sheetView: AnyView - let logger = Logger(subsystem: "net.taler.gnu", category: "Sheet") var cancelButton: some View { diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift @@ -57,9 +57,9 @@ struct TransactionSummaryV: View { func loadTransaction() async { if let reloadedTransaction = try? await reloadAction(transactionId, false) { symLog.log("reloaded transaction: \(reloadedTransaction.common.txState.major)") - withAnimation() { transaction = reloadedTransaction; viewId = UUID() } // redraw + withAnimation { transaction = reloadedTransaction; viewId = UUID() } // redraw } else { - withAnimation() { transaction = Transaction(dummyCurrency: DEMOCURRENCY); viewId = UUID() } + withAnimation{ transaction = Transaction(dummyCurrency: DEMOCURRENCY); viewId = UUID() } } } @@ -95,7 +95,7 @@ struct TransactionSummaryV: View { let newMajor = transition.newTxState.major Task { // runs on MainActor // flush the screen first, then reload - withAnimation() { transaction = Transaction(dummyCurrency: DEMOCURRENCY); viewId = UUID() } + withAnimation { transaction = Transaction(dummyCurrency: DEMOCURRENCY); viewId = UUID() } symLog.log("newState: \(newMajor), reloading transaction") await loadTransaction() }