gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 10/18: Deposit


From: gnunet
Subject: [taler-taler-ios] 10/18: Deposit
Date: Thu, 15 Feb 2024 07:02:10 +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 8cfc1c524b27ded7f11ef8cea48e7ce6e3f21fca
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Feb 13 08:19:53 2024 +0100

    Deposit
---
 TalerWallet.xcodeproj/project.pbxproj              |  12 ++
 TalerWallet1/Views/Banking/DepositAmountV.swift    | 161 +++++++++++++++++++++
 TalerWallet1/Views/Banking/DepositIbanV.swift      | 130 +++++++++++++++++
 TalerWallet1/Views/Banking/ExchangeListView.swift  |   8 +-
 TalerWallet1/Views/Banking/ExchangeRowView.swift   |  17 ++-
 .../Views/Banking/ExchangeSectionView.swift        |  12 +-
 6 files changed, 333 insertions(+), 7 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj 
b/TalerWallet.xcodeproj/project.pbxproj
index 8bfb6d8..aaf6dcb 100644
--- a/TalerWallet.xcodeproj/project.pbxproj
+++ b/TalerWallet.xcodeproj/project.pbxproj
@@ -165,6 +165,8 @@
                4E8E25332A1CD39700A27BFA /* EqualIconWidthDomain.swift in 
Sources */ = {isa = PBXBuildFile; fileRef = 4E8E25322A1CD39700A27BFA /* 
EqualIconWidthDomain.swift */; };
                4E9320432A14F6EA00A87B0E /* WalletColors.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4E9320422A14F6EA00A87B0E /* WalletColors.swift 
*/; };
                4E9320452A1645B600A87B0E /* RequestPayment.swift in Sources */ 
= {isa = PBXBuildFile; fileRef = 4E9320442A1645B600A87B0E /* 
RequestPayment.swift */; };
+               4E96583C2B79656E00404A68 /* DepositAmountV.swift in Sources */ 
= {isa = PBXBuildFile; fileRef = 4E96583B2B79656E00404A68 /* 
DepositAmountV.swift */; };
+               4E96583D2B79656E00404A68 /* DepositAmountV.swift in Sources */ 
= {isa = PBXBuildFile; fileRef = 4E96583B2B79656E00404A68 /* 
DepositAmountV.swift */; };
                4E96583F2B7967EF00404A68 /* Model+Deposit.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4E96583E2B7967EF00404A68 /* Model+Deposit.swift 
*/; };
                4E9658402B7967EF00404A68 /* Model+Deposit.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4E96583E2B7967EF00404A68 /* Model+Deposit.swift 
*/; };
                4E9796902A3765ED006F73BC /* AgePicker.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4E97968F2A3765ED006F73BC /* AgePicker.swift */; 
};
@@ -228,6 +230,8 @@
                4EBA56412A7FF5200084948B /* PayTemplateView.swift in Sources */ 
= {isa = PBXBuildFile; fileRef = 4EBA56402A7FF5200084948B /* 
PayTemplateView.swift */; };
                4EBA82AB2A3EB2CA00E5F39A /* TransactionButton.swift in Sources 
*/ = {isa = PBXBuildFile; fileRef = 4EBA82AA2A3EB2CA00E5F39A /* 
TransactionButton.swift */; };
                4EBA82AD2A3F580500E5F39A /* QuiteSomeCoins.swift in Sources */ 
