gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 03/12: string(_ currencyInfo: CurrencyInfo?)


From: gnunet
Subject: [taler-taler-ios] 03/12: string(_ currencyInfo: CurrencyInfo?)
Date: Tue, 31 Oct 2023 08:53:00 +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 262d4d194e09f7e1cd72437d13b486928d3e9e1e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Oct 29 15:16:01 2023 +0100

    string(_ currencyInfo: CurrencyInfo?)
---
 TalerWallet1/Helper/CurrencySpecification.swift  | 10 ++++++++++
 TalerWallet1/Views/Balances/BalanceRowView.swift |  8 ++++----
 TalerWallet1/Views/Balances/PendingRowView.swift | 10 ++--------
 TalerWallet1/Views/HelperViews/AmountRowV.swift  |  4 ++--
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/TalerWallet1/Helper/CurrencySpecification.swift 
b/TalerWallet1/Helper/CurrencySpecification.swift
index 9adff4b..63988e3 100644
--- a/TalerWallet1/Helper/CurrencySpecification.swift
+++ b/TalerWallet1/Helper/CurrencySpecification.swift
@@ -5,6 +5,16 @@
 import Foundation
 import taler_swift
 
+extension Amount {
+    func string(_ currencyInfo: CurrencyInfo?) -> String {
+        if let currencyInfo {
+            return currencyInfo.string(for: valueAsTuple)
+        } else {
+            return valueStr
+        }
+    }
+}
+
 public struct CurrencyInfo {
     let scope: ScopeInfo
     let specs: CurrencySpecification
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift 
b/TalerWallet1/Views/Balances/BalanceRowView.swift
index a1d2425..9c36bbd 100644
--- a/TalerWallet1/Views/Balances/BalanceRowView.swift
+++ b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -57,8 +57,8 @@ struct BalanceRowView: View {
         let correctForSize = Self.correctForSize(sizeCategory)
         SingleAxisGeometryReader { width in
             VStack (alignment: .trailing) {
-                let amountStr = currencyInfo?.string(for: amount.valueAsTuple)
-                BalanceButton(amountStr: amountStr ?? amount.valueStr,
+                let amountStr = amount.string(currencyInfo)
+                BalanceButton(amountStr: amountStr,
                               sizeCategory: sizeCategory,
                               rowAction: rowAction)
                 let uiFont = TalerFont.uiFont(.title3)
@@ -88,8 +88,8 @@ struct SomeBalanceRows: View {
         let demoInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 2)
         let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
         let demo = try! Amount(fromString: DEMOCURRENCY + ":123.12")
-        let testStr = testInfo.string(for: test.valueAsTuple)
-        let demoStr = demoInfo.string(for: demo.valueAsTuple)
+//        let testStr = test.string(testInfo)
+//        let demoStr = demo.string(demoInfo)
 
         List {
             Section {
diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift 
b/TalerWallet1/Views/Balances/PendingRowView.swift
index 111fea2..b73f85d 100644
--- a/TalerWallet1/Views/Balances/PendingRowView.swift
+++ b/TalerWallet1/Views/Balances/PendingRowView.swift
@@ -45,14 +45,8 @@ struct PendingAmountView: View {
     let currencyInfo: CurrencyInfo?
     let incoming: Bool
 
-    public static func amountStr(amount: Amount, currencyInfo: CurrencyInfo?, 
incoming: Bool) -> String {
-//        let sign = incoming ? "+ " : "- "
-        let amountStr = currencyInfo?.string(for: amount.valueAsTuple)
-        return /*sign +*/ (amountStr ?? amount.valueStr)
-    }
-    
     public static func width(amount: Amount, currencyInfo: CurrencyInfo?, 
incoming: Bool) -> CGFloat {
-        let valueStr = Self.amountStr(amount: amount, currencyInfo: 
currencyInfo, incoming: incoming)
+        let valueStr = amount.string(currencyInfo)
         let uiFont = TalerFont.uiFont(.title)
         let width = valueStr.widthOfString(usingUIFont: uiFont)
 //    print("Amount width: ", width)
@@ -61,7 +55,7 @@ struct PendingAmountView: View {
 
     var body: some View {
         let pendingColor = WalletColors().pendingColor(incoming)
-        let valueStr = Self.amountStr(amount: amount, currencyInfo: 
currencyInfo, incoming: incoming)
+        let valueStr = amount.string(currencyInfo)
         Text(valueStr)
             .foregroundColor(pendingColor)
             .accessibilityFont(.title)
diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift 
b/TalerWallet1/Views/HelperViews/AmountRowV.swift
index 36ae4e0..f3307af 100644
--- a/TalerWallet1/Views/HelperViews/AmountRowV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift
@@ -49,8 +49,8 @@ struct SectionWithAmountRow: View {
         let demoInfo = PreviewCurrencyInfo(DEMOCURRENCY, digits: 2)
         let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
         let demo = try! Amount(fromString: DEMOCURRENCY + ":1234.12")
-        let testStr = testInfo.string(for: test.valueAsTuple)
-        let demoStr = demoInfo.string(for: demo.valueAsTuple)
+        let testStr = test.string(testInfo)
+        let demoStr = demo.string(demoInfo)
         List {
             Section {
                 AmountRowV(amountStr: demoStr, largeAmountFont: true, 
fitsHorizontal: true) {

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