gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] branch master updated: loading indicator for adding ex


From: gnunet
Subject: [taler-taler-ios] branch master updated: loading indicator for adding exchanges
Date: Wed, 10 Aug 2022 01:11:15 +0200

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

jonathan-buchanan pushed a commit to branch master
in repository taler-ios.

The following commit(s) were added to refs/heads/master by this push:
     new d37deaa  loading indicator for adding exchanges
d37deaa is described below

commit d37deaad8d4e58222e5200a8d8f7ccfa2c005aa8
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Tue Aug 9 19:10:27 2022 -0400

    loading indicator for adding exchanges
---
 Taler/ExchangeManager.swift | 25 ++++++++++++++-------
 Taler/SettingsView.swift    | 53 +++++++++++++++++++++++++++++++++++----------
 2 files changed, 58 insertions(+), 20 deletions(-)

diff --git a/Taler/ExchangeManager.swift b/Taler/ExchangeManager.swift
index 2d2e990..003d2eb 100644
--- a/Taler/ExchangeManager.swift
+++ b/Taler/ExchangeManager.swift
@@ -21,7 +21,7 @@ typealias ExchangeItem = 
WalletBackendListExchanges.ExchangeListItem
 class ExchangeManager: ObservableObject {
     var backend: WalletBackend
     
-    var loading: Bool
+    @Published var loading: Bool
     @Published var exchanges: [ExchangeItem]?
     
     init(_backend: WalletBackend) {
@@ -33,14 +33,14 @@ class ExchangeManager: ObservableObject {
     func updateList() {
         let listRequest = WalletBackendListExchanges()
         backend.sendFormattedRequest(request: listRequest) { response, err in
-            self.loading = false
-            if let result = response {
-                // TODO: Use Combine instead.
-                DispatchQueue.main.async {
+            // TODO: Use Combine instead.
+            DispatchQueue.main.async {
+                self.loading = false
+                if let result = response {
                     self.exchanges = result.exchanges
+                } else {
+                    // TODO: Show error.
                 }
-            } else {
-                // TODO: Show error.
             }
         }
         self.loading = true
@@ -49,7 +49,16 @@ class ExchangeManager: ObservableObject {
     func add(url: String) {
         let addRequest = WalletBackendAddExchangeRequest(exchangeBaseUrl: url)
         backend.sendFormattedRequest(request: addRequest) { response, err in
-            // TODO: Show error.
+            // TODO: Use Combine instead.
+            DispatchQueue.main.async {
+                self.loading = false
+                if let _ = response {
+                    self.updateList()
+                } else {
+                    // TODO: Show error.
+                }
+            }
         }
+        self.loading = true
     }
 }
diff --git a/Taler/SettingsView.swift b/Taler/SettingsView.swift
index 4548f12..e1607a0 100644
--- a/Taler/SettingsView.swift
+++ b/Taler/SettingsView.swift
@@ -64,13 +64,28 @@ extension View {
     }
 }
 
-struct ExchangeItemView: View {
-    var exchange: ExchangeItem
+struct WithdrawView: View {
+    let exchange: ExchangeItem
+    @State var amount: String = ""
+    
     var body: some View {
         VStack {
-            Text(exchange.exchangeBaseUrl)
-            Text("Currency: " + exchange.currency)
+            Button {
+                
+            } label: {
+                Text("Scan Taler QR Code")
+            }
+            Text("Or transfer manually:")
+            HStack {
+                TextField(exchange.currency, text: $amount)
+            }
+            Button {
+                
+            } label: {
+                Text("Check Fees")
+            }
         }
+            .navigationTitle("Withdraw")
     }
 }
 
@@ -79,7 +94,17 @@ struct ExchangeListView: View {
     @State var showPopup: Bool = false
     
     var body: some View {
-        if let exchanges = exchangeManager.exchanges {
+        if exchangeManager.exchanges == nil {
+            ProgressView()
+                .navigationTitle("Exchanges")
+                .onAppear {
+                    exchangeManager.updateList()
+                }
+        } else if exchangeManager.loading {
+            ProgressView()
+                .navigationTitle("Exchanges")
+        } else {
+            let exchanges = exchangeManager.exchanges!
             if exchanges.count == 0 {
                 Text("No Exchanges")
                     .navigationTitle("Exchanges")
@@ -99,7 +124,17 @@ struct ExchangeListView: View {
                     }, showing: showPopup)
             } else {
                 List(exchanges, id: \.self) { exchange in
-                    ExchangeItemView(exchange: exchange)
+                    VStack {
+                        Text(exchange.exchangeBaseUrl)
+                            .frame(maxWidth: .infinity)
+                        Text("Currency: " + exchange.currency)
+                            .frame(maxWidth: .infinity)
+                        NavigationLink {
+                            WithdrawView(exchange: exchange)
+                        } label: {
+                            Text("Withdraw")
+                        }
+                    }
                 }
                     .navigationTitle("Exchanges")
                     .navigationBarItems(trailing: Button(action: {
@@ -117,12 +152,6 @@ struct ExchangeListView: View {
                         print(exchangeUrl)
                     }, showing: showPopup)
             }
-        } else {
-            ProgressView()
-                .navigationTitle("Exchanges")
-                .onAppear {
-                    exchangeManager.updateList()
-                }
         }
     }
 }

-- 
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]