[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.
- [taler-taler-ios] 64/204: shortcuts, prep for amountLastUsed, (continued)
- [taler-taler-ios] 64/204: shortcuts, prep for amountLastUsed, gnunet, 2024/12/05
- [taler-taler-ios] 67/204: Simplify, gnunet, 2024/12/05
- [taler-taler-ios] 68/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 72/204: cleanup currencyInfo, gnunet, 2024/12/05
- [taler-taler-ios] 84/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 53/204: DualHeightSheet, gnunet, 2024/12/05
- [taler-taler-ios] 71/204: pickerStyle, gnunet, 2024/12/05
- [taler-taler-ios] 70/204: Reorg, gnunet, 2024/12/05
- [taler-taler-ios] 69/204: Reorg, gnunet, 2024/12/05
- [taler-taler-ios] 73/204: Published balances, gnunet, 2024/12/05
- [taler-taler-ios] 78/204: use info(for:scope),
gnunet <=
- [taler-taler-ios] 85/204: ScopePicker, gnunet, 2024/12/05
- [taler-taler-ios] 87/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 77/204: info2, gnunet, 2024/12/05
- [taler-taler-ios] 75/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 80/204: scope from balance, gnunet, 2024/12/05
- [taler-taler-ios] 79/204: -Binding, gnunet, 2024/12/05
- [taler-taler-ios] 81/204: iterate over balances, gnunet, 2024/12/05
- [taler-taler-ios] 82/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 90/204: Onboarding, gnunet, 2024/12/05
- [taler-taler-ios] 100/204: Minimalistic date, gnunet, 2024/12/05