gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 07/30: KYC


From: gnunet
Subject: [taler-taler-ios] 07/30: KYC
Date: Sun, 19 Nov 2023 23:53:31 +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 e4ce6345dbed62a2dc15f9727427e996527603dd
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Nov 17 16:52:49 2023 +0100

    KYC
---
 TalerWallet1/Model/Transaction.swift               |  3 +++
 TalerWallet1/Views/Main/MainView.swift             | 24 +++++++++++++---------
 .../Views/Transactions/TransactionDetailView.swift | 16 +++++++++++++++
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/TalerWallet1/Model/Transaction.swift 
b/TalerWallet1/Model/Transaction.swift
index 307e548..2436d8c 100644
--- a/TalerWallet1/Model/Transaction.swift
+++ b/TalerWallet1/Model/Transaction.swift
@@ -97,6 +97,7 @@ struct TransactionTransition: Codable {             // 
Notification
     var oldTxState: TransactionState
     var newTxState: TransactionState
     var transactionId: String
+    var experimentalUserData: String?       // KYC
 }
 
 enum TxAction: String, Codable {
@@ -436,6 +437,8 @@ enum Transaction: Decodable, Hashable, Identifiable, 
Sendable {
     var isP2pIncoming: Bool { isSendInvoice || isRcvCoins}
 
     var isPending    : Bool { common.txState.major == .pending }
+    var isPendingReady : Bool { common.txState.minor == .ready }
+    var isPendingKYC   : Bool { common.txState.minor == .kyc }
     var isDone       : Bool { common.txState.major == .done }
     var isAborting   : Bool { common.txState.major == .aborting }
     var isAborted    : Bool { common.txState.major == .aborted }
diff --git a/TalerWallet1/Views/Main/MainView.swift 
b/TalerWallet1/Views/Main/MainView.swift
index a1639ed..ab80d3c 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -94,11 +94,16 @@ extension MainView {
 #if TABBAR  // Taler Wallet
         @State private var selectedTab: Tab = .balances
         @State private var showKycAlert: Bool = false
+        @State private var kycURI: URL?
 
         private var openKycButton: some View {
             Button("KYC") {
                 showKycAlert = false
-//                UIApplication.shared.open(URL(string: 
UIApplication.openSettingsURLString)!)
+                if let kycURI {
+                    UIApplication.shared.open(kycURI)
+                } else {
+                    // YIKES!
+                }
             }
         }
         private var dismissAlertButton: some View {
@@ -242,19 +247,18 @@ extension MainView {
                   hamburgerAction: hamburgerAction)
             }
 #endif
-          } .onNotification(.TransactionStateTransition) { notification in
+          } .onNotification(.KYCrequired) { notification in
               // show an alert with the KYC link (button) which opens in Safari
                 if let transition = 
notification.userInfo?[TRANSACTIONTRANSITION] as? TransactionTransition {
-                    if transition.newTxState.major == .pending {
-                        if let newMinor = transition.newTxState.minor {
-                            if newMinor == .kyc {       // user did confirm on 
bank website
-                                logger.log(".onNotification(): KYC required")
-                                showKycAlert = true
-                            }
+                    if let kycString = transition.experimentalUserData {
+                        if let urlForKYC = URL(string: kycString) {
+                            logger.log(".onNotification(.KYCrequired): 
\(kycString)")
+                            kycURI = urlForKYC
+                            showKycAlert = true
                         }
+                    } else {
+                        // TODO: no KYC URI
                     }
-                } else { // should never happen
-                    logger.error("Yikes❗️ TransactionStateTransition without 
transition")
                 }
             }
             .alert("You need to pass a KYC procedure",
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift 
b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index d714f03..330f753 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -225,6 +225,22 @@ struct TransactionDetailView: View {
                                                 }
                                             }
                                         }
+                                    } else if transaction.isPendingKYC {
+                                        if let kycUrl = common.kycUrl {
+                                            if let destination = URL(string: 
kycUrl) {
+                                                VStack(alignment: .leading) {  
// Show Hint that User must pass KYC on website
+                                                    if !iconOnly {
+                                                        Text("You need to pass 
a KYC procedure")
+                                                            
.fixedSize(horizontal: false, vertical: true)       // wrap in scrollview
+                                                            
.multilineTextAlignment(.leading)                   // otherwise
+                                                            
.listRowSeparator(.hidden)
+                                                    }
+                                                    Link("Open KYC website", 
destination: destination)
+                                                        
.buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, aligned: 
.center))
+                                                        .padding(.horizontal)
+                                                }
+                                            }
+                                        }
                                     }
                             } // switch
                         } // ManualDetails or Confirm with bank

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