gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 23/36: amountToTransfer Exchange


From: gnunet
Subject: [taler-taler-ios] 23/36: amountToTransfer Exchange
Date: Mon, 13 Nov 2023 21:27:28 +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 ac45ed6db139a68618358d9ae178c2bdc2c3e760
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Nov 12 18:20:58 2023 +0100

    amountToTransfer Exchange
---
 TalerWallet1/Views/Exchange/ExchangeListView.swift |  8 ++++----
 TalerWallet1/Views/Exchange/ExchangeRowView.swift  | 11 +++++------
 .../Views/Exchange/ExchangeSectionView.swift       | 22 +++++++++++++---------
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift 
b/TalerWallet1/Views/Exchange/ExchangeListView.swift
index cc1d987..48186e3 100644
--- a/TalerWallet1/Views/Exchange/ExchangeListView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -83,7 +83,7 @@ struct ExchangeListCommonV: View {
     @State private var exchanges: [Exchange] = []
 
     // source of truth for the value the user enters in currencyField for 
exchange withdrawals
-    @State private var centsToTransfer: UInt64 = 0        // TODO: different 
values for different currencies?
+    @State private var amountToTransfer = Amount.zero(currency: "")     // 
TODO: Hold different values for different currencies?
 
     func reloadExchanges() async -> Void {
         exchanges = await model.listExchangesM()
@@ -99,7 +99,7 @@ struct ExchangeListCommonV: View {
                  stack: stack.push(),
 //              balances: $balances,
              exchanges: $exchanges,
-       centsToTransfer: $centsToTransfer,
+      amountToTransfer: $amountToTransfer,
        reloadExchanges: reloadExchanges)
         .overlay {
             if exchanges.isEmpty {
@@ -121,7 +121,7 @@ extension ExchangeListCommonV {
         @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 //        @Binding var balances: [Balance]
         @Binding var exchanges: [Exchange]
-        @Binding var centsToTransfer: UInt64
+        @Binding var amountToTransfer: Amount           // does still have the 
wrong currency
         var reloadExchanges: () async -> Void
 
         func currenciesDict(_ exchanges: [Exchange]) -> [String : [Exchange]] {
@@ -147,7 +147,7 @@ extension ExchangeListCommonV {
                 List(sortedDict, id: \.key) { key, value in
                     ExchangeSectionView(stack: stack.push(),
                                      currency: key, exchanges: value,
-                              centsToTransfer: $centsToTransfer)
+                             amountToTransfer: $amountToTransfer)              
 // does still have the wrong currency
                 }
                 .refreshable {
                     symLog?.log("refreshing")
diff --git a/TalerWallet1/Views/Exchange/ExchangeRowView.swift 
b/TalerWallet1/Views/Exchange/ExchangeRowView.swift
index 7343ad3..afea32c 100644
--- a/TalerWallet1/Views/Exchange/ExchangeRowView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeRowView.swift
@@ -8,12 +8,11 @@ import taler_swift
 struct ExchangeRowView: View {
     let stack: CallStack
     let exchange: Exchange
-//    let amount: Amount
     let currency: String
-    @Binding var centsToTransfer: UInt64
-    @AppStorage("iconOnly") var iconOnly: Bool = false
+    @Binding var amountToTransfer: Amount
 
     @Environment(\.sizeCategory) var sizeCategory
+    @AppStorage("iconOnly") var iconOnly: Bool = false
     @State private var buttonSelected: Int? = nil
 
     func selectAndUpdate(_ button: Int) {
@@ -69,7 +68,7 @@ struct ExchangeRowView: View {
             NavigationLink(destination: LazyView {
                 ManualWithdraw(stack: stack.push(),
                             exchange: exchange,
-                     centsToTransfer: $centsToTransfer)
+                    amountToTransfer: $amountToTransfer)
             }, tag: 2, selection: $buttonSelected
             ) { EmptyView() }.frame(width: 0).opacity(0)
         }.listRowSeparator(.hidden)
@@ -105,7 +104,7 @@ struct ExchangeRowView: View {
 // MARK: -
 #if DEBUG
 fileprivate struct ExchangeRow_Container : View {
-    @State private var centsToTransfer: UInt64 = 100
+    @State private var amountToTransfer = Amount(currency: LONGCURRENCY, cent: 
1234)
 
 //    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
@@ -126,7 +125,7 @@ fileprivate struct ExchangeRow_Container : View {
         ExchangeRowView(stack: CallStack("Preview"),
                      exchange: exchange1,
                      currency: LONGCURRENCY,
-              centsToTransfer: $centsToTransfer)
+             amountToTransfer: $amountToTransfer)
     }
 }
 
diff --git a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift 
b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
index 10ad252..4664d50 100644
--- a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
@@ -10,23 +10,27 @@ import taler_swift
 /// [Deposit Coins]  [Withdraw Coins]
 struct ExchangeSectionView: View {
     let stack: CallStack
-//    let amount: Amount
-    let currency: String          // TODO: amount.currencyStr
+    let currency: String                        // this is the currency to be 
used
     let exchanges: [Exchange]
-    @Binding var centsToTransfer: UInt64
+    @Binding var amountToTransfer: Amount       // does still have the wrong 
currency
+
+    func setCurrency() -> String {
+        amountToTransfer.setCurrency(currency)
+        return currency
+    }
 
     var body: some View {
 #if DEBUG
         let _ = Self._printChanges()
 //        let _ = symLog.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
 #endif
+        let currency2 = setCurrency()           // update currency in 
amountToTransfer
         Section {
             ForEach(exchanges) { exchange in
                 ExchangeRowView(stack: stack.push(),
                              exchange: exchange,
-//                               amount: amount,
-                             currency: currency,            // TODO: 
(balance.available) amount.isZero to disable Deposit-button
-                      centsToTransfer: $centsToTransfer)
+                             currency: currency2,            // TODO: 
(balance.available) amount.isZero to disable Deposit-button
+                     amountToTransfer: $amountToTransfer)
             }
         } header: {
             BarGraphHeader(stack: stack.push(), currency: currency)
@@ -35,8 +39,9 @@ struct ExchangeSectionView: View {
 }
 // MARK: -
 #if DEBUG
+fileprivate struct ExchangeSection_Previews: PreviewProvider {
 fileprivate struct ExchangeRow_Container : View {
-    @State private var centsToTransfer: UInt64 = 100
+    @State private var amountToTransfer = Amount(currency: LONGCURRENCY, cent: 
1234)
 
 //    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
@@ -56,11 +61,10 @@ fileprivate struct ExchangeRow_Container : View {
                            ageRestrictionOptions: [])
         ExchangeSectionView(stack: CallStack("Preview"), currency: 
LONGCURRENCY,
                             exchanges: [exchange1, exchange2],
-                            centsToTransfer: $centsToTransfer)
+                            amountToTransfer: $amountToTransfer)
     }
 }
 
-fileprivate struct ExchangeSection_Previews: PreviewProvider {
     static var previews: some View {
         List {
             ExchangeRow_Container()

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]