= {isa = PBXBuildFile; fileRef = 4EBA82AC2A3F580500E5F39A /* 
QuiteSomeCoins.swift */; };
+               4EBC0F012B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift 
*/; };
+               4EBC0F022B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift 
*/; };
                4EC400892AE3E7E800DF72C7 /* AboutView.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4EC400882AE3E7E800DF72C7 /* AboutView.swift */; 
};
                4EC4008A2AE3E7E800DF72C7 /* AboutView.swift in Sources */ = 
{isa = PBXBuildFile; fileRef = 4EC400882AE3E7E800DF72C7 /* AboutView.swift */; 
};
                4EC4008C2AE5664100DF72C7 /* CharacterSet+contains.swift in 
Sources */ = {isa = PBXBuildFile; fileRef = 4EC4008B2AE5664100DF72C7 /* 
CharacterSet+contains.swift */; };
@@ -349,6 +353,7 @@
                4E8E25322A1CD39700A27BFA /* EqualIconWidthDomain.swift */ = 
{isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 
EqualIconWidthDomain.swift; sourceTree = "<group>"; };
                4E9320422A14F6EA00A87B0E /* WalletColors.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= WalletColors.swift; sourceTree = "<group>"; };
                4E9320442A1645B600A87B0E /* RequestPayment.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= RequestPayment.swift; sourceTree = "<group>"; };
+               4E96583B2B79656E00404A68 /* DepositAmountV.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= DepositAmountV.swift; sourceTree = "<group>"; };
                4E96583E2B7967EF00404A68 /* Model+Deposit.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= "Model+Deposit.swift"; sourceTree = "<group>"; };
                4E97968F2A3765ED006F73BC /* AgePicker.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= AgePicker.swift; sourceTree = "<group>"; };
                4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.swift; path = SingleAxisGeometryReader.swift; sourceTree = 
"<group>"; };
@@ -409,6 +414,7 @@
                4EBA56402A7FF5200084948B /* PayTemplateView.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= PayTemplateView.swift; sourceTree = "<group>"; };
                4EBA82AA2A3EB2CA00E5F39A /* TransactionButton.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= TransactionButton.swift; sourceTree = "<group>"; };
                4EBA82AC2A3F580500E5F39A /* QuiteSomeCoins.swift */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.swift; path = 
QuiteSomeCoins.swift; sourceTree = "<group>"; };
+               4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= DepositIbanV.swift; sourceTree = "<group>"; };
                4EC400882AE3E7E800DF72C7 /* AboutView.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= AboutView.swift; sourceTree = "<group>"; };
                4EC4008B2AE5664100DF72C7 /* CharacterSet+contains.swift */ = 
{isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 
"CharacterSet+contains.swift"; sourceTree = "<group>"; };
                4EC4008E2AE8019700DF72C7 /* ExchangeRowView.swift */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path 
