gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] branch master updated (63cd160 -> c38068b)


From: gnunet
Subject: [taler-taler-ios] branch master updated (63cd160 -> c38068b)
Date: Mon, 08 Apr 2024 16:11:33 +0200

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

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

    from 63cd160  Add Observability to LocalConsole
     new 158b189  errorColor
     new 3b03434  localizedRefreshReason
     new 0eb98d3  accessibility
     new d1d405c  includeRefreshes: developerMode
     new c38068b  details for refresh tx

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../Contents.json                                  |  17 +++-
 TalerWallet1/Helper/WalletColors.swift             |   3 +
 TalerWallet1/Model/Transaction.swift               |  36 ++++++-
 .../Views/Balances/BalancesSectionView.swift       |  11 ++-
 TalerWallet1/Views/HelperViews/AmountRowV.swift    |   1 +
 .../Views/Transactions/ThreeAmountsV.swift         |   3 -
 .../Views/Transactions/TransactionSummaryV.swift   | 109 +++++++++++++++------
 7 files changed, 140 insertions(+), 40 deletions(-)
 copy TalerWallet1/Assets.xcassets/{PendingOutgoing.colorset => 
Error.colorset}/Contents.json (54%)

diff --git 
a/TalerWallet1/Assets.xcassets/PendingOutgoing.colorset/Contents.json 
b/TalerWallet1/Assets.xcassets/Error.colorset/Contents.json
similarity index 54%
copy from TalerWallet1/Assets.xcassets/PendingOutgoing.colorset/Contents.json
copy to TalerWallet1/Assets.xcassets/Error.colorset/Contents.json
index c3393e1..b09073b 100644
--- a/TalerWallet1/Assets.xcassets/PendingOutgoing.colorset/Contents.json
+++ b/TalerWallet1/Assets.xcassets/Error.colorset/Contents.json
@@ -2,12 +2,12 @@
   "colors" : [
     {
       "color" : {
-        "color-space" : "srgb",
+        "color-space" : "display-p3",
         "components" : {
           "alpha" : "1.000",
-          "blue" : "0.001",
-          "green" : "0.031",
-          "red" : "0.343"
+          "blue" : "24",
+          "green" : "35",
+          "red" : "175"
         }
       },
       "idiom" : "universal"
@@ -19,6 +19,15 @@
           "value" : "dark"
         }
       ],
+      "color" : {
+        "color-space" : "display-p3",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "36",
+          "green" : "52",
+          "red" : "234"
+        }
+      },
       "idiom" : "universal"
     }
   ],
diff --git a/TalerWallet1/Helper/WalletColors.swift 
b/TalerWallet1/Helper/WalletColors.swift
index bb6b9ac..1f07652 100644
--- a/TalerWallet1/Helper/WalletColors.swift
+++ b/TalerWallet1/Helper/WalletColors.swift
@@ -64,6 +64,9 @@ public struct WalletColors {
         // used in TransactionRowView
         gray1
     }
