gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 01/20: Amounts can be with "-" or "+" sign, or without


From: gnunet
Subject: [taler-taler-ios] 01/20: Amounts can be with "-" or "+" sign, or without sign
Date: Fri, 02 Aug 2024 18:03:55 +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 487859dbe163fccd05edef6c0bcdcd917c4f0f81
Author: Marc Stibane <marc@taler.net>
AuthorDate: Mon Jul 29 21:01:56 2024 +0200

    Amounts can be with "-" or "+" sign, or without sign
---
 TalerWallet1/Views/HelperViews/AmountRowV.swift           |  2 +-
 TalerWallet1/Views/HelperViews/AmountV.swift              | 12 +++++++++---
 TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift  |  5 +++--
 .../Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift       |  5 +++--
 TalerWallet1/Views/Sheets/Payment/PaymentView.swift       | 10 ++++++----
 .../WithdrawBankIntegrated/WithdrawAcceptView.swift       |  2 +-
 TalerWallet1/Views/Transactions/ThreeAmountsSection.swift | 15 +++++++++------
 TalerWallet1/Views/Transactions/TransactionRowView.swift  |  5 +++--
 TalerWallet1/Views/Transactions/TransactionSummaryV.swift | 14 +++++++++++---
 9 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift 
b/TalerWallet1/Views/HelperViews/AmountRowV.swift
index 5149f6a..de10ee1 100644
--- a/TalerWallet1/Views/HelperViews/AmountRowV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift
@@ -14,7 +14,7 @@ struct AmountRowV: View {
     @Binding var currencyInfo: CurrencyInfo
     let title: String
     let amount: Amount
-    let isNegative: Bool        // if true, show a "-" before the amount
+    let isNegative: Bool?        // show fee with minus (or plus) sign, or no 
sign if nil
     let color: Color
     let large: Bool      // set to false for QR or IBAN
 
diff --git a/TalerWallet1/Views/HelperViews/AmountV.swift 
b/TalerWallet1/Views/HelperViews/AmountV.swift
index 274074d..e5ecafc 100644
--- a/TalerWallet1/Views/HelperViews/AmountV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountV.swift
@@ -12,13 +12,19 @@ struct AmountV: View {
     let stack: CallStack?
     @Binding var currencyInfo: CurrencyInfo
     let amount: Amount
-    let isNegative: Bool        // if true, show a "-" before the amount
+    let isNegative: Bool?        // if true, show a "-" before the amount
     let large: Bool             // set to false for QR or IBAN
 
     @EnvironmentObject private var controller: Controller
 
     var body: some View {
-        Text(amount.formatted(currencyInfo, isNegative: isNegative))
+        let dontShow = (isNegative == nil)
+        let showSign: Bool = isNegative ?? false
+        let amountFormatted = amount.formatted(currencyInfo, isNegative: false)
+        let amountStr = dontShow ?      amountFormatted
+                      : showSign ? "- \(amountFormatted)"
+                                 : "+ \(amountFormatted)"
+        Text(amountStr)
             .multilineTextAlignment(.center)
             .talerFont(large ? .title : .title2)
 //            .fontWeight(large ? .medium : .regular)       // @available(iOS 
16.0, *)
@@ -27,7 +33,7 @@ struct AmountV: View {
     }
 }
 extension AmountV {
-    init(_ currencyInfo: Binding<CurrencyInfo>, _ amount: Amount, isNegative: 
Bool) {
+    init(_ currencyInfo: Binding<CurrencyInfo>, _ amount: Amount, isNegative: 
Bool?) {
         self.stack = nil
         self._currencyInfo = currencyInfo
         self.amount = amount
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
index 82e948f..4ba8dbf 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
@@ -38,13 +38,14 @@ struct P2pPayURIView: View {
                                  currencyInfo: $currencyInfo,
                                      topTitle: String(localized: "Amount to 
pay:"),
                                     topAbbrev: String(localized: "Pay:", 
comment: "mini"),
-                                    topAmount: raw, fee: fee,
+                                    topAmount: raw,
+                                       noFees: nil,        // TODO: check 
baseURL for fees
+                                          fee: fee,
                                   bottomTitle: String(localized: "Amount to be 
spent:"),
                                  bottomAbbrev: String(localized: "Effective:", 
comment: "mini"),
                                  bottomAmount: effective,
                                         large: false, pending: false, 
incoming: false,
                                       baseURL: nil,
-                                       noFees: nil,        // TODO: check 
baseURL for fees
                                    txStateLcl: nil,
                                       summary: 
peerPullDebitResponse.contractTerms.summary,
                                      merchant: nil)
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
index a9d221b..24f8dd2 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
@@ -47,13 +47,14 @@ struct P2pReceiveURIView: View {
                                  currencyInfo: $currencyInfo,
                                      topTitle: String(localized: "Gross Amount 
to receive:"),
                                     topAbbrev: String(localized: "Receive 
gross:", comment: "mini"),
-                                    topAmount: raw, fee: fee,
+                                    topAmount: raw,
+                                       noFees: nil,        // TODO: check 
baseURL for fees
+                                          fee: fee,
                                   bottomTitle: String(localized: "Net Amount 
to receive:"),
                                  bottomAbbrev: String(localized: "Receive 
net:", comment: "mini"),
                                  bottomAmount: effective,
                                         large: false, pending: false, 
incoming: true,
                                       baseURL: nil,
-                                       noFees: nil,        // TODO: check 
baseURL for fees
                                    txStateLcl: nil,
                                       summary: 
peerPushCreditResponse.contractTerms.summary,
                                      merchant: nil)
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 994354b..a2b598a 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -108,7 +108,9 @@ struct PaymentView: View {
                                  currencyInfo: $currencyInfo,
                                      topTitle: topTitle,
                                     topAbbrev: topAbbrev,
-                                    topAmount: raw, fee: fee,
+                                    topAmount: raw,
+                                       noFees: nil,        // TODO: check 
baseURL for fees
+                                          fee: fee,
                                   bottomTitle: String(localized: "Amount to 
spend:"),
                                  bottomAbbrev: String(localized: "Effective:", 
comment: "mini"),
                                  bottomAmount: effective,
@@ -116,7 +118,6 @@ struct PaymentView: View {
                                       pending: false,
                                      incoming: false,
                                       baseURL: baseURL,
-                                       noFees: nil,        // TODO: check 
baseURL for fees
                                    txStateLcl: nil,
                                       summary: terms.summary,
                                      merchant: terms.merchant.name)
@@ -128,7 +129,9 @@ struct PaymentView: View {
                                  currencyInfo: $currencyInfo,
                                      topTitle: topTitle,
                                     topAbbrev: topAbbrev,
-                                    topAmount: raw, fee: nil,
+                                    topAmount: raw,
+                                       noFees: nil,        // TODO: check 
baseURL for fees
+                                          fee: nil,
                                   bottomTitle: String(localized: "Amount 
available:"),
                                  bottomAbbrev: String(localized: "Available:", 
comment: "mini"),
                                  bottomAmount: balanceDetails.balanceAvailable,
@@ -136,7 +139,6 @@ struct PaymentView: View {
                                       pending: false,
                                      incoming: false,
                                       baseURL: baseURL,
-                                       noFees: nil,        // TODO: check 
baseURL for fees
                                    txStateLcl: nil,
                                       summary: terms.summary,
                                      merchant: terms.merchant.name)
diff --git 
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift 
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
index 65277ca..8a2d408 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
@@ -60,6 +60,7 @@ struct WithdrawAcceptView: View {
                                      topTitle: String(localized: "Chosen 
amount to withdraw:"),
                                     topAbbrev: String(localized: "Withdraw:", 
comment: "Chosen amount to withdraw:"),
                                     topAmount: raw,
+                                       noFees: exchange.noFees,
                                           fee: fee,
                                   bottomTitle: String(localized: "Amount to 
obtain:"),
                                  bottomAbbrev: String(localized: "Obtain:", 
comment: "Amount to obtain:"),
@@ -68,7 +69,6 @@ struct WithdrawAcceptView: View {
                                       pending: false,
                                      incoming: true,
                                       baseURL: exchange.exchangeBaseUrl,
-                                       noFees: exchange.noFees,
                                    txStateLcl: nil,        // 
common.txState.major.localizedState
                                       summary: nil,
                                      merchant: nil)
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift 
b/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift
index a0c2182..2579fd8 100644
--- a/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift
+++ b/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift
@@ -8,7 +8,7 @@
 import SwiftUI
 import taler_swift
 
-struct ThreeAmountsSheet: View {
+struct ThreeAmountsSheet: View {    // should be in a separate file
     let stack: CallStack
     @Binding var currencyInfo: CurrencyInfo
     var common: TransactionCommon
@@ -18,6 +18,7 @@ struct ThreeAmountsSheet: View {
     var bottomAbbrev: String?
     let baseURL: String?
     let noFees: Bool?                       // true if exchange charges no 
fees at all
+    var feeIsNegative: Bool?                // show fee with minus (or plus) 
sign, or no sign if nil
     let large: Bool               // set to false for QR or IBAN
     let summary: String?
     let merchant: String?
@@ -53,7 +54,9 @@ struct ThreeAmountsSheet: View {
                          topTitle: topTitle,
                         topAbbrev: topAbbrev,
                         topAmount: raw,
+                           noFees: noFees,
                               fee: fee,
+                    feeIsNegative: feeIsNegative,
                       bottomTitle: bottomTitle ?? defaultBottomTitle,
                      bottomAbbrev: bottomAbbrev ?? defaultBottomAbbrev,
                      bottomAmount: incomplete ? nil : effective,
@@ -61,7 +64,6 @@ struct ThreeAmountsSheet: View {
                           pending: pending,
                          incoming: incoming,
                           baseURL: baseURL,
-                           noFees: noFees,
                        txStateLcl: txStateLcl,
                           summary: summary,
                          merchant: merchant)
@@ -74,7 +76,9 @@ struct ThreeAmountsSection: View {
     var topTitle: String
     var topAbbrev: String
     var topAmount: Amount
+    let noFees: Bool?                       // true if exchange charges no 
fees at all
     var fee: Amount?                        // nil = don't show fee line, zero 
= no fee for this tx
+    var feeIsNegative: Bool?                // show fee with minus (or plus) 
sign, or no sign if nil
     var bottomTitle: String
     var bottomAbbrev: String
     var bottomAmount: Amount?               // nil = incomplete (aborted, 
timed out)
@@ -82,7 +86,6 @@ struct ThreeAmountsSection: View {
     let pending: Bool
     let incoming: Bool
     let baseURL: String?
-    let noFees: Bool?                       // true if exchange charges no 
fees at all
     let txStateLcl: String?                 // localizedState
     let summary: String?
     let merchant: String?
@@ -113,7 +116,7 @@ struct ThreeAmountsSection: View {
                 currencyInfo: $currencyInfo,
                        title: minimalistic ? topAbbrev : topTitle,
                       amount: topAmount,
-                  isNegative: !incoming,
+                  isNegative: nil,
                        color: labelColor,
                        large: false)
                 .padding(.bottom, 4)
@@ -125,7 +128,7 @@ struct ThreeAmountsSection: View {
                         currencyInfo: $currencyInfo,
                                title: title,
                               amount: fee,
-                          isNegative: !incoming,
+                          isNegative: fee.isZero ? nil : feeIsNegative,
                                color: labelColor,
                                large: false)
                     .padding(.bottom, 4)
@@ -135,7 +138,7 @@ struct ThreeAmountsSection: View {
                         currencyInfo: $currencyInfo,
                                title: minimalistic ? bottomAbbrev : 
bottomTitle,
                               amount: bottomAmount,
-                          isNegative: !incoming,
+                          isNegative: nil,
                                color: foreColor,
                                large: large)
                 }
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift 
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index 714b110..e4c7c92 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -46,7 +46,8 @@ struct TransactionRowView: View {
                : colorScheme == .dark ? .secondary
                   : increasedContrast ? Color(.darkGray)
                                       : .secondary  // Color(.tertiaryLabel)
-        let refreshZero = common.type.isRefresh && 
common.amountEffective.isZero
+        let isZero = common.amountEffective.isZero
+        let refreshZero = common.type.isRefresh && isZero
         let foreColor = refreshZero ? textColor
                           : pending ? WalletColors().pendingColor(incoming)
                              : done ? WalletColors().transactionColor(incoming)
@@ -55,7 +56,7 @@ struct TransactionRowView: View {
         let iconBadge = TransactionIconBadge(type: common.type, foreColor: 
foreColor,
                                              done: done, incoming: incoming,
                                     shouldConfirm: shouldConfirm, needsKYC: 
needsKYC)
-        let amountV = AmountV($currencyInfo, common.amountEffective, 
isNegative: !incoming)
+        let amountV = AmountV($currencyInfo, common.amountEffective, 
isNegative: isZero ? nil : !incoming)
             .foregroundColor(foreColor)
 
         let topString = topString()
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift 
b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
index 64e07d7..5875a1b 100755
--- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
+++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -312,6 +312,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Chosen 
amount to withdraw:"),
                                         baseURL: details.exchangeBaseUrl,
                                          noFees: nil,               // TODO: 
noFees
+                                  feeIsNegative: true,
                                           large: false,
                                         summary: nil,
                                        merchant: nil)
@@ -325,6 +326,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Amount to 
deposit:"),
                                         baseURL: nil,               // TODO: 
baseURL
                                          noFees: nil,               // TODO: 
noFees
+                                  feeIsNegative: false,
                                           large: true,
                                         summary: nil,
                                        merchant: nil)
@@ -339,6 +341,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Price 
(net):"),
                                         baseURL: nil,               // TODO: 
baseURL
                                          noFees: nil,               // TODO: 
noFees
+                                  feeIsNegative: false,
                                           large: true,
                                         summary: details.info.summary,
                                        merchant: details.info.merchant.name)
@@ -352,6 +355,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Refunded 
amount:"),
                                         baseURL: nil,               // TODO: 
baseURL
                                          noFees: nil,               // TODO: 
noFees
+                                  feeIsNegative: true,
                                           large: true,
                                         summary: details.info?.summary,
                                        merchant: details.info?.merchant.name)
@@ -368,7 +372,7 @@ struct TransactionSummaryV: View {
                                 currencyInfo: $currencyInfo,
                                        title: minimalistic ? "Refreshed:" : 
"Refreshed amount:",
                                       amount: input,
-                                  isNegative: false,
+                                  isNegative: nil,
                                        color: labelColor,
                                        large: true)
                             if let fee = refreshFee(input: input, output: 
details.refreshOutputAmount) {
@@ -376,7 +380,7 @@ struct TransactionSummaryV: View {
                                     currencyInfo: $currencyInfo,
                                            title: minimalistic ? "Fee:" : 
"Refreshed fee:",
                                           amount: fee,
-                                      isNegative: !fee.isZero,
+                                      isNegative: fee.isZero ? nil : true,
                                            color: labelColor,
                                            large: true)
                             }
@@ -440,7 +444,9 @@ struct TransactionSummaryV: View {
                                          common: common,
                                       topAbbrev: localizedType + colon,
                                        topTitle: localizedType + colon,
-                                        baseURL: details.exchangeBaseUrl, 
noFees: nil,         // TODO: noFees
+                                        baseURL: details.exchangeBaseUrl,
+                                         noFees: nil,         // TODO: noFees
+                                  feeIsNegative: true,
                                           large: false,
                                         summary: details.info.summary,
                                        merchant: nil)
@@ -455,6 +461,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Recoup:"),
                                         baseURL: nil,
                                          noFees: nil,
+                                  feeIsNegative: nil,
                                           large: true,             // TODO: 
baseURL, noFees
                                         summary: nil,
                                        merchant: nil)
@@ -468,6 +475,7 @@ struct TransactionSummaryV: View {
                                        topTitle: String(localized: "Money 
lost:"),
                                         baseURL: details.exchangeBaseUrl,
                                          noFees: nil,
+                                  feeIsNegative: nil,
                                           large: true,             // TODO: 
baseURL, noFees
                                         summary: 
details.lossEventType.rawValue,
                                        merchant: nil)

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