commit 5737152e074c7623193d20a2d5d9a240b5479f0d
parent 3677bcfa601ba4fef47fb6318559e2568367ff24
Author: Marc Stibane <marc@taler.net>
Date: Thu, 8 Aug 2024 20:55:46 +0200
currencySymbol
Diffstat:
9 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -47,6 +47,7 @@ struct BalancesSectionView {
@State private var pendingTransactions: [Transaction] = []
@State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
@State private var currencyName: String = UNKNOWN
+ @State private var currencySymbol: String = UNKNOWN
// @State private var buttonSelected: Int? = nil
private static func className() -> String {"\(self)"}
@@ -168,13 +169,17 @@ extension BalancesSectionView: View {
amountToTransfer: $amountToTransfer) // does still have the wrong currency
} header: {
- BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, currencyName: currencyName,
- shouldReloadBalances: $shouldReloadBalances)
+ BarGraphHeader(stack: stack.push(),
+ scopeInfo: scopeInfo,
+ currencyName: $currencyName,
+ currencySymbol: $currencySymbol,
+ shouldReloadBalances: $shouldReloadBalances)
}.id(sectionID)
.listRowSeparator(.hidden)
.task(id: controller.currencyTicker) {
currencyInfo = controller.info(for: currency, controller.currencyTicker)
currencyName = currencyInfo.scope.currency
+ currencySymbol = currencyInfo.altUnitSymbol ?? currencyName
}
.task(id: shouldReloadBalances + 1_000_000) {
// if shownSectionID != sectionID {
diff --git a/TalerWallet1/Views/Banking/DepositAmountV.swift b/TalerWallet1/Views/Banking/DepositAmountV.swift
@@ -90,7 +90,7 @@ struct DepositAmountV: View {
} else {
let currency = amountToTransfer.currencyStr
- let currencySymbol = currencyInfo.specs.altUnitNames?[0] ?? currencyInfo.specs.name
+ let currencySymbol = currencyInfo.altUnitSymbol ?? currencyInfo.specs.name
let navTitle = String(localized: "NavTitle_Deposit_Currency",
defaultValue: "Deposit \(currencySymbol)",
comment: "NavTitle: Deposit 'currencySymbol'")
diff --git a/TalerWallet1/Views/Banking/DepositIbanV.swift b/TalerWallet1/Views/Banking/DepositIbanV.swift
@@ -40,10 +40,13 @@ struct DepositIbanV: View {
return String(localized: "Deposit \(amountWithCurrency)", comment: "amount with currency")
}
- private func subjectTitle(_ amount: Amount) -> String {
-// let amountStr = amount.formatted(currencyInfo, isNegative: true)
+ private var subjectTitle: String {
+// let currencyName = currencyInfo.scope.currency
+// let currencySymbol = currencyInfo.altUnitSymbol ?? currencyName
return String(localized: "NavTitle_Deposit_AmountStr",
- defaultValue: "Deposit", comment: "NavTitle: Deposit")
+// defaultValue: "Deposit \(currencySymbol)",
+ defaultValue: "Deposit IBAN",
+ comment: "NavTitle: Deposit")
// defaultValue: "Deposit \(amountStr)", comment: "NavTitle: Deposit 'amountStr'")
}
@@ -120,7 +123,7 @@ struct DepositIbanV: View {
.accessibilityHint(disabled ? String(localized: "enabled when account holder and IBAN are set") : EMPTYSTRING)
}.padding(.horizontal) } // ScrollVStack
// .scrollBounceBehavior(.basedOnSize) needs iOS 16.4
- .navigationTitle(subjectTitle(amountToTransfer))
+ .navigationTitle(subjectTitle)
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
.onAppear {
DebugViewC.shared.setViewID(VIEW_DEPOSIT_ACCEPT, stack: stack.push())
diff --git a/TalerWallet1/Views/Banking/ExchangeSectionView.swift b/TalerWallet1/Views/Banking/ExchangeSectionView.swift
@@ -22,6 +22,7 @@ struct ExchangeSectionView: View {
@State private var shouldReloadBalances: Int = 0
@State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
@State private var currencyName: String = UNKNOWN
+ @State private var currencySymbol: String = UNKNOWN
func amountAvailable(_ exchange: Exchange?, currency: String?) -> Amount? {
if let exchange {
@@ -76,12 +77,16 @@ struct ExchangeSectionView: View {
.padding(.top)
}
} header: {
- BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, currencyName: currencyName,
- shouldReloadBalances: $shouldReloadBalances)
+ BarGraphHeader(stack: stack.push(),
+ scopeInfo: scopeInfo,
+ currencyName: $currencyName,
+ currencySymbol: $currencySymbol,
+ shouldReloadBalances: $shouldReloadBalances)
}
.task(id: controller.currencyTicker) {
currencyInfo = controller.info(for: currency, controller.currencyTicker)
currencyName = currencyInfo.scope.currency
+ currencySymbol = currencyInfo.altUnitSymbol ?? currencyName
}
}
}
diff --git a/TalerWallet1/Views/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Banking/ManualWithdraw.swift
@@ -44,7 +44,7 @@ struct ManualWithdraw: View {
let currency = scopeInfo.currency
let currencyInfo = controller.info(for: currency, controller.currencyTicker)
let currencyName = currencyInfo.scope.currency
- let currencySymbol = currencyInfo.specs.altUnitNames?[0] ?? currencyName
+ let currencySymbol = currencyInfo.altUnitSymbol ?? currencyName
let navTitle = String(localized: "NavTitle_Withdraw (currency)",
defaultValue: "Withdraw \(currencySymbol)",
diff --git a/TalerWallet1/Views/HelperViews/BarGraph.swift b/TalerWallet1/Views/HelperViews/BarGraph.swift
@@ -11,7 +11,8 @@ struct BarGraphHeader: View {
private let symLog = SymLogV(0)
let stack: CallStack
let scopeInfo: ScopeInfo?
- let currencyName: String
+ @Binding var currencyName: String
+ @Binding var currencySymbol: String
@Binding var shouldReloadBalances: Int
@EnvironmentObject private var model: WalletModel
@@ -25,7 +26,7 @@ struct BarGraphHeader: View {
var body: some View {
HStack (alignment: .center, spacing: 10) {
- if !minimalistic {
+ if !minimalistic || currencyName != currencySymbol {
Text(currencyName)
.talerFont(.title2)
.foregroundColor(WalletColors().secondary(colorScheme, colorSchemeContrast))
@@ -84,13 +85,13 @@ struct BarGraph: View {
let width = barHeight / 3
Rectangle()
.opacity(0.001)
- .frame (width: width, height: incoming ? valueTransparent : barHeight)
+ .frame(width: width, height: incoming ? valueTransparent : barHeight)
Rectangle()
.foregroundColor(incoming ? .green : .red)
- .frame (width: width, height: valueColored)
+ .frame(width: width, height: valueColored)
Rectangle()
.opacity(0.001)
- .frame (width: width, height: incoming ? barHeight : valueTransparent)
+ .frame(width: width, height: incoming ? barHeight : valueTransparent)
}
}
}
diff --git a/TalerWallet1/Views/Overview/OverviewSectionV.swift b/TalerWallet1/Views/Overview/OverviewSectionV.swift
@@ -41,6 +41,7 @@ struct OverviewSectionV {
@State private var pendingTransactions: [Transaction] = []
@State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
@State private var currencyName: String = UNKNOWN
+ @State private var currencySymbol: String = UNKNOWN
func reloadOneAction(_ transactionId: String, _ viewHandles: Bool) async throws -> Transaction {
return try await model.getTransactionByIdT(transactionId, viewHandles: viewHandles)
@@ -100,12 +101,16 @@ extension OverviewSectionV: View {
.padding(.leading, ICONLEADING)
}
} header: {
- BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, currencyName: currencyName,
- shouldReloadBalances: $shouldReloadBalances)
+ BarGraphHeader(stack: stack.push(),
+ scopeInfo: scopeInfo,
+ currencyName: $currencyName,
+ currencySymbol: $currencySymbol,
+ shouldReloadBalances: $shouldReloadBalances)
}.id(sectionID)
.task(id: controller.currencyTicker) {
currencyInfo = controller.info(for: currency, controller.currencyTicker)
currencyName = currencyInfo.scope.currency
+ currencySymbol = currencyInfo.altUnitSymbol ?? currencyName
}
.task(id: shouldReloadBalances + 1_000_000) {
// if shownSectionID != sectionID {
diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
@@ -98,7 +98,7 @@ struct RequestPayment: View {
#endif
let currency = amountToTransfer.currencyStr
// let currencyInfo = controller.info(for: currency, controller.currencyTicker)
- let currencySymbol = currencyInfo.specs.altUnitNames?[0] ?? currency
+ let currencySymbol = currencyInfo.altUnitSymbol ?? currency
let navTitle = String(localized: "NavTitle_Request_Currency",
defaultValue: "Request \(currencySymbol)",
comment: "NavTitle: Request 'currencySymbol'")
diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -105,7 +105,7 @@ struct SendAmount: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
- let currencySymbol = currencyInfo.specs.altUnitNames?[0] ?? currencyInfo.specs.name
+ let currencySymbol = currencyInfo.altUnitSymbol ?? currencyInfo.specs.name
let navTitle = String(localized: "NavTitle_Send_Currency",
defaultValue: "Send \(currencySymbol)",
comment: "NavTitle: Send 'currencySymbol'")