gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 78/204: use info(for:scope)


From: gnunet
Subject: [taler-taler-ios] 78/204: use info(for:scope)
Date: Thu, 05 Dec 2024 23:50: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 5398fe5fcd944245c759282fd9ce220acadfb0f2
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Oct 19 15:13:45 2024 +0200

    use info(for:scope)
---
 TalerWallet1/Views/HelperViews/ScopePicker.swift | 32 ++++++++++++------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift 
b/TalerWallet1/Views/HelperViews/ScopePicker.swift
index 1ec2807..804b79c 100644
--- a/TalerWallet1/Views/HelperViews/ScopePicker.swift
+++ b/TalerWallet1/Views/HelperViews/ScopePicker.swift
@@ -6,18 +6,19 @@
  * @author Marc Stibane
  */
 import SwiftUI
+import taler_swift
 
-fileprivate func formattedAmount(_ balance: Balance) -> String {
+fileprivate func formattedAmount(_ balance: Balance, _ currencyInfo: 
CurrencyInfo) -> String {
     let amount = balance.available
-    return amount.formatted(isNegative: false, useISO: false)
+    return amount.formatted(currencyInfo, isNegative: false, useISO: false)
 }
 
 fileprivate func urlOrCurrency(_ balance: Balance) -> String {
     balance.scopeInfo.url?.trimURL ?? balance.scopeInfo.currency
 }
 
-fileprivate func pickerRow(_ balance: Balance) -> String {
-    String("\(urlOrCurrency(balance)):\t\(formattedAmount(balance).nbs)")
+fileprivate func pickerRow(_ balance: Balance, _ currencyInfo: CurrencyInfo) 
-> String {
+    String("\(urlOrCurrency(balance)):\t\(formattedAmount(balance, 
currencyInfo).nbs)")
 }
 
 struct ScopePicker: View {
@@ -37,8 +38,9 @@ struct ScopePicker: View {
         let count = controller.balances.count
         if (count > 0) {
             let balance = controller.balances[selected]
+            let currencyInfo = controller.info(for: balance.scopeInfo, 
controller.currencyTicker)
             let available = balance.available
-            let availableA11y = available.formatted(isNegative: false, useISO: 
true, a11y: ".")
+            let availableA11y = available.formatted(currencyInfo, isNegative: 
false, useISO: true, a11y: ".")
             let url = balance.scopeInfo.url?.trimURL ?? EMPTYSTRING
             let a11yLabel = url + ", " + availableA11y
 
@@ -56,7 +58,8 @@ struct ScopePicker: View {
                     Picker(EMPTYSTRING, selection: $selected) {
                         ForEach(0..<controller.balances.count, id: \.self) { 
index in
                             let balance = controller.balances[index]
-                            Text(pickerRow(balance))
+                            let currencyInfo = controller.info(for: 
balance.scopeInfo, controller.currencyTicker)
+                            Text(pickerRow(balance, currencyInfo))
                                 .tag(index)
 //                              .selectionDisabled(balance.available.isZero)   
 needs iOS 17
                         }
@@ -101,17 +104,17 @@ struct  ScopeDropDown: View {
     }
 
     @ViewBuilder
-    func dropDownRow(_ balance: Balance) -> some View {
+    func dropDownRow(_ balance: Balance, _ currencyInfo: CurrencyInfo) -> some 
View {
         let hLayout = HStack(alignment: .top) {
             Text(urlOrCurrency(balance))
             Spacer()
-            Text(formattedAmount(balance).nbs)
+            Text(formattedAmount(balance, currencyInfo).nbs)
         }
         let vLayout = VStack(alignment: .leading) {
             Text(urlOrCurrency(balance))
             HStack {
                 Spacer()
-                Text(formattedAmount(balance).nbs)
+                Text(formattedAmount(balance, currencyInfo).nbs)
                 Spacer()
             }
         }
@@ -138,8 +141,9 @@ struct  ScopeDropDown: View {
                             selection = controller.balances.firstIndex(of: 
item) ?? selection
                         }
                     }, label: {
+                        let currencyInfo = controller.info(for: 
item.scopeInfo, controller.currencyTicker)
                         HStack(alignment: .top) {
-                            dropDownRow(item)   // .border(.random)
+                            dropDownRow(item, currencyInfo)   // 
.border(.random)
                                 .foregroundColor(rowDisabled ? .secondary : 
.primary)
                             Spacer()
                             chevron.foregroundColor(.clear)
@@ -156,9 +160,10 @@ struct  ScopeDropDown: View {
             VStack {
                 // selected item
                 let balance = controller.balances[selection]
+                let currencyInfo = controller.info(for: balance.scopeInfo, 
controller.currencyTicker)
                 Button(action: buttonAction) {
                     HStack(alignment: .firstTextBaseline) {
-                        dropDownRow(balance)
+                        dropDownRow(balance, currencyInfo)
                             .accessibilityAddTraits(.isSelected)
                         Spacer()
                         if !disabled {
@@ -202,8 +207,3 @@ struct  ScopeDropDown: View {
         .zIndex(100)
     }
 }
-
-// MARK: -
-//#Preview {
-//    ScopePicker()
-//}

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