commit 0da9fc43055b9d8a48ef21382f01ff2049f0d349
parent 126fac966fd0de082ef75e1449b4a2c33f706a4e
Author: Marc Stibane <marc@taler.net>
Date: Sun, 10 Nov 2024 11:51:55 +0100
cleanup
Diffstat:
7 files changed, 73 insertions(+), 85 deletions(-)
diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift
@@ -309,24 +309,16 @@ extension Controller {
// TODO: uncrypted
}
switch command.lowercased() {
- case "withdraw":
- return .withdraw
- case "withdraw-exchange":
- return .withdrawExchange
- case "terms-exchange":
- return .termsExchange
- case "pay":
- return .pay
- case "pay-pull":
- return .payPull
- case "pay-push":
- return .payPush
- case "pay-template":
- return .payTemplate
- case "refund":
- return .refund
+ case "withdraw": return .withdraw
+ case "withdraw-exchange": return .withdrawExchange
+ case "terms-exchange": return .termsExchange
+ case "pay": return .pay
+ case "pay-pull": return .payPull
+ case "pay-push": return .payPush
+ case "pay-template": return .payTemplate
+ case "refund": return .refund
default:
- self.logger.error("unknown command taler://\(command)")
+ self.logger.error("❗️unknown command taler://\(command)")
}
return .unknown
}
diff --git a/TalerWallet1/Helper/CallStack.swift b/TalerWallet1/Helper/CallStack.swift
@@ -82,6 +82,17 @@ extension CallStack {
return push(item: item)
}
#endif
+ public func print() -> String {
+ var result: String = EMPTYSTRING
+ for (item) in stack {
+#if DEBUG
+ result += item.file + " " + item.function + "; "
+#else
+ result += item.message + "; "
+#endif
+ }
+ return result
+ }
}
//extension CallStack: Equatable {
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -53,12 +53,10 @@ struct BalancesListView: View {
.listStyle(myListStyle.style).anyView
}
}
-#if REFRESHABLE
.refreshable { // already async
controller.hapticNotification(.success)
symLog.log("refreshing balances")
await controller.loadBalances(stack.push("refreshing balances"), model)
}
-#endif
}
}
diff --git a/TalerWallet1/Views/Settings/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Settings/Exchange/ExchangeListView.swift
@@ -73,6 +73,7 @@ struct ExchangeListCommonV: View {
@EnvironmentObject private var model: WalletModel
@EnvironmentObject private var controller: Controller
+ @AppStorage("minimalistic") var minimalistic: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
var body: some View {
@@ -92,12 +93,15 @@ struct ExchangeListCommonV: View {
}
Section {
let plus = Image(systemName: "plus")
- Text("Use the \(plus) button to add a service.")
- .talerFont(.body)
- .listRowSeparator(.hidden)
- Text("You can also scan a withdrawal QR code from your bank in the Action menu to automatically add a payment service.")
- .talerFont(.body)
+ if !minimalistic {
+ Text("Tap the \(plus) button to add a service.")
+ .listRowSeparator(.hidden)
+ Text("You can also scan a withdrawal QR code from your bank in the Action menu to automatically add a payment service.")
+ } else {
+ Text("Tap \(plus) or scan a withdrawal QR code from your bank to add a payment service.")
+ }
}
+ .talerFont(.body)
}
Group {
@@ -108,30 +112,14 @@ struct ExchangeListCommonV: View {
}
}
.listStyle(myListStyle.style).anyView
-//#if REFRESHABLE
.refreshable {
controller.hapticNotification(.success)
symLog?.log("refreshing")
// await reloadExchanges()
NotificationCenter.default.post(name: .BalanceChange, object: nil, userInfo: nil)
}
-//#endif
.onAppear() {
DebugViewC.shared.setViewID(VIEW_PAYMENT_SERVICES, stack: stack.push())
}
-// .onNotification(.ExchangeAdded) { notification in
-// // doesn't need to be received on main thread because we just reload in the background anyway
-// symLog?.log(".onNotification(.ExchangeAdded) ==> reloading exchanges")
-// Task { await reloadExchanges() } // runs on MainActor
-// }
-// .onNotification(.ExchangeDeleted) { notification in
-// // doesn't need to be received on main thread because we just reload in the background anyway
-// symLog?.log(".onNotification(.ExchangeDeleted) ==> reloading exchanges")
-// Task { await reloadExchanges() } // runs on MainActor
-// }
-// .task {
-// symLog?.log(".task")
-// await reloadExchanges()
-// }
} // body
}
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
@@ -71,11 +71,11 @@ struct PayTemplateV: View {
private func computeFeePayTemplate(_ amount: Amount) async -> ComputeFeeResult? {
// if let result = await preparePayForTemplate(model: model,
-// url: url,
-// amount: amountToTransfer,
-// summary: summaryIsEditable ? summary ?? " "
-// : nil,
-// announce: announce)
+// url: url,
+// amount: amountToTransfer,
+// summary: summaryIsEditable ? summary ?? " "
+// : nil,
+// announce: announce)
// {
// preparePayResult = result.ppCheck
// }
@@ -128,47 +128,49 @@ struct PayTemplateV: View {
var body: some View {
if let templateContract { // preparePayResult
// let currency = templateContract.currency ?? templateContract.amount?.currencyStr ?? UNKNOWN
-// let currencyInfo = controller.info(for: currency, controller.currencyTicker)
let amountLabel = minimalistic ? String(localized: "Amount:")
: String(localized: "Amount to pay:")
// final destination with amountToTransfer, after user input of amount
let finalDestinationI = PaymentView(stack: stack.push(),
url: url,
template: true,
- amountToTransfer: $amountToTransfer,
- summary: $summary,
- amountIsEditable: amountIsEditable,
- summaryIsEditable: summaryIsEditable)
+ amountToTransfer: $amountToTransfer,
+ summary: $summary,
+ amountIsEditable: amountIsEditable,
+ summaryIsEditable: summaryIsEditable)
+
+ // final destination with amountShortcut, when user tapped a shortcut
let finalDestinationS = PaymentView(stack: stack.push(),
url: url,
- template: true,
- amountToTransfer: $amountShortcut,
- summary: $summary,
- amountIsEditable: amountIsEditable,
- summaryIsEditable: summaryIsEditable)
+ template: true,
+ amountToTransfer: $amountShortcut,
+ summary: $summary,
+ amountIsEditable: amountIsEditable,
+ summaryIsEditable: summaryIsEditable)
// destination to subject input
let inputDestination = SubjectInputV(stack: stack.push(),
url: url,
- amountAvailable: nil,
- amountToTransfer: $amountToTransfer,
- amountLabel: amountLabel,
- summary: $summary,
-// insufficient: $insufficient,
-// feeAmount: $feeAmount,
- feeIsNotZero: true, // TODO: feeIsNotZero()
- targetView: finalDestinationI)
+ amountAvailable: nil,
+ amountToTransfer: $amountToTransfer,
+ amountLabel: amountLabel,
+ summary: $summary,
+// insufficient: $insufficient,
+// feeAmount: $feeAmount,
+ feeIsNotZero: true, // TODO: feeIsNotZero()
+ targetView: finalDestinationI)
+
// destination to subject input, when user tapped an amount shortcut
let shortcutDestination = SubjectInputV(stack: stack.push(),
url: url,
- amountAvailable: nil,
- amountToTransfer: $amountShortcut,
- amountLabel: amountLabel,
- summary: $summary,
-// insufficient: $insufficient,
-// feeAmount: $feeAmount,
- feeIsNotZero: true, // TODO: feeIsNotZero()
- targetView: finalDestinationS)
+ amountAvailable: nil,
+ amountToTransfer: $amountShortcut,
+ amountLabel: amountLabel,
+ summary: $summary,
+// insufficient: $insufficient,
+// feeAmount: $feeAmount,
+ feeIsNotZero: true, // TODO: feeIsNotZero()
+ targetView: finalDestinationS)
Group {
if amountIsEditable { // template contract amount is not fixed => let the user input an amount first
let amountInput = AmountInputV(stack: stack.push(),
diff --git a/TalerWallet1/Views/Sheets/URLSheet.swift b/TalerWallet1/Views/Sheets/URLSheet.swift
@@ -19,16 +19,14 @@ struct URLSheet: View {
@EnvironmentObject private var controller: Controller
@State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)
@State private var summary = EMPTYSTRING
- @State private var urlCommand: UrlCommand = .unknown
-
- let navTitle = String(localized: "Checking Link")
+ @State private var urlCommand: UrlCommand?
var body: some View {
#if PRINT_CHANGES
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
- Group {
+ if let urlCommand {
switch urlCommand {
case .termsExchange, // TODO: just check the ToS
.withdraw:
@@ -49,18 +47,19 @@ struct URLSheet: View {
PayTemplateV(stack: stack.push(), url: urlToOpen)
case .refund:
RefundURIView(stack: stack.push(), url: urlToOpen)
- default: // Error view
+ default: // TODO: Error view
VStack {
- Text("unknown command")
- .talerFont(.title)
+ let _ = symLog.log("❗️Unknown command❗️ \(urlToOpen.absoluteString)")
Text(controller.messageForSheet ?? urlToOpen.absoluteString)
}
- .navigationTitle(navTitle)
+ .navigationTitle("Unknown command")
}
- }
- .task {
- let command = controller.openURL(urlToOpen, stack: stack.push())
- urlCommand = command
+ } else {
+ LoadingView(scopeInfo: nil, message: "Scanning...")
+ .task {
+ let command = controller.openURL(urlToOpen, stack: stack.push())
+ urlCommand = command
+ }
}
}
}
diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift
@@ -48,13 +48,11 @@ struct TransactionsListView: View {
}
.id(viewId)
.listStyle(myListStyle.style).anyView
-#if REFRESHABLE
.refreshable {
controller.hapticNotification(.success)
symLog.log("refreshing")
await reloadAllAction(stack.push())
}
-#endif
#if false // SCROLLBUTTONS
.if(count > showUpDown) { view in
view.navigationBarItems(trailing: HStack {