gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 04/07: deleteExchange


From: gnunet
Subject: [taler-taler-ios] 04/07: deleteExchange
Date: Thu, 03 Oct 2024 07:41:50 +0200

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 df49c9c40b3a07be7194798b69f5af47e6552d55
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Oct 2 19:28:52 2024 +0200

    deleteExchange
---
 TalerWallet1/Views/Banking/ExchangeListView.swift  | 70 ++++++++++------------
 .../Views/Banking/ExchangeSectionView.swift        | 22 ++++++-
 2 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/TalerWallet1/Views/Banking/ExchangeListView.swift 
b/TalerWallet1/Views/Banking/ExchangeListView.swift
index 682e426..f2deefd 100644
--- a/TalerWallet1/Views/Banking/ExchangeListView.swift
+++ b/TalerWallet1/Views/Banking/ExchangeListView.swift
@@ -97,51 +97,47 @@ extension ExchangeListCommonV: View {
         let _ = symLog?.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
 #endif
         let sortedExchanges = exchanges.sorted { $0 < $1 }
+        let sortedList = List(sortedExchanges, id: \.self) { exchange in
+            ExchangeSectionView(stack: stack.push(),
+                             balances: $balances,
+                             exchange: exchange,
+//                        depositIBAN: $depositIBAN,
+//                      accountHolder: $accountHolder,
+                     amountToTransfer: $amountToTransfer)               // 
does still have the wrong currency
+        }
+
+        let emptyList = List {
+            Section {
+                Text("There are no Payment Services yet.")
+                    .talerFont(.title3)
+            }
+            Section {
+                Text("Use the Add button to add a service.")
+                    .talerFont(.body)
+                    .listRowSeparator(.hidden)
+                Text("You can also scan a withdrawal QR code from your bank on 
the Balances tab to automatically add a payment service.")
+                    .talerFont(.body)
+            }
+        }
+
         // TODO: Balances for amountAvailable for Deposit
         Group {
-            List(sortedExchanges, id: \.self) { exchange in
-                ExchangeSectionView(stack: stack.push(),
-                                 balances: $balances,
-                                 exchange: exchange,
-//                              depositIBAN: $depositIBAN,
-//                            accountHolder: $accountHolder,
-                         amountToTransfer: $amountToTransfer)               // 
does still have the wrong currency
+            if exchanges.isEmpty {
+                emptyList
+            } else {
+                sortedList
             }
+        }
+        .listStyle(myListStyle.style).anyView
 //#if REFRESHABLE
-            .refreshable {
-                symLog?.log("refreshing")
-                await reloadExchanges()
-            }
-//#endif
-            .listStyle(myListStyle.style).anyView
+        .refreshable {
+            symLog?.log("refreshing")
+            await reloadExchanges()
         }
+//#endif
         .onAppear() {
             DebugViewC.shared.setViewID(VIEW_BANKING, stack: stack.push())
         }
-        .overlay {
-            if exchanges.isEmpty {
-                List {
-                    Section {
-                        Text("There are no Payment Services yet.")
-                            .talerFont(.title3)
-                    }
-                    Section {
-                        Text("Use the Add button to add a service.")
-                            .talerFont(.body)
-                            .listRowSeparator(.hidden)
-                        Text("You can also scan a withdrawal QR code from your 
bank on the Balances tab to automatically add a payment service.")
-                            .talerFont(.body)
-                    }
-                }
-//#if REFRESHABLE
-                .refreshable {
-                    symLog?.log("refreshing")
-                    await reloadExchanges()
-                }
-//#endif
-                .listStyle(myListStyle.style).anyView
-            }
-        }
         .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")
diff --git a/TalerWallet1/Views/Banking/ExchangeSectionView.swift 
b/TalerWallet1/Views/Banking/ExchangeSectionView.swift
index e5eae86..852a0a2 100755
--- a/TalerWallet1/Views/Banking/ExchangeSectionView.swift
+++ b/TalerWallet1/Views/Banking/ExchangeSectionView.swift
@@ -52,10 +52,14 @@ struct ExchangeSectionView: View {
 
     private func deleteExchange() {
         disabled = true     // don't try this more than once
+        let doPurge = purge
         Task { // runs on MainActor
-            if let _ = try? await model.deleteExchange(url: 
exchange.exchangeBaseUrl, purge: purge) {
+            let baseUrl = exchange.exchangeBaseUrl
+            if let _ = try? await model.deleteExchange(url: baseUrl, purge: 
doPurge, viewHandles: !doPurge) {
                 symLog.log("deleted \(baseUrl.trimURL())")
                 didDelete = true             // change button text
+                NotificationCenter.default.post(name: .ExchangeDeleted, 
object: nil, userInfo: nil)
+                NotificationCenter.default.post(name: .BalanceChange, object: 
nil, userInfo: nil)
             } else {
                 purge = true
                 disabled = false
@@ -97,15 +101,29 @@ struct ExchangeSectionView: View {
                 .accessibilityElement(children: .combine)
                 .accessibilityLabel(bankingHint + " " + linkTitle)
                 .padding(.top)
+                .listRowSeparator(.hidden)
             }
 
             let buttonTitle = String(localized: "Exchange.Delete", 
defaultValue: "Delete Payment Provider", comment: "Action button")
-            WarningButton(warningText: String(localized: "Are you sure you 
want to delete this payment provider?"),
+            let warningText1 = String(localized: "Are you sure you want to 
delete this payment provider?")
+            let warningText2 = String(localized: "This payment provider is in 
use. Delete anyway?")
+            WarningButton(warningText: warningText1,
                           buttonTitle: buttonTitle,
                            buttonIcon: "trash",
                                  role: .destructive,
                              disabled: $disabled,
                                action: deleteExchange)
+            .padding(.top)
+            .alert(warningText2, isPresented: $purge, actions: {
+                Button("Cancel", role: .cancel) {
+                    purge = false
+                }
+                Button(buttonTitle) {
+                    deleteExchange()
+                    purge = false
+                }
+              }, message: { Text("You will loose all \(currency) of this 
payment provider") }
+            )
         } header: {
             BarGraphHeader(stack: stack.push(),
                        scopeInfo: scopeInfo,

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