gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 22/30: DD51 for fee


From: gnunet
Subject: [taler-taler-ios] 22/30: DD51 for fee
Date: Sun, 19 Nov 2023 23:53:46 +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 c0cf8461feaf8cb84d0686f1d72617ebb40e73f9
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Nov 19 13:48:50 2023 +0100

    DD51 for fee
---
 TalerWallet1/Views/Exchange/ManualWithdraw.swift   |  3 ++
 TalerWallet1/Views/Exchange/QuiteSomeCoins.swift   | 34 ++++++++++++----------
 TalerWallet1/Views/Peer2peer/RequestPayment.swift  |  9 ++++--
 TalerWallet1/Views/Peer2peer/RequestPurpose.swift  |  9 ++++--
 .../WithdrawBankIntegrated/WithdrawURIView.swift   | 14 ++++-----
 5 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift 
b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
index 7071931..b1e4bd5 100644
--- a/TalerWallet1/Views/Exchange/ManualWithdraw.swift
+++ b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
@@ -14,6 +14,7 @@ struct ManualWithdraw: View {
     let exchange: Exchange
     @Binding var amountToTransfer: Amount
 
+    @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
     @AppStorage("iconOnly") var iconOnly: Bool = false
 
@@ -27,6 +28,7 @@ struct ManualWithdraw: View {
         let _ = symLog.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
 #endif
         let currency = exchange.scopeInfo?.currency ?? exchange.currency ?? 
String(localized: "Unknown", comment: "unknown currency")
+        let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
         let navTitle = String(localized: "NavTitle_Withdraw (currency)", 
defaultValue: "Withdraw \(currency)")
 //        let agePicker = AgePicker(ageMenuList: $ageMenuList, selectedAge: 
$selectedAge)
 
@@ -40,6 +42,7 @@ struct ManualWithdraw: View {
                 QuiteSomeCoins(someCoins: someCoins,
                            shouldShowFee: true,           // TODO: set to 
false if we never charge withdrawal fees
                                 currency: currency,
+                            currencyInfo: currencyInfo,
                          amountEffective: 
withdrawalAmountDetails?.amountEffective)
                 Text(exchange.exchangeBaseUrl.trimURL())
                     .multilineTextAlignment(.center)
diff --git a/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift 
b/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift
index f1e5589..a0376f2 100644
--- a/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift
+++ b/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift
@@ -14,8 +14,7 @@ struct SomeCoins {
     var quiteSome: Bool { numCoins > 199 }
     var tooMany:   Bool { numCoins > 999 }
 
-    let fee: String
-    var hasFee:    Bool { fee.count > 0 }
+    let fee: Amount?
 }
 
 extension SomeCoins {
@@ -23,26 +22,26 @@ extension SomeCoins {
         do {
             if let details {
                 // Incoming: fee = raw - effective
-                let fee = try details.amountRaw - details.amountEffective
+                let aFee = try details.amountRaw - details.amountEffective
                 self.init(numCoins: details.numCoins ?? -1,    // either the 
number of coins, or unknown
-                               fee: fee.isZero ? "" : fee.readableDescription)
+                               fee: aFee)
                 return
             }
         } catch {}
-        self.init(numCoins: 0, fee:"")      // invalid
+        self.init(numCoins: 0, fee: nil)      // invalid
     }
 
     init(details: CheckPeerPullCreditResponse?) {
         do {
             if let details {
                 // Incoming: fee = raw - effective
-                let fee = try details.amountRaw - details.amountEffective
+                let aFee = try details.amountRaw - details.amountEffective
                 self.init(numCoins: details.numCoins ?? -1,    // either the 
number of coins, or unknown
-                               fee: fee.isZero ? "" : fee.readableDescription)
+                               fee: aFee)
                 return
             }
         } catch {}
-        self.init(numCoins: 0, fee:"")      // invalid
+        self.init(numCoins: 0, fee: nil)      // invalid
     }
 }
 // MARK: -
