commit d039dbdf59f85baa8dee57c5727fc523391335bc
parent 93bdf944d63ad9c26c05ddded2feecb62c02c218
Author: Marc Stibane <marc@taler.net>
Date: Sun, 12 Nov 2023 10:11:38 +0100
Cleanup
Diffstat:
9 files changed, 51 insertions(+), 64 deletions(-)
diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift
@@ -54,6 +54,7 @@ class Controller: ObservableObject {
backendState = .instantiated
currencyInfos = []
}
+// MARK: -
func info(for currency: String) -> CurrencyInfo? {
for currencyInfo in currencyInfos {
@@ -81,7 +82,7 @@ class Controller: ObservableObject {
}
currencyInfos.append(info)
}
-
+// MARK: -
@MainActor
func initWalletCore(_ model: WalletModel, sqlite3: Bool)
async throws {
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -99,7 +99,8 @@ struct BalanceRowView: View {
// MARK: -
#if DEBUG
-struct SomeBalanceRows: View {
+struct BalanceRowView_Previews: PreviewProvider {
+ struct StateContainer: View {
var body: some View {
let testInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 0)
let demoInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 2)
@@ -114,13 +115,11 @@ struct SomeBalanceRows: View {
}
BalanceRowView(amount: test, currencyInfo: testInfo, sendAction: {}, recvAction: {}, rowAction: {})
}
-
}
-}
+ }
-struct BalanceRowView_Previews: PreviewProvider {
static var previews: some View {
- SomeBalanceRows()
+ StateContainer()
// .environment(\.sizeCategory, .extraExtraLarge) Canvas Device Settings
}
}
diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift b/TalerWallet1/Views/Balances/PendingRowView.swift
@@ -108,16 +108,13 @@ struct PendingRowView: View {
}
// MARK: -
#if DEBUG
-
func PreviewCurrencyInfo(_ currency: String, digits: Int) -> CurrencyInfo {
let unitName = digits == 0 ? "¥" : "€"
let scope = ScopeInfo(type: .global, currency: currency)
- let specs = CurrencySpecification(name: TESTCURRENCY,
-// decimalSeparator: ".", groupSeparator: "'",
+ let specs = CurrencySpecification(name: currency,
fractionalInputDigits: digits,
fractionalNormalDigits: digits,
fractionalTrailingZeroDigits: digits,
-// isCurrencyNameLeading: true,
altUnitNames: [0 : unitName])
let formatter = CurrencyFormatter.formatter(scope: scope, specs: specs)
return CurrencyInfo(scope: scope, specs: specs, formatter: formatter)
diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
@@ -96,7 +96,8 @@ struct ManualWithdraw: View {
}
// MARK: -
#if DEBUG
-struct ManualWithdraw_Container : View {
+struct ManualWithdraw_Previews: PreviewProvider {
+ struct StateContainer : View {
@State private var centsToTransfer: UInt64 = 510
@State private var details = WithdrawalAmountDetails(tosAccepted: false,
amountRaw: Amount(currency: LONGCURRENCY, cent: 510),
@@ -117,11 +118,10 @@ struct ManualWithdraw_Container : View {
centsToTransfer: $centsToTransfer,
withdrawalAmountDetails: details)
}
-}
+ }
-struct ManualWithdraw_Previews: PreviewProvider {
static var previews: some View {
- ManualWithdraw_Container()
+ StateContainer()
}
}
#endif
diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
@@ -1,10 +1,7 @@
-//
-// CurrencyInputView.swift
-// TalerWalletT
-//
-// Created by Marc Stibane on 2023-06-04.
-// Copyright © 2023 Taler. All rights reserved.
-//
+/*
+ * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * See LICENSE.md
+ */
import SwiftUI
struct CurrencyInputView: View {
diff --git a/TalerWallet1/Views/Peer2peer/SendPurpose.swift b/TalerWallet1/Views/Peer2peer/SendPurpose.swift
@@ -9,7 +9,6 @@ import SymLog
struct SendPurpose: View {
private let symLog = SymLogV(0)
let stack: CallStack
- @FocusState private var isFocused: Bool
let amountAvailable: Amount
let centsToTransfer: UInt64
@@ -26,6 +25,7 @@ struct SendPurpose: View {
// return formatter.string(for: Decimal(centsToTransfer) / mag) ?? ""
return String(centsToTransfer / 100) // TODO: based on currency
}
+ @FocusState private var isFocused: Bool
var body: some View {
let amount = Amount.amountFromCents(amountAvailable.currencyStr, centsToTransfer)
diff --git a/TalerWallet1/Views/Settings/AboutView.swift b/TalerWallet1/Views/Settings/AboutView.swift
@@ -94,11 +94,7 @@ extension Bundle {
#if DEBUG
struct AboutView_Previews: PreviewProvider {
static var previews: some View {
-#if TABBAR // Taler Wallet
AboutView(stack: CallStack("Preview"), navTitle: "About")
-#else // GNU Taler
- SettingsView(stack: CallStack("Preview"), navTitle: "About") { }
-#endif
}
}
#endif
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -13,8 +13,6 @@ import SymLog
* Debug log
* View/send internal log
*
- * Reset Wallet (dangerous!)
- * Throws away your money
*/
struct SettingsView: View {
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -119,44 +119,43 @@ struct PaymentURIView_Previews: PreviewProvider {
let extra = Extra(articleName: "articleName")
let product = Product(description: "description")
let terms = MerchantContractTerms(hWire: "hWire",
- wireMethod: "wireMethod",
- summary: "summary",
- summaryI18n: nil,
+ wireMethod: "wireMethod",
+ summary: "summary",
+ summaryI18n: nil,
nonce: "nonce",
- amount: Amount(currency: LONGCURRENCY, cent: 220),
- payDeadline: Timestamp.tomorrow(),
- maxFee: Amount(currency: LONGCURRENCY, cent: 20),
- merchant: merchant,
- merchantPub: "merchantPub",
- deliveryDate: nil,
- deliveryLocation: nil,
- exchanges: [],
- products: [product],
- refundDeadline: Timestamp.tomorrow(),
- wireTransferDeadline: Timestamp.tomorrow(),
- timestamp: Timestamp.now(),
- orderID: "orderID",
- merchantBaseURL: "merchantBaseURL",
- fulfillmentURL: "fulfillmentURL",
- publicReorderURL: "publicReorderURL",
- fulfillmentMessage: nil,
- fulfillmentMessageI18n: nil,
- wireFeeAmortization: 0,
- maxWireFee: Amount(currency: LONGCURRENCY, cent: 20),
- minimumAge: nil
-// extra: extra,
-// auditors: [],
+ amount: Amount(currency: LONGCURRENCY, cent: 220),
+ payDeadline: Timestamp.tomorrow(),
+ maxFee: Amount(currency: LONGCURRENCY, cent: 20),
+ merchant: merchant,
+ merchantPub: "merchantPub",
+ deliveryDate: nil,
+ deliveryLocation: nil,
+ exchanges: [],
+ products: [product],
+ refundDeadline: Timestamp.tomorrow(),
+ wireTransferDeadline: Timestamp.tomorrow(),
+ timestamp: Timestamp.now(),
+ orderID: "orderID",
+ merchantBaseURL: "merchantBaseURL",
+ fulfillmentURL: "fulfillmentURL",
+ publicReorderURL: "publicReorderURL",
+ fulfillmentMessage: nil,
+ fulfillmentMessageI18n: nil,
+ wireFeeAmortization: 0,
+ maxWireFee: Amount(currency: LONGCURRENCY, cent: 20),
+ minimumAge: nil
+// extra: extra,
+// auditors: []
)
- let details = PreparePayResult(
- status: PreparePayResultType.paymentPossible,
- transactionId: "txn:payment:012345",
- contractTerms: terms,
- contractTermsHash: "termsHash",
- amountRaw: Amount(currency: LONGCURRENCY, cent: 220),
- amountEffective: Amount(currency: LONGCURRENCY, cent: 240),
- balanceDetails: nil,
- paid: nil
-// , talerUri: "talerURI"
+ let details = PreparePayResult(status: PreparePayResultType.paymentPossible,
+ transactionId: "txn:payment:012345",
+ contractTerms: terms,
+ contractTermsHash: "termsHash",
+ amountRaw: Amount(currency: LONGCURRENCY, cent: 220),
+ amountEffective: Amount(currency: LONGCURRENCY, cent: 240),
+ balanceDetails: nil,
+ paid: nil
+// , talerUri: "talerURI"
)
let url = URL(string: "taler://pay/some_amount")!