+    func errorColor() -> Color {
+        Color("Error")
+    }
     func pendingColor(_ incoming: Bool) -> Color {
         incoming ? Color("PendingIncoming")
                  : Color("PendingOutgoing")
diff --git a/TalerWallet1/Model/Transaction.swift 
b/TalerWallet1/Model/Transaction.swift
index 7900180..dc2d7a6 100644
--- a/TalerWallet1/Model/Transaction.swift
+++ b/TalerWallet1/Model/Transaction.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import Foundation
 import AnyCodable
 import taler_swift
@@ -327,7 +330,7 @@ struct WithdrawalTransactionDetails: Decodable {
     var withdrawalDetails: WithdrawalDetails
 }
 
-struct WithdrawalTransaction : Sendable{
+struct WithdrawalTransaction : Sendable {
     var common: TransactionCommon
     var details: WithdrawalTransactionDetails
 }
@@ -402,6 +405,35 @@ enum RefreshReason: String, Decodable {
     case recoup
     case backupRestored = "backup-restored"
     case scheduled
+
+    var localizedRefreshReason: String {
+        switch self {
+            case .manual:               return String(localized: "Merchant",
+                                                      comment: "RefreshReason")
+            case .payMerchant:          return String(localized: "Merchant",
+                                                    comment: "RefreshReason")
+            case .payDeposit:           return String(localized: "Deposit",
+                                                  comment: "RefreshReason")
+            case .payPeerPush:          return String(localized: "Pay 
Peer-Push",
+                                                  comment: "RefreshReason")
+            case .payPeerPull:          return String(localized: "Pay 
Peer-Pull",
+                                                  comment: "RefreshReason")
+            case .refund:               return String(localized: "Refund",
+                                                  comment: "RefreshReason")
+            case .abortPay:             return String(localized: "Abort 
Payment",
+                                                  comment: "RefreshReason")
+            case .abortDeposit:         return String(localized: "Abort 
Deposit",
+                                                  comment: "RefreshReason")
+            case .abortPeerPushDebit:   return String(localized: "Abort P2P 
Send",
+                                                    comment: "RefreshReason")
+            case .recoup:           return String(localized: "Recoup",
+                                                  comment: "RefreshReason")
+            case .backupRestored:   return String(localized: "Backup restored",
+                                                  comment: "RefreshReason")
+            case .scheduled:        return String(localized: "Scheduled",
+                                                  comment: "RefreshReason")
+        }
+    }
 }
 struct RefreshError: Decodable {
     var code: Int
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift 
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index 03113c0..0d1a80a 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -27,6 +27,11 @@ struct BalancesSectionView {
     @Environment(\.colorScheme) private var colorScheme
     @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @EnvironmentObject private var controller: Controller
+#if DEBUG
+    @AppStorage("developerMode") var developerMode: Bool = true
+#else
+    @AppStorage("developerMode") var developerMode: Bool = false
+#endif
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
     @State private var showSpendingHint = true
@@ -43,12 +48,12 @@ struct BalancesSectionView {
     @State private var shownSectionID = UUID()  // guaranteed to be different 
the first time
 
     func reloadCompleted(_ stack: CallStack) async -> () {
-        transactions = await model.transactionsT(stack.push(), scopeInfo: 
balance.scopeInfo, includeRefreshes: true)
+        transactions = await model.transactionsT(stack.push(), scopeInfo: 
balance.scopeInfo, includeRefreshes: developerMode)
         completedTransactions = WalletModel.completedTransactions(transactions)
     }
 
     func reloadPending(_ stack: CallStack) async -> () {
-        transactions = await model.transactionsT(stack.push(), scopeInfo: 
balance.scopeInfo, includeRefreshes: true)
+        transactions = await model.transactionsT(stack.push(), scopeInfo: 
balance.scopeInfo, includeRefreshes: developerMode)
         pendingTransactions = WalletModel.pendingTransactions(transactions)
     }
 }
@@ -123,7 +128,7 @@ extension BalancesSectionView: View {
 //            if shownSectionID != sectionID {
                 symLog.log(".task for BalancesSectionView - reload 
Transactions")
             // TODO: only load the MAXRECENT most recent transactions
-            let response = await model.transactionsT(stack.push(".task - 
reload Transactions"), scopeInfo: scopeInfo, includeRefreshes: true)
+            let response = await model.transactionsT(stack.push(".task - 
reload Transactions"), scopeInfo: scopeInfo, includeRefreshes: developerMode)
                 transactions = response
                 pendingTransactions = WalletModel.pendingTransactions(response)
                 completedTransactions = 
WalletModel.completedTransactions(response)
diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift 
b/TalerWallet1/Views/HelperViews/AmountRowV.swift
index 5655ce5..4f30d9f 100644
--- a/TalerWallet1/Views/HelperViews/AmountRowV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift
@@ -47,6 +47,7 @@ struct AmountRowV: View {
             }
         }
             .frame(maxWidth: .infinity, alignment: .leading)
+            .accessibilityElement(children: .combine)
             .listRowSeparator(.hidden)
     }
 }
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift 
b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
index 6e61e21..f67966f 100644
--- a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
+++ b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
@@ -91,7 +91,6 @@ struct ThreeAmountsV: View {
                        color: labelColor,
                        large: false)
                 .padding(.bottom, 4)
-                .accessibilityElement(children: .combine)
             if let fee {
                 AmountRowV(title: minimalistic ? String(localized: "Fee 
(short):", defaultValue:"Fee:", comment:"short version")
                                                : String(localized: "Fee 
(long):", defaultValue:"Fee:", comment:"long version"),
@@ -99,14 +98,12 @@ struct ThreeAmountsV: View {
                            color: labelColor,
                            large: false)
                 .padding(.bottom, 4)
-                .accessibilityElement(children: .combine)
             }
             if let bottomAmount {
                 AmountRowV(title: minimalistic ? bottomAbbrev : bottomTitle,
                           amount: bottomAmount,
                            color: foreColor,
                            large: large)
-                .accessibilityElement(children: .combine)
             }
             if let baseURL {
                 VStack(alignment: .leading) {
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift 
b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
index ccfb638..da7ce3c 100644
--- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
+++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -240,14 +240,55 @@ struct TransactionSummaryV: View {
         }
     }
 
+    struct PendingWithdrawalDetails: View {
+        @Binding var transaction: Transaction
+        let details: WithdrawalTransactionDetails
+
+        var body: some View {
+            let common = transaction.common
+            if transaction.isPendingKYC {
+                if let kycUrl = common.kycUrl {
+                    if let destination = URL(string: kycUrl) {
+                        KycButton(destination: destination)
+                    }
+                }
+            }
+            let withdrawalDetails = details.withdrawalDetails
+            switch withdrawalDetails.type {
+                case .manual:               // "Make a wire transfer of 
\(amount) to"
+                    ManualDetailsV(common: common, details: withdrawalDetails)
+
+                case .bankIntegrated:       // "Confirm now" (with bank)
+                    if !transaction.isPendingKYC {              // cannot 
confirm if KYC is needed first
+                        let confirmed = withdrawalDetails.confirmed ?? false
+                        if !confirmed {
+                            if let confirmationUrl = 
withdrawalDetails.bankConfirmationUrl {
+                                if let destination = URL(string: 
confirmationUrl) {
+                                    ConfirmationButton(destination: 
destination)
+                                }   }   }   }
+            } // switch
+        }
+    }
+
     struct TypeDetail: View {
         let stack: CallStack
         @Binding var transaction: Transaction
         let hasDone: Bool
         @Environment(\.colorScheme) private var colorScheme
         @Environment(\.colorSchemeContrast) private var colorSchemeContrast
+        @AppStorage("minimalistic") var minimalistic: Bool = false
         @State private var rotationEnabled = true
 
+        func refreshFee(input: Amount, output: Amount) -> Amount? {
+            do {
+                let fee = try input - output
+                return fee
+            } catch {
+                
+            }
+            return nil
+        }
+
         var body: some View {
             let common = transaction.common
             let pending = transaction.isPending
@@ -264,27 +305,7 @@ struct TransactionSummaryV: View {
                     case .withdrawal(let withdrawalTransaction): Group {
                         let details = withdrawalTransaction.details
                         if pending {
-                            if transaction.isPendingKYC {
-                                if let kycUrl = common.kycUrl {
-                                    if let destination = URL(string: kycUrl) {
-                                        KycButton(destination: destination)
-                                    }
-                                }
-                            }
-                            let withdrawalDetails = details.withdrawalDetails
-                            switch withdrawalDetails.type {
-                                case .manual:               // "Make a wire 
transfer of \(amount) to"
-                                    ManualDetailsV(common: common, details: 
withdrawalDetails)
-
-                                case .bankIntegrated:       // "Confirm now" 
(with bank)
-                                    if !transaction.isPendingKYC {             
 // cannot confirm if KYC is needed first
-                                        let confirmed = 
withdrawalDetails.confirmed ?? false
-                                        if !confirmed {
-                                            if let confirmationUrl = 
withdrawalDetails.bankConfirmationUrl {
-                                                if let destination = 
URL(string: confirmationUrl) {
-                                                    
ConfirmationButton(destination: destination)
-                                    }   }   }   }
-                            } // switch
+                            PendingWithdrawalDetails(transaction: 
$transaction, details: details)
                         } // ManualDetails or Confirm now (with bank)
                         ThreeAmountsSheet(stack: stack.push(),
                                           common: common, topAbbrev: 
String(localized: "Chosen:", comment: "mini"),
@@ -320,13 +341,45 @@ struct TransactionSummaryV: View {
                                         merchant: details.info?.merchant.name)
                     }
                     case .refresh(let refreshTransaction): Group {
-                        let details = refreshTransaction.details               
 // TODO: details
-                        Text(details.refreshReason.rawValue)
-                        ThreeAmountsSheet(stack: stack.push(),
-                                          common: common, topAbbrev: 
String(localized: "Refreshed:", comment: "mini"),
-                                        topTitle: String(localized: "Refreshed 
amount:"),
-                                         baseURL: nil, large: true,            
 // TODO: baseURL
-                                         summary: nil, merchant: nil)
+                        let labelColor = Color(UIColor.label)
+                        let errorColor = WalletColors().errorColor()
+                        let details = refreshTransaction.details
+                        Section {
+                            Text(details.refreshReason.localizedRefreshReason)
+                                .talerFont(.title)
+                            let input = details.refreshInputAmount
+                            AmountRowV(title: minimalistic ? "Refreshed:" : 
"Refreshed amount:",
+                                      amount: input,
+                                       color: labelColor,
+                                       large: true)
+                            if let fee = refreshFee(input: input, output: 
details.refreshOutputAmount) {
+                                AmountRowV(title: minimalistic ? "Fee:" : 
"Refreshed fee:",
+                                          amount: fee,
+                                           color: labelColor,
+                                           large: true)
+                            }
+                            if let error = details.error {
+                                HStack {
+                                    VStack(alignment: .leading) {
+                                        Text(error.hint)
+                                            .talerFont(.headline)
+                                            .foregroundColor(errorColor)
+                                            .listRowSeparator(.hidden)
+                                        if let stack = error.stack {
+                                            Text(stack)
+                                                .talerFont(.body)
+                                                .foregroundColor(errorColor)
+                                                .listRowSeparator(.hidden)
+                                        }
+                                    }
+                                    let stackStr = error.stack ?? EMPTYSTRING
+                                    let errorStr = error.hint + "\n" + stackStr
+                                    CopyButton(textToCopy: errorStr, vertical: 
true)
+                                        .accessibilityLabel("Copy the error")
+                                        .disabled(false)
+                                }
+                            }
+                        }
                     }
                     case .peer2peer(let p2pTransaction): Group {
                         let details = p2pTransaction.details

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