= ExchangeRowView.swift; sourceTree = "<group>"; };
@@ -678,6 +684,8 @@
                                4EB095292989CBFE0043A8A1 /* 
ExchangeListView.swift */,
                                4EC90C772A1B528B0071DC58 /* 
ExchangeSectionView.swift */,
                                4EC4008E2AE8019700DF72C7 /* 
ExchangeRowView.swift */,
+                               4E96583B2B79656E00404A68 /* 
DepositAmountV.swift */,
+                               4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift 
*/,
                                4E50B34F2A1BEE8000F9F01C /* 
ManualWithdraw.swift */,
                                4EBA82AC2A3F580500E5F39A /* 
QuiteSomeCoins.swift */,
                                4EB431662A1E55C700C5690E /* 
ManualWithdrawDone.swift */,
@@ -1076,6 +1084,7 @@
                                4E3327BA2AD1635100BF5AD6 /* 
AsyncSemaphore.swift in Sources */,
                                4E3EAE2C2A990778009F1BE8 /* 
ManualWithdraw.swift in Sources */,
                                4E3EAE2D2A990778009F1BE8 /* 
Model+Exchange.swift in Sources */,
+                               4EBC0F012B7B3CD600C0CB19 /* DepositIbanV.swift 
in Sources */,
                                4E3EAE2E2A990778009F1BE8 /* 
QRCodeDetailView.swift in Sources */,
                                4E3EAE2F2A990778009F1BE8 /* 
TransactionsEmptyView.swift in Sources */,
                                4E605DAF2AADDD13002FB9A7 /* 
UIScreen+screenSize.swift in Sources */,
@@ -1127,6 +1136,7 @@
                                4E3EAE592A990778009F1BE8 /* 
Model+Settings.swift in Sources */,
                                4EC4008C2AE5664100DF72C7 /* 
CharacterSet+contains.swift in Sources */,
                                4E3EAE5A2A990778009F1BE8 /* ErrorView.swift in 
Sources */,
+                               4E96583C2B79656E00404A68 /* 
DepositAmountV.swift in Sources */,
                                4E3EAE5B2A990778009F1BE8 /* 
View+Notification.swift in Sources */,
                                4E3EAE5C2A990778009F1BE8 /* Model+Pending.swift 
in Sources */,
                                4E3EAE5D2A990778009F1BE8 /* 
ExchangeListView.swift in Sources */,
@@ -1185,6 +1195,7 @@
                                4E3327BB2AD1635100BF5AD6 /* 
AsyncSemaphore.swift in Sources */,
                                4E50B3502A1BEE8000F9F01C /* 
ManualWithdraw.swift in Sources */,
                                4E3B4BC92A42BC4800CC88B8 /* 
Model+Exchange.swift in Sources */,
+                               4EBC0F022B7B3CD600C0CB19 /* DepositIbanV.swift 
in Sources */,
                                4E5A88F52A38A4FD00072618 /* 
QRCodeDetailView.swift in Sources */,
                                4E87C8732A31CB7F001C6406 /* 
TransactionsEmptyView.swift in Sources */,
                                4E605DB02AADDD13002FB9A7 /* 
UIScreen+screenSize.swift in Sources */,
@@ -1236,6 +1247,7 @@
                                4EB095152989CBB00043A8A1 /* 
Model+Settings.swift in Sources */,
                                4EC4008D2AE5664100DF72C7 /* 
CharacterSet+contains.swift in Sources */,
                                4EB095692989CBFE0043A8A1 /* ErrorView.swift in 
Sources */,
+                               4E96583D2B79656E00404A68 /* 
DepositAmountV.swift in Sources */,
                                4E3B4BC72A429F2A00CC88B8 /* 
View+Notification.swift in Sources */,
                                4EB0956E2989CBFE0043A8A1 /* Model+Pending.swift 
in Sources */,
                                4EB095522989CBFE0043A8A1 /* 
ExchangeListView.swift in Sources */,
diff --git a/TalerWallet1/Views/Banking/DepositAmountV.swift 
b/TalerWallet1/Views/Banking/DepositAmountV.swift
new file mode 100644
index 0000000..28f40fb
--- /dev/null
+++ b/TalerWallet1/Views/Banking/DepositAmountV.swift
@@ -0,0 +1,161 @@
+/*
+ * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * See LICENSE.md
+ */
+import SwiftUI
+import taler_swift
+import SymLog
+
+// Called when tapping "Deposit" in the exchanges list
+struct DepositAmountV: View {
+    private let symLog = SymLogV(0)
+    let stack: CallStack
+
+//    let exchangeBaseUrl: String
+    let amountAvailable: Amount // TODO: GetMaxPeerPushAmount
+    @Binding var amountToTransfer: Amount
+    @Binding var depositIBAN: String
+    @Binding var accountHolder: String
+//    let scopeInfo: ScopeInfo
+
+    @EnvironmentObject private var controller: Controller
+    @EnvironmentObject private var model: WalletModel
+    @AppStorage("minimalistic") var minimalistic: Bool = false
+
+    @State var prepareDepositResult: PrepareDepositResult? = nil
+    @State private var insufficient = false
+    @State private var feeAmount: Amount? = nil
+    @State private var feeStr: String = EMPTYSTRING
+    @State private var buttonSelected = false
+    @State private var amountShortcut = Amount.zero(currency: EMPTYSTRING)     
 // Update currency when used
+    @State private var exchange: Exchange? = nil          // wg. hasNoFees
+
+    private func fee(ppCheck: PrepareDepositResult?) -> Amount? {
+        do {
+            if let ppCheck {
+                // Outgoing: fee = effective - raw
+                feeAmount = try ppCheck.fees.coin + ppCheck.fees.wire + 
ppCheck.fees.refresh
+                return feeAmount
+            }
+        } catch {}
+        feeAmount = nil
+        return feeAmount
+    }
+    
+    var feeLabel: String { feeStr.count > 0 ? String(localized: "+ \(feeStr) 
fee") : EMPTYSTRING }
+
+    private func shortcutAction(_ shortcut: Amount) {
+        amountShortcut = shortcut
+        buttonSelected = true
+    }
+    private func feeIsNotZero() -> Bool? {
+        if let hasNoFees = exchange?.hasNoFees {
+            if hasNoFees {
+                return nil      // this exchange never has fees
+            }
+        }
+        return prepareDepositResult != nil ? (!(feeAmount?.isZero ?? false))
+                                    : false
+    }
+
+    var body: some View {
+#if PRINT_CHANGES
+        let _ = Self._printChanges()
+        let _ = symLog.vlog()       // just to get the # to compare it with 
.onAppear & onDisappear
+#endif
+        let currency = amountToTransfer.currencyStr
+        let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
+        let currencySymbol = currencyInfo.specs.altUnitNames?[0] ?? currency
+        let navTitle = String(localized: "NavTitle_Deposit_Currency",
+                           defaultValue: "Deposit \(currencySymbol)",
+                                comment: "NavTitle: Deposit 'currencySymbol'")
+        let available = amountAvailable.string(currencyInfo)
+        let _ = print("available: \(available)")
+        let _ = symLog.log("currency: \(currency), available: \(available)")
+        let amountVoiceOver = amountToTransfer.string(currencyInfo)
+        let insufficientLabel = String(localized: "You don't have enough 
\(currency).")
+        let insufficientLabel2 = String(localized: "but you only have 
\(available) to send.")
+
+        let inputDestination = LazyView {
+            DepositIbanV(stack: stack.push(),
+                     feeLabel: feeLabel,
+                 feeIsNotZero: feeIsNotZero(),
+                 currencyInfo: currencyInfo,
+             amountToTransfer: $amountToTransfer,
+                  depositIBAN: $depositIBAN,
+                accountHolder: $accountHolder)
+        }
+        let shortcutDestination = LazyView {
+            DepositIbanV(stack: stack.push(),
+                     feeLabel: nil,
+                 feeIsNotZero: feeIsNotZero(),
+                 currencyInfo: currencyInfo,
+             amountToTransfer: $amountShortcut,
+                  depositIBAN: $depositIBAN,
+                accountHolder: $accountHolder)
+        }
+        let disabled = insufficient || amountToTransfer.isZero
+        ScrollView { VStack(alignment: .trailing) {
+//            Text("Available:\t\(available)")
+//                .talerFont(.title3)
+//                .padding(.bottom, 2)
+            CurrencyInputView(amount: $amountToTransfer,
+                           available: nil,  // amountAvailable,
+                               title: minimalistic ? String(localized: 
"Amount:")
+                                                   : String(localized: "Amount 
to deposit:"),
+                      shortcutAction: shortcutAction)
+            Text(insufficient ? insufficientLabel
+                              : feeLabel)
+                .talerFont(.body)
+                .foregroundColor(insufficient ? .red
+                                 : (feeAmount?.isZero ?? true) ? .secondary : 
.red)
+                .padding(4)
+            NavigationLink(destination: inputDestination) { Text("Next") }
+                .buttonStyle(TalerButtonStyle(type: .prominent))
+                .disabled(disabled)
+                .background(NavigationLink(destination: shortcutDestination, 
isActive: $buttonSelected)
+                    { EmptyView() }.frame(width: 0).opacity(0).hidden()
+                )
+        }.padding(.horizontal) } // ScrollVStack
+        .frame(maxWidth: .infinity, alignment: .leading)
+//        .scrollBounceBehavior(.basedOnSize)  needs iOS 16.4
+        .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
+        .navigationTitle(navTitle)
+        .onAppear {
+            DebugViewC.shared.setViewID(VIEW_P2P_SEND, stack: stack.push())
+            symLog.log("❗️ \(navTitle) onAppear")
+        }
+        .onDisappear {
+            symLog.log("❗️ \(navTitle) onDisappear")
+        }
+        .task(id: amountToTransfer.value) {
+//            do {
+//                insufficient = try amountToTransfer > amountAvailable
+//            } catch {
+//                print("Yikes❗️ insufficient failed❗️")
+//                insufficient = true
+//            }
+
+//            if insufficient {
+//                announce(this: "\(amountVoiceOver), \(insufficientLabel2)")
+//            } else if amountToTransfer.isZero {
+//                feeStr = EMPTYSTRING
+//            } else {
+//                do {
+//                    let ppCheck = try await model.prepareDepositM("", 
amount: amountToTransfer)
+//                    prepareDepositResult = ppCheck
+//                    if let feeAmount = fee(ppCheck: prepareDepositResult) {
+//                        feeStr = feeAmount.string(currencyInfo)
+//                    } else { feeStr = EMPTYSTRING }
+//                    announce(this: "\(amountVoiceOver), \(feeLabel)")
+//                } catch {    // TODO: error
+//                    symLog.log(error.localizedDescription)
+//                    prepareDepositResult = nil
+//                }
+//            }
+        }
+    }
+}
+// MARK: -
+#if DEBUG
+#endif
diff --git a/TalerWallet1/Views/Banking/DepositIbanV.swift 
b/TalerWallet1/Views/Banking/DepositIbanV.swift
new file mode 100644
index 0000000..b0be9b3
--- /dev/null
+++ b/TalerWallet1/Views/Banking/DepositIbanV.swift
@@ -0,0 +1,130 @@
+/*
+ * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * See LICENSE.md
+ */
+import SwiftUI
+import taler_swift
+import SymLog
+
+
+struct DepositIbanV: View {
+    private let symLog = SymLogV(0)
+    let stack: CallStack
+    let feeLabel: String?
+    let feeIsNotZero: Bool?            // nil = no fees at all, false = no fee 
for this tx
+    let currencyInfo: CurrencyInfo
+    @Binding var amountToTransfer: Amount
+    @Binding var depositIBAN: String
+    @Binding var accountHolder: String
+
+    @EnvironmentObject private var model: WalletModel
+    @AppStorage("minimalistic") var minimalistic: Bool = false
+
+    @State private var myFeeLabel: String = EMPTYSTRING
+    @State private var transactionStarted: Bool = false
+    @FocusState private var isFocused: Bool
+
+    private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
+        let amountWithCurrency = amount.string(currencyInfo, useSymbol: false)
+        return String(localized: "Deposit \(amountWithCurrency)", comment: 
"amount with currency")
+    }
+
+    private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
+        let amountStr = amount.string(currencyInfo)
+        return String(localized: "NavTitle_Deposit_AmountStr",
+                   defaultValue: "Deposit \(amountStr)", comment: "NavTitle: 
Deposit 'amountStr'")
+    }
+
+    var body: some View {
+#if PRINT_CHANGES
+        let _ = Self._printChanges()
+        let _ = symLog.vlog(amountToTransfer.readableDescription)       // 
just to get the # to compare it with .onAppear & onDisappear
+#endif
+        ScrollView { VStack (alignment: .leading, spacing: 6) {
+            if let feeIsNotZero {       // don't show fee if nil
+                let label = feeLabel ?? myFeeLabel
+                if label.count > 0 {
+                    Text(label)
+                        .frame(maxWidth: .infinity, alignment: .trailing)
+                        .foregroundColor(feeIsNotZero ? .red : .secondary)
+                        .talerFont(.body)
+                }
+            }
+            if !minimalistic {
+                Text("Account holder:")
+                    .talerFont(.title3)
+                    .accessibilityAddTraits(.isHeader)
+                    .accessibilityRemoveTraits(.isStaticText)
+                    .padding(.top)
+            }
+            TextField(minimalistic ? "Account holder" : EMPTYSTRING, text: 
$accountHolder)
+                .focused($isFocused)
+                .talerFont(.title2)
+                .foregroundColor(WalletColors().fieldForeground)     // text 
color
+                .background(WalletColors().fieldBackground)
+                .textFieldStyle(.roundedBorder)
+                .onAppear {
+                    symLog.log("dispatching kbd...")
+                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
+                        isFocused = true        // make first responder - 
raise keybord
+                        symLog.log("...kbd isFocused")
+                    }
+                }
+
+            if !minimalistic {
+                Text("IBAN:")
+                    .talerFont(.title3)
+                    .accessibilityAddTraits(.isHeader)
+                    .accessibilityRemoveTraits(.isStaticText)
+                    .padding(.top)
+            }
+            TextField(minimalistic ? "Account holder" : EMPTYSTRING, text: 
$depositIBAN)
+                .talerFont(.title2)
+                .foregroundColor(WalletColors().fieldForeground)     // text 
color
+                .background(WalletColors().fieldBackground)
+                .textFieldStyle(.roundedBorder)
+
+            let disabled = (accountHolder.count < 1) || (depositIBAN.count < 
1)    // TODO: check amountAvailable
+            NavigationLink(destination: LazyView {
+                EmptyView()
+//                    P2PReadyV(stack: stack.push(),
+//                            summary: summary,
+//                         expireDays: expireDays,
+//                       amountToSend: amountToSend,
+//                   amountToTransfer: amountToTransfer,
+//                 transactionStarted: $transactionStarted)
+            }) {
+                Text(buttonTitle(amountToTransfer, currencyInfo))
+            }
+                .buttonStyle(TalerButtonStyle(type: .prominent))
+                .disabled(disabled)
+                .accessibilityHint(disabled ? "enabled when account holder and 
IBAN are set" : EMPTYSTRING)
+        }.padding(.horizontal) } // ScrollVStack
+//        .scrollBounceBehavior(.basedOnSize)  needs iOS 16.4
+        .navigationTitle(subjectTitle(amountToTransfer, currencyInfo))
+        .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
+        .onAppear {
+            DebugViewC.shared.setViewID(VIEW_DEPOSIT_ACCEPT, stack: 
stack.push())
+//            print("❗️ P2PSubjectV onAppear")
+        }
+        .onDisappear {
+//            print("❗️ P2PSubjectV onDisappear")
+        }
+//        .task(id: amountToTransfer.value) {
+//            if amountToSend && feeLabel == nil {
+//                do {
+//                    let ppCheck = try await 
model.checkPeerPushDebitM(amountToTransfer)
+//                    if let feeAmount = p2pFee(ppCheck: ppCheck) {
+//                        let feeStr = feeAmount.string(currencyInfo)
+//                        myFeeLabel = String(localized: "+ \(feeStr) fee")
+//                    } else { myFeeLabel = EMPTYSTRING }
+//                } catch {    // TODO: error
+//                    symLog.log(error.localizedDescription)
+//                }
+//            }
+//        }
+    }
+}
+// MARK: -
+#if DEBUG
+#endif
diff --git a/TalerWallet1/Views/Banking/ExchangeListView.swift 
b/TalerWallet1/Views/Banking/ExchangeListView.swift
index 217d7b2..03405e8 100644
--- a/TalerWallet1/Views/Banking/ExchangeListView.swift
+++ b/TalerWallet1/Views/Banking/ExchangeListView.swift
@@ -76,7 +76,9 @@ struct ExchangeListCommonV {
     @State private var exchanges: [Exchange] = []
 
     // source of truth for the value the user enters in currencyField for 
exchange withdrawals
-    @State private var amountToTransfer = Amount.zero(currency: "")     // 
TODO: Hold different values for different currencies?
+    @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)   
  // TODO: Hold different values for different currencies?
+    @State private var depositIBAN = EMPTYSTRING
+    @State private var accountHolder = EMPTYSTRING
 
     func reloadExchanges() async -> Void {
         exchanges = await model.listExchangesM()
@@ -96,7 +98,9 @@ extension ExchangeListCommonV: View {
             List(sortedExchanges, id: \.self) { exchange in
                 ExchangeSectionView(stack: stack.push(),
                                  exchange: exchange,
-                         amountToTransfer: $amountToTransfer)               // 
does still have the wrong currency
+                         amountToTransfer: $amountToTransfer,               // 
does still have the wrong currency
+                              depositIBAN: $depositIBAN,
+                            accountHolder: $accountHolder)
             }
             .refreshable {
                 symLog?.log("refreshing")
diff --git a/TalerWallet1/Views/Banking/ExchangeRowView.swift 
b/TalerWallet1/Views/Banking/ExchangeRowView.swift
index 03766c5..fb25361 100644
--- a/TalerWallet1/Views/Banking/ExchangeRowView.swift
+++ b/TalerWallet1/Views/Banking/ExchangeRowView.swift
@@ -12,6 +12,8 @@ struct ExchangeRowView: View {
     let exchange: Exchange
     let currency: String                        // this is the currency to be 
used
     @Binding var amountToTransfer: Amount       // does still have the wrong 
currency
+    @Binding var depositIBAN: String
+    @Binding var accountHolder: String
 
     @Environment(\.sizeCategory) var sizeCategory
     @EnvironmentObject private var controller: Controller
@@ -52,7 +54,12 @@ struct ExchangeRowView: View {
                                     comment: "Button `Withdraw (currency)´, 
must have ONE \\t and ONE %@")
         let baseURL = exchange.exchangeBaseUrl
         let deposit = LazyView {
-            EmptyView()     // TODO: Deposit
+            DepositAmountV(stack: stack.push(),
+//                 exchangeBaseUrl: baseURL,
+                 amountAvailable: Amount.zero(currency: currency),
+                amountToTransfer: $amountToTransfer,
+                     depositIBAN: $depositIBAN,
+                   accountHolder: $accountHolder)
         }
         let manualWithdraw = LazyView {
             ManualWithdraw(stack: stack.push(),
@@ -69,7 +76,7 @@ struct ExchangeRowView: View {
                                           recvTitle: minimalistic ? 
withdrawTitle0 : withdrawTitle1,
                                      fitsSideBySide: false,
                                           lineLimit: 5,
-                                       sendDisabled: true,             // 
TODO: availableAmount.isZero
+                                       sendDisabled: false,  // TODO: 
availableAmount.isZero
                                          sendAction: { selectAndUpdate(1) },
                                          recvAction: { selectAndUpdate(2) })
         Group {
@@ -122,6 +129,8 @@ struct ExchangeRowView: View {
 #if DEBUG
 fileprivate struct ExchangeRow_Container : View {
     @State private var amountToPreview = Amount(currency: LONGCURRENCY, cent: 
1234)
+    @State private var depositIBAN = "DE1234567890"
+    @State private var accountHolder = "Marc Stibane"
 
 //    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
@@ -143,7 +152,9 @@ fileprivate struct ExchangeRow_Container : View {
         ExchangeRowView(stack: CallStack("Preview"),
                      exchange: exchange1,
                      currency: LONGCURRENCY,
-             amountToTransfer: $amountToPreview)
+             amountToTransfer: $amountToPreview,
+                  depositIBAN: $depositIBAN,
+                accountHolder: $accountHolder)
     }
 }
 
diff --git a/TalerWallet1/Views/Banking/ExchangeSectionView.swift 
b/TalerWallet1/Views/Banking/ExchangeSectionView.swift
index 6fb1b4f..4935735 100644
--- a/TalerWallet1/Views/Banking/ExchangeSectionView.swift
+++ b/TalerWallet1/Views/Banking/ExchangeSectionView.swift
@@ -13,6 +13,8 @@ struct ExchangeSectionView: View {
     let exchange: Exchange
 //    let exchanges: [Exchange]
     @Binding var amountToTransfer: Amount       // does still have the wrong 
currency
+    @Binding var depositIBAN: String
+    @Binding var accountHolder: String
     @EnvironmentObject private var controller: Controller
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
@@ -33,7 +35,9 @@ struct ExchangeSectionView: View {
                 ExchangeRowView(stack: stack.push(),
                              exchange: exchange,
                              currency: currencyName,        // TODO: 
(balance.available) amount.isZero to disable Deposit-button
-                     amountToTransfer: $amountToTransfer)   // does still have 
the wrong currency
+                     amountToTransfer: $amountToTransfer,   // does still have 
the wrong currency
+                          depositIBAN: $depositIBAN,
+                        accountHolder: $accountHolder)
                 .listRowSeparator(.hidden)
 //            }
             if DEMOCURRENCY == currency {
@@ -61,6 +65,8 @@ struct ExchangeSectionView: View {
 fileprivate struct ExchangeSection_Previews: PreviewProvider {
 fileprivate struct ExchangeRow_Container : View {
     @State private var amountToPreview = Amount(currency: LONGCURRENCY, cent: 
1234)
+    @State private var depositIBAN = "DE1234567890"
+    @State private var accountHolder = "Marc Stibane"
 
 //    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
@@ -83,7 +89,9 @@ fileprivate struct ExchangeRow_Container : View {
 //                        scopeInfo: scopeInfo,
                          exchange: exchange1,
 //                        exchanges: [exchange1, exchange2],
-                 amountToTransfer: $amountToPreview)
+                 amountToTransfer: $amountToPreview,
+                      depositIBAN: $depositIBAN,
+                    accountHolder: $accountHolder)
     }
 }
 

-- 
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]