aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2024-03-01 10:21:46 +0100
committerMarc Stibane <marc@taler.net>2024-03-01 10:21:46 +0100
commit898b6d941bbfd130861904ef76abf72d47f3ac0e (patch)
treed9ecc95ab3d0f2d864247b6ff4b8173c1b39e763
parent9453c61dd09304de43dd0fbe1bae29fa681cb2b6 (diff)
downloadtaler-ios-898b6d941bbfd130861904ef76abf72d47f3ac0e.tar.gz
taler-ios-898b6d941bbfd130861904ef76abf72d47f3ac0e.tar.bz2
taler-ios-898b6d941bbfd130861904ef76abf72d47f3ac0e.zip
direct withdrawal in empty wallet
-rw-r--r--TalerWallet1/Model/Model+Settings.swift9
-rw-r--r--TalerWallet1/Views/Main/WalletEmptyView.swift38
-rw-r--r--TalerWallet1/Views/Settings/SettingsView.swift6
3 files changed, 37 insertions, 16 deletions
diff --git a/TalerWallet1/Model/Model+Settings.swift b/TalerWallet1/Model/Model+Settings.swift
index eb3b019..a727679 100644
--- a/TalerWallet1/Model/Model+Settings.swift
+++ b/TalerWallet1/Model/Model+Settings.swift
@@ -33,13 +33,12 @@ fileprivate struct WithdrawTestBalanceRequest: WalletBackendFormattedRequest {
}
}
extension WalletModel {
- @MainActor func loadTestKudosM(test: Bool)
+ @MainActor func loadTestKudosM(test: Bool, amount: Amount)
async throws { // M for MainActor
- let amount = Amount(currency: test ? TESTCURRENCY : DEMOCURRENCY, cent: 1100)
let request = WithdrawTestBalanceRequest(amount: amount,
-// bankBaseUrl: test ? TESTBANK : DEMOBANK,
- corebankApiBaseUrl: test ? TESTBANK : DEMOBANK,
- exchangeBaseUrl: test ? TESTEXCHANGE : DEMOEXCHANGE)
+// bankBaseUrl: test ? TESTBANK : DEMOBANK,
+ corebankApiBaseUrl: test ? TESTBANK : DEMOBANK,
+ exchangeBaseUrl: test ? TESTEXCHANGE : DEMOEXCHANGE)
let response = try await sendRequest(request, ASYNCDELAY)
}
} // loadTestKudosM()
diff --git a/TalerWallet1/Views/Main/WalletEmptyView.swift b/TalerWallet1/Views/Main/WalletEmptyView.swift
index ff72980..0a4f3e0 100644
--- a/TalerWallet1/Views/Main/WalletEmptyView.swift
+++ b/TalerWallet1/Views/Main/WalletEmptyView.swift
@@ -7,6 +7,7 @@
*/
import SwiftUI
import SymLog
+import taler_swift
/// This view shows hints if a wallet is empty
/// It is the very first thing the user sees after installing the app
@@ -14,7 +15,10 @@ import SymLog
struct WalletEmptyView: View {
private let symLog = SymLogV(0)
let stack: CallStack
+
+ @EnvironmentObject private var model: WalletModel
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
+ @State private var withDrawDisabled = false
var body: some View {
List {
@@ -23,21 +27,37 @@ struct WalletEmptyView: View {
.talerFont(.title3)
}
Section {
- Text("You can register an account in the demo bank, then withdraw some digital cash to experience how to pay with the money of the future.")
+ Text("Use the QR code scan button to start a withdrawal if your bank already supports Taler payments.")
.talerFont(.body)
.listRowSeparator(.hidden)
- let title = String(localized: "LinkTitle_Test_Money", defaultValue: "Get demo money")
- Link(title, destination: URL(string: DEMOBANK)!)
- .buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, aligned: .center))
- .padding(.vertical)
- .accessibilityHint("Will go to the demo bank website.")
+ Text("You can also add a payment service manually on the Banking tab.")
+ .talerFont(.body)
}
Section {
- Text("Use the QR code scan button to start a withdrawal if your bank already supports Taler payments.")
+ Text("Demo: get digital cash to experience how to pay with the money of the future.")
+// Text("You can register an account in the demo bank, then withdraw some digital cash to experience how to pay with the money of the future.")
.talerFont(.body)
.listRowSeparator(.hidden)
- Text("You can also add a payment service manually on the Banking tab.")
- .talerFont(.body)
+ let title = String(localized: "LinkTitle_Test_Money", defaultValue: "Get demo money")
+ Button(title) {
+ withDrawDisabled = true // don't run twice
+ Task { // runs on MainActor
+ let amount = Amount(currency: DEMOCURRENCY, cent: 2500)
+ symLog.log("Withdraw KUDOS")
+ do {
+ try await model.loadTestKudosM(test: false, amount: amount)
+ } catch { // TODO: show error
+ symLog.log(error.localizedDescription)
+ }
+ }
+ }
+ .buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, disabled: withDrawDisabled, aligned: .center))
+ .disabled(withDrawDisabled)
+
+// Link(title, destination: URL(string: DEMOBANK)!)
+// .buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, aligned: .center))
+// .padding(.vertical)
+// .accessibilityHint("Will go to the demo bank website.")
}
}
.listStyle(myListStyle.style).anyView
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
index 8e2ba06..b77a3be 100644
--- a/TalerWallet1/Views/Settings/SettingsView.swift
+++ b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -153,7 +153,8 @@ struct SettingsView: View {
Task { // runs on MainActor
symLog.log("Withdraw KUDOS")
do {
- try await model.loadTestKudosM(test: false)
+ let amount = Amount(currency: DEMOCURRENCY, cent: 1100)
+ try await model.loadTestKudosM(test: false, amount: amount)
} catch { // TODO: show error
symLog.log(error.localizedDescription)
}
@@ -170,7 +171,8 @@ struct SettingsView: View {
Task { // runs on MainActor
symLog.log("Withdraw TESTKUDOS")
do {
- try await model.loadTestKudosM(test: true)
+ let amount = Amount(currency: TESTCURRENCY, cent: 1100)
+ try await model.loadTestKudosM(test: true, amount: amount)
} catch { // TODO: show error
symLog.log(error.localizedDescription)
}