gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 35/36: Check Available, accessibility


From: gnunet
Subject: [taler-taler-ios] 35/36: Check Available, accessibility
Date: Mon, 13 Nov 2023 21:27:40 +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 a286bb937968041cf91d777e76354a1e75144bdf
Author: Marc Stibane <marc@taler.net>
AuthorDate: Mon Nov 13 21:12:55 2023 +0100

    Check Available, accessibility
---
 TalerWallet1/Views/Peer2peer/SendAmount.swift | 42 ++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift 
b/TalerWallet1/Views/Peer2peer/SendAmount.swift
index f9d58ee..7437004 100644
--- a/TalerWallet1/Views/Peer2peer/SendAmount.swift
+++ b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -21,17 +21,21 @@ struct SendAmount: View {
 
     @State var peerPushCheck: CheckPeerPushDebitResponse? = nil
     @State private var expireDays: UInt = SEVENDAYS
+    @State private var insufficient: Bool = false
+    @State private var fee: String = ""
 
-    private func fee(ppCheck: CheckPeerPushDebitResponse?) -> String {
+    private func fee(ppCheck: CheckPeerPushDebitResponse?) -> Amount? {
         do {
             if let ppCheck {
                 // Outgoing: fee = effective - raw
                 let fee = try ppCheck.amountEffective - ppCheck.amountRaw
-                return fee.readableDescription
+                return fee
             }
         } catch {}
-        return ""
+        return nil
     }
+    
+    var feeLabel: String { String(localized: " + \(fee) payment fee") }
 
     var body: some View {
 #if DEBUG
@@ -39,25 +43,29 @@ struct SendAmount: View {
         let _ = symLog.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
 #endif
         let currency = amountAvailable.currencyStr
+        let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
         let navTitle = String(localized: "Send \(currency)", comment: "Send 
currency, Dialog Title")
-        let fee = fee(ppCheck: peerPushCheck)
+        let available = amountAvailable.string(currencyInfo)
+        let current = amountToTransfer.string(currencyInfo)
+        let insufficientLabel = String(localized: "You don't have enough 
\(currency).")
+        let insufficientLabel2 = String(localized: "but you only have 
\(available) to send.")
         ScrollView {
             VStack(alignment: .trailing) {
-                let available = amountAvailable.readableDescription // TODO: 
formatter
-                Text("Available: \(available)")
+//                let _ = print("available: \(available)")
+                Text("Available:\t\(available)")
                     .accessibilityFont(.title3)
                     .padding(.bottom, 2)
                 CurrencyInputView(amount: $amountToTransfer,
                                    title: iconOnly ? String(localized: "How 
much:")
                                                    : String(localized: "Amount 
to send:"),
                            shortcutLabel: String(localized: "Send", comment: 
"VoiceOver: Send $50,$25,$10,$5 shortcut buttons"))
-                Text("+ \(fee) payment fee")
+                let disabled = insufficient || amountToTransfer.isZero
+                Text(insufficient ? insufficientLabel
+                                  : feeLabel)
                     .accessibilityFont(.body)
                     .foregroundColor(.red)
                     .padding(4)
 
-                let disabled = amountToTransfer.isZero    // TODO: check 
amountAvailable
-
                 NavigationLink(destination: LazyView {
                     SendPurpose(stack: stack.push(),
                       amountAvailable: amountAvailable,
@@ -84,12 +92,26 @@ struct SendAmount: View {
             symLog.log("❗️Yikes SendAmount onDisappear")
         }
         .task(id: amountToTransfer.value) {
-            if !amountToTransfer.isZero {
+            do {
+                insufficient = try amountToTransfer > amountAvailable
+                print("current: \(current)")
+            } catch {
+                print("Yikes❗️ insufficient failed❗️")
+                insufficient = true
+            }
+
+            if insufficient {
+                announce(this: "\(current), \(insufficientLabel2)")
+            } else if !amountToTransfer.isZero {
                 do {
                     let ppCheck = try await 
model.checkPeerPushDebitM(amountToTransfer)
                     peerPushCheck = ppCheck
                 // TODO: set from exchange
 //                agePicker.setAges(ages: peerPushCheck?.ageRestrictionOptions)
+                    if let feeAmount = fee(ppCheck: peerPushCheck) {
+                        fee = feeAmount.string(currencyInfo)
+                    } else { fee = "" }
+                    announce(this: "\(current), \(feeLabel)")
                 } catch {    // TODO: error
                     symLog.log(error.localizedDescription)
                     peerPushCheck = 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]