[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 01/18: fix #9400
From: |
gnunet |
Subject: |
[taler-taler-ios] 01/18: fix #9400 |
Date: |
Thu, 19 Dec 2024 23:12:31 +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 2e7d64aefa445b78de9affbde766565c7f50085e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Dec 19 08:07:46 2024 +0100
fix #9400
---
.../Views/Actions/Banking/ManualWithdraw.swift | 67 ++++++++++++++--------
TalerWallet1/Views/Main/MainView.swift | 4 +-
TalerWallet1/Views/Sheets/WithdrawExchangeV.swift | 3 +
3 files changed, 49 insertions(+), 25 deletions(-)
diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
index e430010..eb543cf 100644
--- a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
+++ b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
@@ -16,6 +16,8 @@ struct ManualWithdraw: View {
let stack: CallStack
@Binding var selectedBalance: Balance?
@Binding var amountLastUsed: Amount
+ @Binding var amountToTransfer: Amount
+ @Binding var exchange: Exchange? // only for withdraw-exchange
let isSheet: Bool
@EnvironmentObject private var controller: Controller
@@ -23,10 +25,13 @@ struct ManualWithdraw: View {
@State private var balanceIndex = 0
@State private var balance: Balance? = nil // nil only when balances
== []
@State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
- @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
+// @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
private func viewDidLoad() async {
- if let selectedBalance {
+ if let exchange {
+ currencyInfo = controller.info(for: exchange.scopeInfo,
controller.currencyTicker)
+ return
+ } else if let selectedBalance {
balance = selectedBalance
balanceIndex = controller.balances.firstIndex(of: selectedBalance)
?? 0
} else {
@@ -56,20 +61,29 @@ struct ManualWithdraw: View {
let count = controller.balances.count
let _ = symLog.log("count = \(count)")
let scrollView = ScrollView {
- if count > 0 {
- ScopePicker(value: $balanceIndex, onlyNonZero: false)
- { index in
- balanceIndex = index
- balance = controller.balances[index]
- }
- .padding(.horizontal)
- .padding(.bottom, 4)
- }
- if let balance {
+ if let exchange {
ManualWithdrawContent(stack: stack.push(),
- scope: balance.scopeInfo,
+ scope: exchange.scopeInfo,
amountLastUsed: $amountLastUsed,
- amountToTransfer: $amountToTransfer)
+ amountToTransfer: $amountToTransfer,
+ exchange: $exchange)
+ } else {
+ if count > 0 {
+ ScopePicker(value: $balanceIndex, onlyNonZero: false)
+ { index in
+ balanceIndex = index
+ balance = controller.balances[index]
+ }
+ .padding(.horizontal)
+ .padding(.bottom, 4)
+ }
+ if let balance {
+ ManualWithdrawContent(stack: stack.push(),
+ scope: balance.scopeInfo,
+ amountLastUsed: $amountLastUsed,
+ amountToTransfer: $amountToTransfer,
+ exchange: $exchange)
+ }
}
} // ScrollView
.navigationTitle(navTitle)
@@ -91,7 +105,11 @@ struct ManualWithdraw: View {
.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 {
+ if let exchange {
+ let scopeInfo = exchange.scopeInfo
+ amountToTransfer.setCurrency(scopeInfo.currency)
+ currencyInfo = controller.info(for: scopeInfo,
controller.currencyTicker)
+ } else if let balance {
let scopeInfo = balance.scopeInfo
amountToTransfer.setCurrency(scopeInfo.currency)
currencyInfo = controller.info(for: scopeInfo,
controller.currencyTicker)
@@ -117,6 +135,7 @@ struct ManualWithdrawContent: View {
let scope: ScopeInfo
@Binding var amountLastUsed: Amount
@Binding var amountToTransfer: Amount
+ @Binding var exchange: Exchange?
@EnvironmentObject private var controller: Controller
@EnvironmentObject private var model: WalletModel
@@ -126,10 +145,6 @@ struct ManualWithdrawContent: View {
// @State var ageMenuList: [Int] = []
// @State var selectedAge = 0
- @State private var exchanges: [Exchange] = []
- @State private var exchange: Exchange? = nil
-
-
private func exchangeVia(_ baseURL: String?) -> String? {
if let baseURL {
return String(localized: "via \(baseURL.trimURL)", comment:
"currency/exchange chooser")
@@ -161,6 +176,13 @@ struct ManualWithdrawContent: View {
return nil
} // computeFee
+ @MainActor
+ private func reloadExchange(_ baseURL: String) async {
+ if exchange == nil || exchange?.tosStatus != .accepted {
+ symLog.log("getExchangeByUrl(\(baseURL))")
+ exchange = try? await model.getExchangeByUrl(url: baseURL)
+ }
+ }
@MainActor
private func viewDidLoad2() async {
// neues scope wenn balance geändert wird?
@@ -168,10 +190,6 @@ struct ManualWithdrawContent: View {
viewHandles: true)
if let details {
detailsForAmount = details
- if exchange == nil || exchange?.tosStatus != .accepted {
- symLog.log("getExchangeByUrl(\(details.exchangeBaseUrl))")
- exchange = try? await model.getExchangeByUrl(url:
details.exchangeBaseUrl)
- }
}
}
@@ -243,7 +261,8 @@ struct ManualWithdrawContent: View {
.padding(.top)
}
} // Group
- .padding(.horizontal)
+ .padding(.horizontal)
+ .task { await reloadExchange(detailsForAmount.exchangeBaseUrl)
}
} else {
LoadingView(scopeInfo: scope, message: nil)
.task { await viewDidLoad2() }
diff --git a/TalerWallet1/Views/Main/MainView.swift
b/TalerWallet1/Views/Main/MainView.swift
index 01364fa..a13752f 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -247,7 +247,7 @@ extension MainView {
@State private var amountToTransfer = Amount.zero(currency:
EMPTYSTRING) // Update currency when used
@State private var amountLastUsed = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
@State private var summary: String = EMPTYSTRING
- @State private var myExchange: Exchange? = nil
+ @State private var exchange: Exchange? = nil
private var openKycButton: some View {
Button("KYC") {
@@ -328,6 +328,8 @@ extension MainView {
let manualWithdrawDest = ManualWithdraw(stack:
stack.push(Self.name),
selectedBalance: $selectedBalance,
amountLastUsed: $amountLastUsed,
// currency needs to be updated!
+ amountToTransfer: $amountToTransfer,
+ exchange: $exchange,
// only for withdraw-exchange
isSheet: false)
/// each NavigationView needs its own NavLinks
let balanceActions = Group {
diff --git a/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
b/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
index 464fd5b..2886eb4 100644
--- a/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
@@ -42,6 +42,7 @@ struct WithdrawExchangeV: View {
amountToTransfer.setCurrency(currency)
// is already Amount.zero()
}
+ amountLastUsed.setCurrency(amountToTransfer.currencyStr)
exchange = exc
} else {
exchange = nil
@@ -61,6 +62,8 @@ struct WithdrawExchangeV: View {
ManualWithdraw(stack: stack.push(),
selectedBalance: $selectedBalance,
amountLastUsed: $amountLastUsed,
+ amountToTransfer: $amountToTransfer,
+ exchange: $exchange, // only for
withdraw-exchange
isSheet: true)
}
.task(id: controller.currencyTicker) {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (4b4d112 -> 1a6daf7), gnunet, 2024/12/19
- [taler-taler-ios] 04/18: terms for tx, gnunet, 2024/12/19
- [taler-taler-ios] 01/18: fix #9400,
gnunet <=
- [taler-taler-ios] 08/18: A11Y VoiceOver dismiss button, gnunet, 2024/12/19
- [taler-taler-ios] 05/18: NavigationModel tosView, gnunet, 2024/12/19
- [taler-taler-ios] 09/18: hide tabBar in ToS, gnunet, 2024/12/19
- [taler-taler-ios] 02/18: isInternal #9332, gnunet, 2024/12/19
- [taler-taler-ios] 06/18: ForEachWithIndex, gnunet, 2024/12/19
- [taler-taler-ios] 03/18: cleanup, gnunet, 2024/12/19
- [taler-taler-ios] 07/18: A11Y colors + fontsize, gnunet, 2024/12/19
- [taler-taler-ios] 10/18: API wording, gnunet, 2024/12/19
- [taler-taler-ios] 12/18: L10N, gnunet, 2024/12/19
- [taler-taler-ios] 11/18: exportDbToFile, gnunet, 2024/12/19