summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-11-04 08:27:12 +0100
committerMarc Stibane <marc@taler.net>2023-11-04 08:27:12 +0100
commit1c8b9fdac4b6aaa1495ea101cc54007abde23d47 (patch)
treea71a0ad13c81dd7897857fdd3e5ed4e3198ee04e
parentb9cb956ae2380fa1574fcb6a912662f083767d07 (diff)
downloadtaler-ios-1c8b9fdac4b6aaa1495ea101cc54007abde23d47.tar.gz
taler-ios-1c8b9fdac4b6aaa1495ea101cc54007abde23d47.tar.bz2
taler-ios-1c8b9fdac4b6aaa1495ea101cc54007abde23d47.zip
KYC - wip
-rw-r--r--TalerWallet1/Model/Transaction.swift1
-rw-r--r--TalerWallet1/Views/Main/MainView.swift35
2 files changed, 35 insertions, 1 deletions
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift
index 823e1d7..5c9f16e 100644
--- a/TalerWallet1/Model/Transaction.swift
+++ b/TalerWallet1/Model/Transaction.swift
@@ -150,6 +150,7 @@ struct TransactionCommon: Decodable, Sendable {
var transactionId: String
var timestamp: Timestamp
var txActions: [TxAction]
+ var kycUrl: String?
func localizedType(_ type: TransactionType) -> String {
switch type {
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
index 56b166e..0edd3ef 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -89,6 +89,19 @@ extension MainView {
let settingsTitle = String(localized: "TitleSettings", defaultValue: "Settings")
#if TABBAR // Taler Wallet
@State private var selectedTab: Tab = .balances
+ @State private var showKycAlert: Bool = false
+
+ private var openKycButton: some View {
+ Button("KYC") {
+ showKycAlert = false
+// UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
+ }
+ }
+ private var dismissAlertButton: some View {
+ Button("Cancel", role: .cancel) {
+ showKycAlert = false
+ }
+ }
private func tabSelection() -> Binding<Tab> {
Binding { //this is the get block
@@ -220,7 +233,27 @@ extension MainView {
hamburgerAction: hamburgerAction)
}
#endif
- }
+ } .onNotification(.TransactionStateTransition) { 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
+ }
+ }
+ }
+ } else { // should never happen
+ logger.error("Yikes! TransactionStateTransition without transition")
+// symLog.log(notification.userInfo as Any)
+ }
+ }
+ .alert("You need to pass a KYC procedure",
+ isPresented: $showKycAlert,
+ actions: { openKycButton
+ dismissAlertButton },
+ message: { Text("Tap the button to go to the KYC website.") })
.onNotification(.BalanceChange) { notification in
// reload balances on receiving BalanceChange notification ...
logger.info(".onNotification(.BalanceChange) ==> reload")