commit df7fc21c48b681213a5491a91d0bcdb5c143cb5a
parent be28f565b289ec7695d70b137087c4db1237d6d5
Author: Marc Stibane <marc@taler.net>
Date: Sat, 27 Jul 2024 08:26:45 +0200
cleanup
Diffstat:
10 files changed, 47 insertions(+), 43 deletions(-)
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift
@@ -397,7 +397,7 @@ struct PaymentTransactionDetails: Decodable {
var refundQueryActive: Bool?
var posConfirmation: String?
}
-struct PaymentTransaction : Sendable{
+struct PaymentTransaction : Sendable {
var common: TransactionCommon
var details: PaymentTransactionDetails
}
diff --git a/TalerWallet1/Views/Balances/SendRequestV.swift b/TalerWallet1/Views/Balances/SendRequestV.swift
@@ -71,9 +71,9 @@ struct SendRequestV: View {
RequestPayment(stack: stack.push("\(Self.className())()"),
currencyInfo: $currencyInfo,
amountToTransfer: $amountToTransfer, // with correct currency
- summary: $summary,
- scopeInfo: scope,
- cameraAction: cameraAction)
+ summary: $summary,
+ scopeInfo: scope,
+ cameraAction: cameraAction)
}
let disableSend = amountAvailable.isZero //?? false
let twoRowButtons = TwoRowButtons(stack: stack.push(),
diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
@@ -153,7 +153,7 @@ struct CurrencyInputView: View {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
hasBeenShown = true
if !currencyField.becomeFirstResponder() {
- print("❗️Yikes❗️")
+ print("❗️Yikes❗️ cannot becomeFirstResponder")
}
}
}
diff --git a/TalerWallet1/Views/Overview/OverviewRowV.swift b/TalerWallet1/Views/Overview/OverviewRowV.swift
@@ -93,24 +93,24 @@ struct OverviewRowV: View {
#if DEBUG
struct OverviewRowV_Previews: PreviewProvider {
@MainActor
- struct StateContainer: View {
+ struct StateContainer: View {
@State private var currencyInfoD: CurrencyInfo = CurrencyInfo.zero(DEMOCURRENCY)
@State private var currencyInfoT: CurrencyInfo = CurrencyInfo.zero(TESTCURRENCY)
- var body: some View {
- let test = Amount(currency: TESTCURRENCY, cent: 123)
- let demo = Amount(currency: DEMOCURRENCY, cent: 123456)
+ var body: some View {
+ let test = Amount(currency: TESTCURRENCY, cent: 123)
+ let demo = Amount(currency: DEMOCURRENCY, cent: 123456)
- List {
- Section {
- OverviewRowV(stack: CallStack("Preview"), currencyInfo: $currencyInfoD, amount: demo,
+ List {
+ Section {
+ OverviewRowV(stack: CallStack("Preview"), currencyInfo: $currencyInfoD, amount: demo,
+ sendAction: {}, recvAction: {}, rowAction: {}, balanceDest: nil)
+ }
+ OverviewRowV(stack: CallStack("Preview"), currencyInfo: $currencyInfoT, amount: test,
sendAction: {}, recvAction: {}, rowAction: {}, balanceDest: nil)
}
- OverviewRowV(stack: CallStack("Preview"), currencyInfo: $currencyInfoT, amount: test,
- sendAction: {}, recvAction: {}, rowAction: {}, balanceDest: nil)
}
}
- }
static var previews: some View {
StateContainer()
diff --git a/TalerWallet1/Views/Peer2peer/P2PReadyV.swift b/TalerWallet1/Views/Peer2peer/P2PReadyV.swift
@@ -16,7 +16,7 @@ struct P2PReadyV: View {
@Binding var currencyInfo: CurrencyInfo
let summary: String
let expireDays: UInt
- let amountToSend: Bool
+ let outgoing: Bool
let amountToTransfer: Amount
@Binding var transactionStarted: Bool
@@ -91,7 +91,7 @@ struct P2PReadyV: View {
let terms = PeerContractTerms(amount: amountToTransfer,
summary: summary,
purse_expiration: timestamp)
- if amountToSend {
+ if outgoing {
// TODO: let user choose baseURL
if let response = try? await model.initiatePeerPushDebitM(nil, terms: terms) {
// will switch from WithdrawProgressView to TransactionSummaryV
diff --git a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
@@ -24,7 +24,7 @@ struct P2PSubjectV: View {
@Binding var currencyInfo: CurrencyInfo
let feeLabel: String?
let feeIsNotZero: Bool? // nil = no fees at all, false = no fee for this tx
- let amountToSend: Bool
+ let outgoing: Bool
@Binding var amountToTransfer: Amount
@Binding var summary: String
@Binding var expireDays: UInt
@@ -40,20 +40,20 @@ struct P2PSubjectV: View {
private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String {
let amountWithCurrency = amount.formatted(currencyInfo, isNegative: false, useISO: true)
- return amountToSend ? String(localized: "Send \(amountWithCurrency) now",
- comment: "amount with currency")
- : String(localized: "Request \(amountWithCurrency)",
- comment: "amount with currency")
+ return outgoing ? String(localized: "Send \(amountWithCurrency) now",
+ comment: "amount with currency")
+ : String(localized: "Request \(amountWithCurrency)",
+ comment: "amount with currency")
}
private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String {
let amountStr = amount.formatted(currencyInfo, isNegative: false)
- return amountToSend ? String(localized: "NavTitle_Send_AmountStr",
- defaultValue: "Send \(amountStr)",
- comment: "NavTitle: Send 'amountStr'")
- : String(localized: "NavTitle_Request_AmountStr",
- defaultValue: "Request \(amountStr)",
- comment: "NavTitle: Request 'amountStr'")
+ return outgoing ? String(localized: "NavTitle_Send_AmountStr",
+ defaultValue: "Send \(amountStr)",
+ comment: "NavTitle: Send 'amountStr'")
+ : String(localized: "NavTitle_Request_AmountStr",
+ defaultValue: "Request \(amountStr)",
+ comment: "NavTitle: Request 'amountStr'")
}
var body: some View {
@@ -106,7 +106,7 @@ struct P2PSubjectV: View {
.accessibilityValue(String(localized: "\(summary.count) characters of 100"))
// TODO: compute max Expiration day from peerPushCheck to disable 30 (and even 7)
- SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS, outgoing: amountToSend)
+ SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS, outgoing: outgoing)
.disabled(false)
.padding(.bottom)
@@ -116,7 +116,7 @@ struct P2PSubjectV: View {
currencyInfo: $currencyInfo,
summary: summary,
expireDays: expireDays,
- amountToSend: amountToSend,
+ outgoing: outgoing,
amountToTransfer: amountToTransfer,
transactionStarted: $transactionStarted)
}) {
@@ -137,7 +137,7 @@ struct P2PSubjectV: View {
// print("❗️ P2PSubjectV onDisappear")
}
.task(id: amountToTransfer.value) {
- if amountToSend && feeLabel == nil {
+ if outgoing && feeLabel == nil {
if let ppCheck = try? await model.checkPeerPushDebitM(amountToTransfer) {
if let feeAmount = p2pFee(ppCheck: ppCheck) {
let feeStr = feeAmount.formatted(currencyInfo, isNegative: false)
diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
@@ -84,7 +84,7 @@ struct RequestPayment: View {
currencyInfo: $currencyInfo,
feeLabel: coinData.feeLabel(currencyInfo),
feeIsNotZero: feeIsNotZero(),
- amountToSend: false,
+ outgoing: false,
amountToTransfer: $amountToTransfer,
summary: $summary,
expireDays: $expireDays)
@@ -94,7 +94,7 @@ struct RequestPayment: View {
currencyInfo: $currencyInfo,
feeLabel: nil,
feeIsNotZero: feeIsNotZero(),
- amountToSend: false,
+ outgoing: false,
amountToTransfer: $amountShortcut,
summary: $summary,
expireDays: $expireDays)
diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -124,7 +124,7 @@ struct SendAmount: View {
currencyInfo: $currencyInfo,
feeLabel: feeLabel(feeStr),
feeIsNotZero: feeIsNotZero(),
- amountToSend: true,
+ outgoing: true,
amountToTransfer: $amountToTransfer, // from the textedit
summary: $summary,
expireDays: $expireDays)
@@ -134,7 +134,7 @@ struct SendAmount: View {
currencyInfo: $currencyInfo,
feeLabel: nil,
feeIsNotZero: feeIsNotZero(),
- amountToSend: true,
+ outgoing: true,
amountToTransfer: $amountShortcut, // from the tapped shortcut button
summary: $summary,
expireDays: $expireDays)
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
@@ -161,7 +161,7 @@ struct PayTemplateV: View {
.background(NavigationLink(destination: finalDestinationI, isActive: $buttonSelected1)
{ EmptyView() }.frame(width: 0).opacity(0).hidden())
}
- }
+ } // ScrollView
} else if summaryIsEditable { // template contract summary is not fixed => let the user input a summary
ScrollView {
inputDestination
@@ -195,17 +195,21 @@ struct PayTemplateV: View {
LoadingView(scopeInfo: nil, message: url.host)
.task {
if let details = try? await model.checkPayForTemplateM(url.absoluteString) {
+ /// checkPayForTemplateM does not provide fees (yet)
let contract = details.templateDetails.templateContract // specifies fixed amount/summary
amountIsEditable = contract.amount == nil
summaryIsEditable = contract.summary == nil
let defaults = details.templateDetails.editableDefaults // might be nil, or its fields might be nil
+ // TODO: let the user choose a currency from supportedCurrencies[]
let prepCurrency = contract.currency ?? defaults?.currency ??
(details.supportedCurrencies.count > 0 ? details.supportedCurrencies[0]
- : String(localized: "UNKNOWN", comment: "merchant didn't specify the currency, use ALL CAPS"))
+ : UNKNOWN)
let zeroAmount = Amount(currency: prepCurrency, cent: 0)
let prepAmount = contract.amount ?? defaults?.amount // might be nil
let prepSummary = contract.summary ?? defaults?.summary // might be nil
// symLog.log("LoadingView.task preparePayForTemplate")
+ /// preparePayForTemplate will make a network call to the merchant and create a TX
+ /// -> we only want to do this after the user entered amount and subject - but before confirmation of course
// if let result = await preparePayForTemplate(model: model,
// url: url,
// amount: amountIsEditable ? prepAmount ?? zeroAmount
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift b/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift
@@ -192,12 +192,12 @@ struct ThreeAmounts_Previews: PreviewProvider {
common: common, topAbbrev: "Withdrawal",
topTitle: "Withdrawal", baseURL: DEMOEXCHANGE, noFees: false,
large: 1==0, summary: nil, merchant: nil)
- .safeAreaInset(edge: .bottom) {
- Button(String(localized: "Accept"), action: {})
- .buttonStyle(TalerButtonStyle(type: .prominent))
- .padding(.horizontal)
- .disabled(true)
- }
+ .safeAreaInset(edge: .bottom) {
+ Button(String(localized: "Accept"), action: {})
+ .buttonStyle(TalerButtonStyle(type: .prominent))
+ .padding(.horizontal)
+ .disabled(true)
+ }
}
}
}