commit fb7b78be9bc06ca86e74bb10b042b815c1fb5e9d
parent dab7694c246affca4ce7c99de1e2810e3d0ac084
Author: Marc Stibane <marc@taler.net>
Date: Fri, 13 Oct 2023 19:29:48 +0200
Preparation for Exchange
deposit only with positive balance
Diffstat:
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -11,6 +11,7 @@ struct ExchangeListView: View {
private let symLog = SymLogV(0)
let stack: CallStack
let navTitle: String
+ @Binding var balances: [Balance]
#if TABBAR // Taler Wallet
#else // GNU Taler
var hamburgerAction: () -> Void
@@ -59,6 +60,7 @@ struct ExchangeListView: View {
//Text("Exchanges...")
Content(symLog: symLog,
stack: stack.push(),
+ balances: $balances,
exchanges: $exchanges,
centsToTransfer: $centsToTransfer,
reloadAction: reloadAction)
@@ -95,6 +97,7 @@ extension ExchangeListView {
let symLog: SymLogV?
let stack: CallStack
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
+ @Binding var balances: [Balance]
@Binding var exchanges: [Exchange]
@Binding var centsToTransfer: UInt64
var reloadAction: () async -> Void
diff --git a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
@@ -8,21 +8,25 @@ import taler_swift
struct ExchangeRowView: View {
let stack: CallStack
let exchange: Exchange
+// let amount: Amount
let currency: String
@Binding var centsToTransfer: UInt64
+ @Environment(\.sizeCategory) var sizeCategory
@State private var buttonSelected: Int? = nil
func selectAndUpdate(_ button: Int) {
- Task { // runs on MainActor
- do {
- buttonSelected = button // will trigger NavigationLink
+ buttonSelected = button // will trigger NavigationLink
+ // while navigation animation runs, contact Exchange to update Fees
+// Task { // runs on MainActor
+// do {
// try await model.updateExchange(scopeInfo: balance.scopeInfo)
- } catch { // TODO: error handling - couldn't updateExchange
- // symLog.log("error: \(error)")
- }
- }
+// } catch { // TODO: error handling - couldn't updateExchange
+// // symLog.log("error: \(error)")
+// }
+// }
}
+
let depositTitle = String(localized: "Deposit", comment: "Top of button <Deposit (currency)>")
let withdrawTitle = String(localized: "Withdraw", comment: "Top of button <Withdraw (currency)>")
func needVStack(_ currency: String) -> Bool {
@@ -78,6 +82,7 @@ struct ExchangeRowView: View {
struct ExchangeSectionView: View {
let stack: CallStack
let currency: String
+// let amount: Amount
let exchanges: [Exchange]
@Binding var centsToTransfer: UInt64
@@ -92,11 +97,12 @@ struct ExchangeSectionView: View {
ExchangeRowView(stack: stack.push(),
exchange: exchange,
currency: currency,
+// amount: amount,
centsToTransfer: $centsToTransfer)
}
.accessibilityElement(children: .combine)
} header: {
- Text(currency)
+ Text(currency) // TODO: amount.currencyStr
.accessibilityFont(.title)
}
}
@@ -106,6 +112,7 @@ struct ExchangeSectionView: View {
struct ExchangeRow_Container : View {
@State private var centsToTransfer: UInt64 = 100
+// let amount = try! Amount(fromString: LONGCURRENCY + ":1234.56")
var body: some View {
let exchange1 = Exchange(exchangeBaseUrl: ARS_AGE_EXCHANGE,
currency: LONGCURRENCY,
@@ -121,8 +128,9 @@ struct ExchangeRow_Container : View {
exchangeEntryStatus: .ephemeral,
exchangeUpdateStatus: .ready,
ageRestrictionOptions: [])
- ExchangeSectionView(stack: CallStack("Preview"), currency: LONGCURRENCY, exchanges: [exchange1, exchange2],
- centsToTransfer: $centsToTransfer)
+ ExchangeSectionView(stack: CallStack("Preview"), currency: LONGCURRENCY,
+ exchanges: [exchange1, exchange2],
+ centsToTransfer: $centsToTransfer)
}
}
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
@@ -122,6 +122,7 @@ extension MainView {
sysImage: "building.columns",
view: AnyView(ExchangeListView(stack: stack.push(exchangesTitle),
navTitle: exchangesTitle,
+ balances: $balances,
hamburgerAction: hamburgerAction)
)),
SidebarItem(name: settingsTitle, // TODO: "About"?
@@ -157,7 +158,8 @@ extension MainView {
NavigationView {
ExchangeListView(stack: stack.push(exchangesTitle),
- navTitle: exchangesTitle)
+ navTitle: exchangesTitle,
+ balances: $balances)
}
.tabItem {
Image(systemName: "building.columns")