@@ -51,6 +50,7 @@ struct QuiteSomeCoins: View {
     let someCoins: SomeCoins
     let shouldShowFee: Bool
     let currency: String
+    let currencyInfo: CurrencyInfo?
     let amountEffective: Amount?
 
     var body: some View {
@@ -67,22 +67,24 @@ struct QuiteSomeCoins: View {
             }
         }
         if shouldShowFee {
-            Text(someCoins.invalid ? "Amount too small!"
-               : someCoins.tooMany ? "Amount too big for a single withdrawal!"
-                : someCoins.hasFee ? "- \(someCoins.fee) fee"
-                                   : "No withdrawal fee")
-            .foregroundColor((someCoins.invalid || someCoins.tooMany || 
someCoins.hasFee) ? .red : .primary)
-            .accessibilityFont(.body)
-//            .padding(4)
+            if let fee = someCoins.fee {
+                Text(someCoins.invalid ? "Amount too small!"
+                   : someCoins.tooMany ? "Amount too big for a single 
withdrawal!"
+                          : fee.isZero ? "No withdrawal fee"
+                                       : "- \(fee.string(currencyInfo)) fee")
+                .foregroundColor((someCoins.invalid || someCoins.tooMany || 
!fee.isZero) ? .red : .primary)
+                .accessibilityFont(.body)
+            }
         }
     }
 }
 // MARK: -
 struct QuiteSomeCoins_Previews: PreviewProvider {
     static var previews: some View {
-        QuiteSomeCoins(someCoins: SomeCoins(numCoins: 4, fee: "20 " + 
LONGCURRENCY),
+        QuiteSomeCoins(someCoins: SomeCoins(numCoins: 4, fee: Amount(currency: 
LONGCURRENCY, cent: 20) ),
                    shouldShowFee: true,
                         currency: LONGCURRENCY,
+                    currencyInfo: nil,
                  amountEffective: nil)
     }
 }
diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift 
b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
index deed5dc..1440e90 100644
--- a/TalerWallet1/Views/Peer2peer/RequestPayment.swift
+++ b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
@@ -14,6 +14,7 @@ struct RequestPayment: View {
     @Binding var amountToTransfer: Amount
     @Binding var summary: String
 
+    @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
     @AppStorage("iconOnly") var iconOnly: Bool = false
 
@@ -26,18 +27,20 @@ struct RequestPayment: View {
         let _ = symLog.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
 #endif
         let currency = amountToTransfer.currencyStr
-        let navTitle = String(localized: "Request Money", comment: "Dialog 
Title")
+        let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
+        let navTitle = String(localized: "Request \(currency)", comment: 
"Dialog Title")
 
-        ScrollView { VStack {
+        ScrollView { VStack(alignment: .trailing) {
             CurrencyInputView(amount: $amountToTransfer,
                            available: nil,
                                title: iconOnly ? String(localized: "How much:")
                                                : String(localized: "Amount to 
request:"))
-
+            .padding(.top)
             let someCoins = SomeCoins(details: peerPullCheck)
             QuiteSomeCoins(someCoins: someCoins,
                        shouldShowFee: true,     // always true since the 
requester pays fees
                             currency: currency,
+                        currencyInfo: currencyInfo,
                      amountEffective: peerPullCheck?.amountEffective)
 
             let disabled = amountToTransfer.isZero || someCoins.invalid || 
someCoins.tooMany
diff --git a/TalerWallet1/Views/Peer2peer/RequestPurpose.swift 
b/TalerWallet1/Views/Peer2peer/RequestPurpose.swift
index 60572d4..352f2f7 100644
--- a/TalerWallet1/Views/Peer2peer/RequestPurpose.swift
+++ b/TalerWallet1/Views/Peer2peer/RequestPurpose.swift
@@ -11,7 +11,7 @@ struct RequestPurpose: View {
     let stack: CallStack
 
     let amountToTransfer: Amount
-    let fee: String
+    let fee: Amount?
     @Binding var summary: String
     @Binding var expireDays: UInt
 
@@ -27,8 +27,11 @@ struct RequestPurpose: View {
         let currencyInfo = controller.info(for: amountToTransfer.currencyStr, 
controller.currencyTicker)
         ScrollView { VStack (spacing: 6) {
             Text(amountToTransfer.string(currencyInfo))
-            Text("+ \(fee) payment fee")
-                .foregroundColor(.red)
+            if let fee {
+                let feeStr = fee.string(currencyInfo)
+                Text("+ \(feeStr) payment fee")
+                    .foregroundColor(.red)
+            }
             VStack(alignment: .leading, spacing: 6) {
                 if !iconOnly {
                     Text("Subject:")
diff --git 
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift 
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
index c3e5ca2..56773b4 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
@@ -17,6 +17,7 @@ struct WithdrawURIView: View {
     // the URL from the bank website
     let url: URL
 
+    @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
     @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 
@@ -32,6 +33,7 @@ struct WithdrawURIView: View {
                     let raw = withdrawalAmountDetails.amountRaw
                     let effective = withdrawalAmountDetails.amountEffective
                     let currency = raw.currencyStr
+                    let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
                     let fee = try! Amount.diff(raw, effective)
                     let outColor = WalletColors().transactionColor(false)
                     let inColor = WalletColors().transactionColor(true)
@@ -47,7 +49,8 @@ struct WithdrawURIView: View {
                     let someCoins = SomeCoins(details: withdrawalAmountDetails)
                     QuiteSomeCoins(someCoins: someCoins,
                                shouldShowFee: true,       // TODO: set to 
false if we never charge withdrawal fees
-                                    currency: raw.currencyStr,
+                                    currency: currency,
+                                currencyInfo: currencyInfo,
                              amountEffective: effective)
                 }
                 .listStyle(myListStyle.style).anyView
@@ -83,13 +86,10 @@ struct WithdrawURIView: View {
             do { // TODO: cancelled
                 symLog.log(".task")
                 let withdrawUriInfo = try await 
model.loadWithdrawalDetailsForUriM(url.absoluteString)
-                let amount = withdrawUriInfo.amount
-                if let baseURL = withdrawUriInfo.defaultExchangeBaseUrl {
-                    exchangeBaseUrl = baseURL
-                } else if let first = withdrawUriInfo.possibleExchanges.first {
-                    exchangeBaseUrl = first.exchangeBaseUrl
-                }
+                exchangeBaseUrl = withdrawUriInfo.defaultExchangeBaseUrl ??
+                                  
withdrawUriInfo.possibleExchanges.first?.exchangeBaseUrl
                 if let exchangeBaseUrl {
+                    let amount = withdrawUriInfo.amount
                     let details = try await 
model.loadWithdrawalDetailsForAmountM(exchangeBaseUrl, amount: amount)
                     withdrawalAmountDetails = details
 //                  agePicker.setAges(ages: details?.ageRestrictionOptions)

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