gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 01/02: direct withdrawal in empty wallet


From: gnunet
Subject: [taler-taler-ios] 01/02: direct withdrawal in empty wallet
Date: Fri, 01 Mar 2024 10:23:27 +0100

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit 898b6d941bbfd130861904ef76abf72d47f3ac0e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Mar 1 10:21:46 2024 +0100

    direct withdrawal in empty wallet
---
 TalerWallet1/Model/Model+Settings.swift        |  9 +++---
 TalerWallet1/Views/Main/WalletEmptyView.swift  | 38 ++++++++++++++++++++------
 TalerWallet1/Views/Settings/SettingsView.swift |  6 ++--
 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)
                                     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]