[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 84/204: cleanup
From: |
gnunet |
Subject: |
[taler-taler-ios] 84/204: cleanup |
Date: |
Thu, 05 Dec 2024 23:50:52 +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 f96ea13f3385933939c0fc08805dd5b680bcf70f
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Oct 19 17:41:19 2024 +0200
cleanup
---
.../Views/Actions/Peer2peer/SendAmountV.swift | 110 ++++++++++-----------
1 file changed, 55 insertions(+), 55 deletions(-)
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
index 9ee538f..b7cdf72 100644
--- a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
+++ b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
@@ -21,26 +21,31 @@ struct SendAmountV: View {
@State private var balanceIndex = 0
@State private var balance: Balance? = nil // nil only when balances
== []
+ @State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
- func firstNonZero() -> Balance? {
- for aBalance in controller.balances {
- if !aBalance.available.isZero {
- return aBalance
- }
- }
- return nil
+ func navTitle(_ currency: String, _ condition: Bool = false) -> String {
+ condition ? String(localized: "NavTitle_Send_Currency",
+ defaultValue: "Send \(currency)",
+ comment: "NavTitle: Send 'currency'")
+ : String(localized: "NavTitle_Send",
+ defaultValue: "Send",
+ comment: "NavTitle: Send")
}
var body: some View {
#if PRINT_CHANGES
let _ = Self._printChanges()
#endif
+ let currencySymbol = currencyInfo.symbol
+ let navA11y = navTitle(currencyInfo.name)
+ let navTitle = navTitle(currencySymbol, currencyInfo.hasSymbol)
let count = controller.balances.count
let _ = symLog.log("count = \(count)")
let scrollView = ScrollView {
if count > 0 {
ScopePicker(value: $balanceIndex,
- onlyNonZero: true) { index in
+ onlyNonZero: true)
+ { index in
balanceIndex = index
balance = controller.balances[index]
}
@@ -48,12 +53,22 @@ struct SendAmountV: View {
.padding(.bottom, 4)
}
SendAmountContent(stack: stack.push(),
+ currencyInfo: $currencyInfo,
balance: $balance,
balanceIndex: $balanceIndex,
amountLastUsed: $amountLastUsed,
summary: $summary)
} // ScrollView
+ .navigationTitle(navTitle)
+ .frame(maxWidth: .infinity, alignment: .leading)
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
+ .onAppear {
+ DebugViewC.shared.setViewID(VIEW_P2P_SEND, stack: stack.push())
+ symLog.log("❗️ \(navTitle) onAppear")
+ }
+ .onDisappear {
+ symLog.log("❗️ \(navTitle) onDisappear")
+ }
.task {
if let selectedBalance {
if selectedBalance.available.isZero {
@@ -87,8 +102,9 @@ struct SendAmountV: View {
}
// MARK: -
struct SendAmountContent: View {
- private let symLog = SymLogV(0)
+ private let symLog = SymLogV()
let stack: CallStack
+ @Binding var currencyInfo: CurrencyInfo
@Binding var balance: Balance?
@Binding var balanceIndex: Int
@Binding var amountLastUsed: Amount
@@ -110,7 +126,6 @@ struct SendAmountContent: View {
@State private var amountAvailable = Amount.zero(currency: EMPTYSTRING)
// GetMaxPeerPushAmount
@State private var exchange: Exchange? = nil
// wg. noFees
- @State private var currencyInfo = CurrencyInfo.zero(UNKNOWN)
@State private var scopeInfo: ScopeInfo = ScopeInfo.zero()
private func shortcutAction(_ shortcut: Amount) {
@@ -188,20 +203,17 @@ struct SendAmountContent: View {
}
var body: some View {
-#if true //PRINT_CHANGES
+#if PRINT_CHANGES
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with
.onAppear & onDisappear
#endif
- let navTitle = String(localized: "NavTitle_Send",
- defaultValue: "Send",
- comment: "NavTitle: Send")
Group {
if let balance {
let scopeInfo = balance.scopeInfo
let availableStr = amountAvailable.formatted(currencyInfo,
isNegative: false)
- let availableA11y = amountAvailable.formatted(currencyInfo,
isNegative: false, useISO: true, a11y: ".")
- let amountVoiceOver = amountToTransfer.formatted(currencyInfo,
isNegative: false)
- let insufficientLabel2 = String(localized: "but you only have
\(availableStr) to send.")
+// let availableA11y = amountAvailable.formatted(currencyInfo,
isNegative: false, useISO: true, a11y: ".")
+// let amountVoiceOver = amountToTransfer.formatted(currencyInfo,
isNegative: false)
+// let insufficientLabel2 = String(localized: "but you only have
\(availableStr) to send.")
let inputDestination = P2PSubjectV(stack: stack.push(),
scope: scopeInfo,
@@ -221,57 +233,45 @@ struct SendAmountContent: View {
amountToTransfer: $amountShortcut,
// from the tapped shortcut button
summary: $summary,
expireDays: $expireDays)
- Group {
- AmountInputV(stack: stack.push(),
- currencyInfo: $currencyInfo,
- amountAvailable: $amountAvailable,
- amountLabel: nil, // will use "Available:
xxx", trailing
- amountToTransfer: $amountToTransfer,
- amountLastUsed: amountLastUsed,
- wireFee: nil,
- summary: $summary,
- shortcutAction: shortcutAction,
- buttonAction: buttonAction,
- feeIsNegative: false,
- computeFee: computeFeeSend)
- .background(NavigationLink(destination:
shortcutDestination, isActive: $shortcutSelected)
- { EmptyView() }.frame(width: 0).opacity(0).hidden()
- ) // shortcutDestination
- .background(NavigationLink(destination: inputDestination,
isActive: $buttonSelected)
- { EmptyView() }.frame(width: 0).opacity(0).hidden()
- ) // inputDestination
- }
+ AmountInputV(stack: stack.push(),
+ currencyInfo: $currencyInfo,
+ amountAvailable: $amountAvailable,
+ amountLabel: nil, // will use "Available: xxx",
trailing
+ amountToTransfer: $amountToTransfer,
+ amountLastUsed: amountLastUsed,
+ wireFee: nil,
+ summary: $summary,
+ shortcutAction: shortcutAction,
+ buttonAction: buttonAction,
+ feeIsNegative: false,
+ computeFee: computeFeeSend)
+ .background(NavigationLink(destination: shortcutDestination,
isActive: $shortcutSelected)
+ { EmptyView() }.frame(width: 0).opacity(0).hidden()
+ ) // shortcutDestination
+ .background(NavigationLink(destination: inputDestination,
isActive: $buttonSelected)
+ { EmptyView() }.frame(width: 0).opacity(0).hidden()
+ ) // inputDestination
} else { // no balance - Yikes
Text("No balance. There seems to be a problem with the
database...")
}
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
- .navigationTitle(navTitle)
- .task {
+ } // Group
+ .task { // getMaxPeerPushDebit on first appearance
if scopeInfo.type != .madeUp {
do {
- let amount = try await
model.getMaxPeerPushDebitAmountM(scopeInfo, viewHandles: true)
- amountAvailable = amount
+ symLog.log("❗️ task \(scopeInfo.currency)")
+ amountAvailable = try await
model.getMaxPeerPushDebitAmountM(scopeInfo, viewHandles: true)
return
} catch {}
}
amountAvailable = Amount.zero(currency:
amountToTransfer.currencyStr)
}
- .onAppear {
- DebugViewC.shared.setViewID(VIEW_P2P_SEND, stack: stack.push())
- symLog.log("❗️ \(navTitle) onAppear")
- }
- .onDisappear {
- symLog.log("❗️ \(navTitle) onDisappear")
- }
.task(id: balanceIndex + (1000 * controller.currencyTicker)) {
+ // runs whenever the user changes the exchange via ScopePicker, or
on new currencyInfo
symLog.log("❗️ task \(balanceIndex)")
if let balance {
scopeInfo = balance.scopeInfo
- let currency = scopeInfo.currency
- amountToTransfer.setCurrency(currency)
- currencyInfo = controller.info2(for: currency,
controller.currencyTicker)
+ amountToTransfer.setCurrency(scopeInfo.currency)
+ currencyInfo = controller.info(for: scopeInfo,
controller.currencyTicker)
do {
amountAvailable = try await
model.getMaxPeerPushDebitAmountM(scopeInfo)
} catch {
@@ -315,7 +315,7 @@ struct SendAmountContent: View {
// }
// }
// }
- }
+ } // body
}
// MARK: -
#if DEBUG
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 54/204: tabBar+QR, (continued)
- [taler-taler-ios] 54/204: tabBar+QR, gnunet, 2024/12/05
- [taler-taler-ios] 52/204: QRButton gets camera API, gnunet, 2024/12/05
- [taler-taler-ios] 57/204: innerSize, gnunet, 2024/12/05
- [taler-taler-ios] 58/204: ScopePicker, gnunet, 2024/12/05
- [taler-taler-ios] 62/204: a11y, gnunet, 2024/12/05
- [taler-taler-ios] 63/204: amount too small is no error, gnunet, 2024/12/05
- [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 <=
- [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, 2024/12/05
- [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