[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 08/32: new withdrawal procedure (amountIsEditable)
From: |
gnunet |
Subject: |
[taler-taler-ios] 08/32: new withdrawal procedure (amountIsEditable) |
Date: |
Sun, 14 Jul 2024 00:19:17 +0200 |
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 7db2a0846a8a7797c450f4df38d4d9099c01e9cd
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Jun 26 15:13:43 2024 +0200
new withdrawal procedure (amountIsEditable)
---
TalerWallet1/Model/Model+Withdraw.swift | 9 ++--
.../WithdrawAcceptDone.swift | 9 ++--
.../WithdrawAcceptView.swift | 5 +-
.../WithdrawBankIntegrated/WithdrawURIView.swift | 59 ++++++++++++++++++----
4 files changed, 63 insertions(+), 19 deletions(-)
diff --git a/TalerWallet1/Model/Model+Withdraw.swift
b/TalerWallet1/Model/Model+Withdraw.swift
index 7bf637f..796a8dc 100644
--- a/TalerWallet1/Model/Model+Withdraw.swift
+++ b/TalerWallet1/Model/Model+Withdraw.swift
@@ -171,15 +171,17 @@ struct AcceptWithdrawalResponse: Decodable {
fileprivate struct AcceptBankIntegratedWithdrawal:
WalletBackendFormattedRequest {
typealias Response = AcceptWithdrawalResponse
func operation() -> String { "acceptBankIntegratedWithdrawal" }
- func args() -> Args { Args(talerWithdrawUri: talerWithdrawUri,
exchangeBaseUrl: exchangeBaseUrl, restrictAge: restrictAge) }
+ func args() -> Args { Args(talerWithdrawUri: talerWithdrawUri,
exchangeBaseUrl: exchangeBaseUrl, amount: amount, restrictAge: restrictAge) }
var talerWithdrawUri: String
var exchangeBaseUrl: String
+ var amount: Amount?
var restrictAge: Int?
struct Args: Encodable {
var talerWithdrawUri: String
var exchangeBaseUrl: String
+ var amount: Amount?
var restrictAge: Int?
}
}
@@ -251,9 +253,10 @@ extension WalletModel {
return response
}
@MainActor // M for MainActor
- func sendAcceptIntWithdrawalM(_ exchangeBaseUrl: String, withdrawURL:
String, restrictAge: Int?, viewHandles: Bool = false)
+ func sendAcceptIntWithdrawalM(_ exchangeBaseUrl: String, withdrawURL:
String, amount: Amount?, restrictAge: Int?, viewHandles: Bool = false)
async throws -> AcceptWithdrawalResponse? {
- let request = AcceptBankIntegratedWithdrawal(talerWithdrawUri:
withdrawURL, exchangeBaseUrl: exchangeBaseUrl, restrictAge: restrictAge)
+ let request = AcceptBankIntegratedWithdrawal(talerWithdrawUri:
withdrawURL, exchangeBaseUrl: exchangeBaseUrl,
+ amount:
amount, restrictAge: restrictAge)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles:
viewHandles)
return response
}
diff --git
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index f19260e..71f51d6 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -9,10 +9,11 @@ import SymLog
struct WithdrawAcceptDone: View {
private let symLog = SymLogV(0)
let stack: CallStack
- let navTitle = String(localized: "Confirm with Bank")
+ let navTitle = String(localized: "Confirm with Bank", comment: "Nav title")
let exchangeBaseUrl: String?
let url: URL
+ let amountToTransfer: Amount?
@EnvironmentObject private var controller: Controller
@EnvironmentObject private var model: WalletModel
@@ -57,7 +58,8 @@ struct WithdrawAcceptDone: View {
}.task {
if let exchangeBaseUrl {
// TODO: restrictAge
- if let result = try? await
model.sendAcceptIntWithdrawalM(exchangeBaseUrl, withdrawURL:
url.absoluteString, restrictAge: nil) {
+ if let result = try? await
model.sendAcceptIntWithdrawalM(exchangeBaseUrl, withdrawURL: url.absoluteString,
+
amount: amountToTransfer, restrictAge: nil) {
let confirmTransferUrl = result.confirmTransferUrl
symLog.log(confirmTransferUrl)
transactionId = result.transactionId
@@ -71,6 +73,7 @@ struct WithdrawAcceptDone_Previews: PreviewProvider {
static var previews: some View {
WithdrawAcceptDone(stack: CallStack("Preview"),
exchangeBaseUrl: DEMOEXCHANGE,
- url: URL(string: DEMOSHOP)!)
+ url: URL(string: DEMOSHOP)!,
+ amountToTransfer: nil)
}
}
diff --git
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
index 55a503b..6ba6286 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptView.swift
@@ -79,8 +79,9 @@ struct WithdrawAcceptView: View {
if tosAccepted {
NavigationLink(destination: LazyView {
WithdrawAcceptDone(stack: stack.push(),
- exchangeBaseUrl:
exchange.exchangeBaseUrl,
- url: url)
+ exchangeBaseUrl: exchange.exchangeBaseUrl,
+ url: url,
+ amountToTransfer: amountToTransfer)
}) {
Text("Confirm Withdrawal") //
SHEET_WITHDRAW_ACCEPT
}
diff --git
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
index 5a94d28..c777517 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
@@ -22,6 +22,7 @@ struct WithdrawURIView: View {
@EnvironmentObject private var controller: Controller
@EnvironmentObject private var model: WalletModel
+ @AppStorage("minimalistic") var minimalistic: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@State private var withdrawUriInfo: WithdrawUriInfoResponse? = nil
@@ -29,8 +30,11 @@ struct WithdrawURIView: View {
@State private var amountIsEditable = false
@State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
@State private var amountShortcut = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
+ @State private var buttonSelected = false
@State private var shortcutSelected = false
+ @State private var amountAvailable: Amount? = nil
@State private var wireFee: Amount? = nil
+ @State private var summary = EMPTYSTRING
@State private var selectedExchange = EMPTYSTRING
@State private var exchange: Exchange? = nil
@@ -43,10 +47,18 @@ struct WithdrawURIView: View {
}
}
+ private func shortcutAction(_ shortcut: Amount) {
+ amountShortcut = shortcut
+ shortcutSelected = true
+ }
+ private func buttonAction() {
+ buttonSelected = true
+ }
+
var body: some View {
if possibleExchanges.count > 0 {
if let defaultBaseUrl = defaultExchangeBaseUrl ??
possibleExchanges.first?.exchangeBaseUrl {
- VStack {
+ ScrollView { VStack {
let title = String(localized: "Exchange")
if possibleExchanges.count > 1 {
Picker(title, selection: $selectedExchange) {
@@ -71,18 +83,40 @@ struct WithdrawURIView: View {
await loadExchange(defaultBaseUrl)
}
}
- if amountToTransfer.isZero {
- // TODO: input amount, then
- WithdrawAcceptView(stack: stack.push(), url: url,
- amountToTransfer: $amountToTransfer,
- exchange: $exchange)
+ let acceptDestination = WithdrawAcceptView(stack:
stack.push(), url: url,
+ amountToTransfer:
$amountToTransfer,
+ exchange:
$exchange)
+ if amountIsEditable { // amountToTransfer.isZero {
+ let shortcutDestination = LazyView {
+ WithdrawAcceptView(stack: stack.push(), url: url,
+ amountToTransfer: $amountShortcut,
+ exchange: $exchange)
+ }
+ // TODO: input amount, then
+ let amountLabel = minimalistic ? String(localized:
"Amount:")
+ : String(localized:
"Amount to withdraw:")
+
+ AmountInputV(stack: stack.push(), url: nil,
+ amountAvailable: amountAvailable,
+ amountToTransfer: $amountToTransfer,
wireFee: wireFee,
+ amountLabel: amountLabel,
+ summaryIsEditable: false,
+ summary: $summary,
+// insufficient: $insufficient,
+// feeAmount: $feeAmount,
+ shortcutAction: shortcutAction,
+ buttonAction: buttonAction)
+ .background(NavigationLink(destination:
shortcutDestination, isActive: $shortcutSelected)
+ { EmptyView() }.frame(width:
0).opacity(0).hidden()
+ )
+ .background(NavigationLink(destination:
acceptDestination, isActive: $buttonSelected)
+ { EmptyView() }.frame(width:
0).opacity(0).hidden()
+ )
} else {
- WithdrawAcceptView(stack: stack.push(), url: url,
- amountToTransfer: $amountToTransfer,
- exchange: $exchange)
+ acceptDestination
}
- }
+ } } // ScrollVStack
.navigationTitle(navTitle)
.onAppear() {
symLog.log("onAppear")
@@ -104,9 +138,12 @@ struct WithdrawURIView: View {
.task {
symLog.log(".task")
if let someInfo = try? await
model.getWithdrawalDetailsForUriM(url.absoluteString) {
+ let currency = someInfo.currency
defaultExchangeBaseUrl =
someInfo.defaultExchangeBaseUrl
possibleExchanges = someInfo.possibleExchanges
- amountToTransfer = someInfo.amount ??
Amount.zero(currency: someInfo.currency)
+ amountToTransfer = someInfo.amount ??
Amount.zero(currency: currency)
+ amountAvailable = someInfo.maxAmount
+ amountIsEditable = someInfo.editableAmount
wireFee = someInfo.wireFee
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (0877055 -> 49c8f03), gnunet, 2024/07/13
- [taler-taler-ios] 06/32: Confirm->Authorize, gnunet, 2024/07/13
- [taler-taler-ios] 01/32: nbs, gnunet, 2024/07/13
- [taler-taler-ios] 04/32: useISO, gnunet, 2024/07/13
- [taler-taler-ios] 02/32: fix string replace, gnunet, 2024/07/13
- [taler-taler-ios] 07/32: wireFee, gnunet, 2024/07/13
- [taler-taler-ios] 08/32: new withdrawal procedure (amountIsEditable),
gnunet <=
- [taler-taler-ios] 03/32: iso instead of symbol, fix formatting of currency strings, gnunet, 2024/07/13
- [taler-taler-ios] 05/32: move QR scanner into MainView, gnunet, 2024/07/13
- [taler-taler-ios] 15/32: minimalistic: no currency name, gnunet, 2024/07/13
- [taler-taler-ios] 18/32: cleanup, gnunet, 2024/07/13
- [taler-taler-ios] 28/32: Icons in transactions, gnunet, 2024/07/13
- [taler-taler-ios] 30/32: IconBadge improvements, gnunet, 2024/07/13
- [taler-taler-ios] 31/32: Fix layout of tx list, gnunet, 2024/07/13
- [taler-taler-ios] 20/32: qrCodesForPayto WIP, gnunet, 2024/07/13
- [taler-taler-ios] 26/32: TwoRowButtons with icons, gnunet, 2024/07/13
- [taler-taler-ios] 25/32: Error+debugDescription, gnunet, 2024/07/13