taler-ios

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

commit a9f37010a880fd2291ff300491bd35abc6afc78d
parent 2f43f4269cbc47a00c503f02f6c7f75bb2920d8f
Author: Marc Stibane <marc@taler.net>
Date:   Sun, 19 Nov 2023 13:24:12 +0100

cleanup

Diffstat:
MTalerWallet1/Backend/WalletCore.swift | 31++++++++++++++++++-------------
MTalerWallet1/Model/Model+Exchange.swift | 18------------------
MTalerWallet1/Model/Model+Withdraw.swift | 4++--
MTalerWallet1/Model/WalletModel.swift | 6++++--
MTalerWallet1/Views/Balances/BalanceRowView.swift | 3++-
MTalerWallet1/Views/Balances/TwoRowButtons.swift | 2+-
MTalerWallet1/Views/Exchange/ManualWithdraw.swift | 2+-
MTalerWallet1/Views/HelperViews/Buttons.swift | 1+
MTalerWallet1/Views/Transactions/TransactionDetailView.swift | 18+++++++++---------
9 files changed, 38 insertions(+), 47 deletions(-)

diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -197,31 +197,36 @@ extension WalletCore { case .done: logger.info("Done: \(decoded.transactionId, privacy: .private(mask: .hash))") Controller.shared.playSound(type.isIncoming ? 2 : 1) - postNotification(.TransactionDone, - userInfo: [TRANSACTIONTRANSITION: decoded]) + postNotification(.TransactionDone, userInfo: [TRANSACTIONTRANSITION: decoded]) + return case .expired: logger.log("Expired: \(decoded.transactionId, privacy: .private(mask: .hash))") Controller.shared.playSound(0) - postNotification(.TransactionExpired, - userInfo: [TRANSACTIONTRANSITION: decoded]) + postNotification(.TransactionExpired, userInfo: [TRANSACTIONTRANSITION: decoded]) + return case .pending: if let newMinor = decoded.newTxState.minor { if newMinor == .ready { - postNotification(.PendingReady, - userInfo: [TRANSACTIONTRANSITION: decoded]) + logger.log("PendingReady: \(decoded.transactionId, privacy: .private(mask: .hash))") + postNotification(.PendingReady, userInfo: [TRANSACTIONTRANSITION: decoded]) + return } else if newMinor == .exchangeWaitReserve // user did confirm on bank website || newMinor == .withdrawCoins { // coin-withdrawal has started - postNotification(.DismissSheet, - userInfo: [TRANSACTIONTRANSITION: decoded]) + logger.log("DismissSheet: \(decoded.transactionId, privacy: .private(mask: .hash))") + postNotification(.DismissSheet, userInfo: [TRANSACTIONTRANSITION: decoded]) + return } else if newMinor == .kyc { // user did confirm on bank website, but KYC is needed - postNotification(.KYCrequired, - userInfo: [TRANSACTIONTRANSITION: decoded]) + logger.log("KYCrequired: \(decoded.transactionId, privacy: .private(mask: .hash))") + postNotification(.KYCrequired, userInfo: [TRANSACTIONTRANSITION: decoded]) + return } } - default: break + logger.log("Pending: \(decoded.transactionId, privacy: .private(mask: .hash))") + postNotification(.TransactionStateTransition, userInfo: [TRANSACTIONTRANSITION: decoded]) + default: + logger.log("Yikes: \(decoded.transactionId, privacy: .private(mask: .hash))") + postNotification(.TransactionStateTransition, userInfo: [TRANSACTIONTRANSITION: decoded]) } // switch - postNotification(.TransactionStateTransition, - userInfo: [TRANSACTIONTRANSITION: decoded]) } // type } // 3 components } catch { // rethrows diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift @@ -61,24 +61,6 @@ struct Exchange: Codable, Hashable, Identifiable { } } -struct ExchangeListItem: Codable, Hashable { - var exchangeBaseUrl: String - var currency: String - var paytoUris: [String] - - public static func == (lhs: ExchangeListItem, rhs: ExchangeListItem) -> Bool { - return lhs.exchangeBaseUrl == rhs.exchangeBaseUrl && - lhs.currency == rhs.currency && - lhs.paytoUris == rhs.paytoUris - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(exchangeBaseUrl) - hasher.combine(currency) - hasher.combine(paytoUris) - } -} - struct ExchangeUrlItem: Codable, Hashable, Identifiable { var exchangeBaseUrl: String var id: String { exchangeBaseUrl } diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift @@ -11,8 +11,8 @@ fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging /// The result from getWithdrawalDetailsForUri struct WithdrawUriInfoResponse: Decodable { var amount: Amount - var defaultExchangeBaseUrl: String? // TODO: might be nil ❗️Yikes - var possibleExchanges: [ExchangeListItem] // TODO: query these for fees? + var defaultExchangeBaseUrl: String? + var possibleExchanges: [Exchange] // TODO: query these for fees? } /// A request to get an exchange's withdrawal details. fileprivate struct GetWithdrawalDetailsForURI: WalletBackendFormattedRequest { diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -122,8 +122,9 @@ extension WalletModel { } private func docPath (sqlite3: Bool) throws -> String { - if let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { - let documentUrl = documentsUrl.appendingPathComponent(DATABASE, isDirectory: false) +// if let documentsDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first { + if let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { + let documentUrl = documentsDir.appendingPathComponent(DATABASE, isDirectory: false) .appendingPathExtension(sqlite3 ? "sqlite3" : "json") let docPath = documentUrl.path logger.debug("\(docPath)") @@ -174,3 +175,4 @@ extension WalletModel { _ = try await sendRequest(request, 0) } } +// MARK: - diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -10,8 +10,8 @@ struct BalanceButton: View { let sizeCategory: ContentSizeCategory let rowAction: () -> Void - @AppStorage("iconOnly") var iconOnly: Bool = false @Environment(\.colorSchemeContrast) private var colorSchemeContrast + @AppStorage("iconOnly") var iconOnly: Bool = false // @AppStorage("moreContrast") var moreContrast: Bool = false var body: some View { @@ -51,6 +51,7 @@ struct BalanceRowView: View { let sendAction: () -> Void let recvAction: () -> Void let rowAction: () -> Void + @Environment(\.sizeCategory) var sizeCategory @EnvironmentObject private var controller: Controller @AppStorage("iconOnly") var iconOnly: Bool = false diff --git a/TalerWallet1/Views/Balances/TwoRowButtons.swift b/TalerWallet1/Views/Balances/TwoRowButtons.swift @@ -25,8 +25,8 @@ struct TwoRowButtons: View { let sendDisabled: Bool let sendAction: () -> Void let recvAction: () -> Void + @Environment(\.sizeCategory) var sizeCategory - var body: some View { Group { diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift @@ -26,7 +26,7 @@ struct ManualWithdraw: View { let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let currency = exchange.currency ?? String(localized: "Unknown", comment: "unknown currency") + let currency = exchange.scopeInfo?.currency ?? exchange.currency ?? String(localized: "Unknown", comment: "unknown currency") let navTitle = String(localized: "NavTitle_Withdraw (currency)", defaultValue: "Withdraw \(currency)") // let agePicker = AgePicker(ageMenuList: $ageMenuList, selectedAge: $selectedAge) diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -107,6 +107,7 @@ struct TalerButtonStyle: ButtonStyle { var aligned: TextAlignment = .center 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), backColor: backColor(type: type, pressed: configuration.isPressed), diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -24,15 +24,6 @@ extension Transaction { // for Dummys struct TransactionDetailView: View { private let symLog = SymLogV(0) let stack: CallStack - @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic -// @AppStorage("moreContrast") var moreContrast: Bool = false -#if DEBUG - @AppStorage("developerMode") var developerMode: Bool = true -#else - @AppStorage("developerMode") var developerMode: Bool = false -#endif - @Environment(\.colorSchemeContrast) private var colorSchemeContrast - let transactionId: String let reloadAction: ((_ transactionId: String) async throws -> Transaction) @@ -44,6 +35,15 @@ struct TransactionDetailView: View { let suspendAction: ((_ transactionId: String) async throws -> Void)? let resumeAction: ((_ transactionId: String) async throws -> Void)? + @Environment(\.colorSchemeContrast) private var colorSchemeContrast + @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic +// @AppStorage("moreContrast") var moreContrast: Bool = false +#if DEBUG + @AppStorage("developerMode") var developerMode: Bool = true +#else + @AppStorage("developerMode") var developerMode: Bool = false +#endif + @State var transaction: Transaction = Transaction(dummyCurrency: DEMOCURRENCY) @State var viewId = UUID()