commit 19745a240c51c38a867d3fdfc8f02a0acc8471fb
parent 8aa2eb2ab76c06e702a57d00f1afa6d53ad8c241
Author: Marc Stibane <marc@taler.net>
Date: Thu, 8 Feb 2024 17:19:59 +0100
CallStack
Diffstat:
7 files changed, 50 insertions(+), 34 deletions(-)
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
@@ -29,7 +29,8 @@ struct P2pPayURIView: View {
let effective = peerPullDebitResponse.amountEffective
let currency = raw.currencyStr
let fee = try! Amount.diff(raw, effective)
- ThreeAmountsV(topTitle: String(localized: "Amount to pay:"),
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: String(localized: "Amount to pay:"),
topAbbrev: String(localized: "Pay:", comment: "mini"),
topAmount: raw, fee: fee,
bottomTitle: String(localized: "Amount to be spent:"),
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
@@ -37,7 +37,8 @@ struct P2pReceiveURIView: View {
let effective = peerPushCreditResponse.amountEffective
let currency = raw.currencyStr
let fee = try! Amount.diff(raw, effective)
- ThreeAmountsV(topTitle: String(localized: "Gross Amount to receive:"),
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: String(localized: "Gross Amount to receive:"),
topAbbrev: String(localized: "Receive gross:", comment: "mini"),
topAmount: raw, fee: fee,
bottomTitle: String(localized: "Net Amount to receive:"),
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift
@@ -59,7 +59,8 @@ struct PayTemplateView: View {
if let effective {
// TODO: already paid
let fee = try! Amount.diff(raw, effective) // TODO: different currencies
- ThreeAmountsV(topTitle: topTitle,
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: topTitle,
topAbbrev: topAbbrev,
topAmount: raw, fee: fee,
bottomTitle: String(localized: "Amount to spend:"),
@@ -74,7 +75,8 @@ struct PayTemplateView: View {
} else if let balanceDetails = preparePayResult.balanceDetails { // Insufficient
Text("You don't have enough \(currency)")
.accessibilityFont(.body)
- ThreeAmountsV(topTitle: topTitle,
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: topTitle,
topAbbrev: topAbbrev,
topAmount: raw, fee: nil,
bottomTitle: String(localized: "Amount available:"),
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -36,7 +36,8 @@ struct PaymentView: View {
if let effective {
// TODO: already paid
let fee = try! Amount.diff(raw, effective) // TODO: different currencies
- ThreeAmountsV(topTitle: topTitle,
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: topTitle,
topAbbrev: topAbbrev,
topAmount: raw, fee: fee,
bottomTitle: String(localized: "Amount to spend:"),
@@ -51,7 +52,8 @@ struct PaymentView: View {
} else if let balanceDetails = preparePayResult.balanceDetails { // Insufficient
Text("You don't have enough \(currency)")
.accessibilityFont(.headline)
- ThreeAmountsV(topTitle: topTitle,
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: topTitle,
topAbbrev: topAbbrev,
topAmount: raw, fee: nil,
bottomTitle: String(localized: "Amount available:"),
diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift
@@ -43,7 +43,8 @@ struct WithdrawURIView: View {
let outColor = WalletColors().transactionColor(false)
let inColor = WalletColors().transactionColor(true)
- ThreeAmountsV(topTitle: String(localized: "Chosen amount to withdraw:"),
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: String(localized: "Chosen amount to withdraw:"),
topAbbrev: String(localized: "Chosen:", comment: "mini"),
topAmount: raw, fee: fee,
bottomTitle: String(localized: "Amount to be withdrawn:"),
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
@@ -6,6 +6,7 @@ import SwiftUI
import taler_swift
struct ThreeAmountsSheet: View {
+ let stack: CallStack
var common: TransactionCommon
var topAbbrev: String
var topTitle: String
@@ -33,19 +34,22 @@ struct ThreeAmountsSheet: View {
: String(localized: "Obtained:", comment: "mini") )
: (pending ? String(localized: "Pay:", comment: "mini")
: String(localized: "Paid:", comment: "mini") )
- ThreeAmountsV(topTitle: topTitle, topAbbrev: topAbbrev, topAmount: raw, fee: fee,
- bottomTitle: bottomTitle ?? defaultBottomTitle,
- bottomAbbrev: bottomAbbrev ?? defaultBottomAbbrev,
- bottomAmount: incomplete ? nil : effective,
- large: large, pending: pending, incoming: incoming,
- baseURL: baseURL,
- status: common.txState.major.localizedState,
- summary: summary,
- merchant: merchant)
+ ThreeAmountsV(stack: stack.push(),
+ topTitle: topTitle, topAbbrev: topAbbrev,
+ topAmount: raw, fee: fee,
+ bottomTitle: bottomTitle ?? defaultBottomTitle,
+ bottomAbbrev: bottomAbbrev ?? defaultBottomAbbrev,
+ bottomAmount: incomplete ? nil : effective,
+ large: large, pending: pending, incoming: incoming,
+ baseURL: baseURL,
+ status: common.txState.major.localizedState,
+ summary: summary,
+ merchant: merchant)
}
}
// MARK: -
struct ThreeAmountsV: View {
+ let stack: CallStack
var topTitle: String
var topAbbrev: String
var topAmount: Amount
@@ -88,7 +92,7 @@ struct ThreeAmountsV: View {
.accessibilityElement(children: .combine)
if let fee {
AmountRowV(title: minimalistic ? String(localized: "Fee (short):", defaultValue:"Fee:", comment:"short version")
- : String(localized: "Fee (long):", defaultValue:"Fee:", comment:"long version"),
+ : String(localized: "Fee (long):", defaultValue:"Fee:", comment:"long version"),
amount: fee,
color: labelColor,
large: false)
@@ -141,9 +145,10 @@ struct ThreeAmounts_Previews: PreviewProvider {
txActions: [])
Group {
List {
- ThreeAmountsSheet(common: common, topAbbrev: "Withdrawal",
- topTitle: "Withdrawal", baseURL: DEMOEXCHANGE,
- large: 1==0, summary: nil, merchant: nil)
+ ThreeAmountsSheet(stack: CallStack("Preview"),
+ common: common, topAbbrev: "Withdrawal",
+ topTitle: "Withdrawal", baseURL: DEMOEXCHANGE,
+ large: 1==0, summary: nil, merchant: nil)
.safeAreaInset(edge: .bottom) {
Button(String(localized: "Accept"), action: {})
.buttonStyle(TalerButtonStyle(type: .prominent))
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -137,7 +137,8 @@ struct TransactionSummaryV: View {
}
} .listRowSeparator(.automatic)
.accessibilityFont(.title)
- TypeDetail(transaction: $transaction, hasDone: doneAction != nil)
+ TypeDetail(stack: stack.push(),
+ transaction: $transaction, hasDone: doneAction != nil)
// if transaction.isRetryable { if let retryAction {
// TransactionButton(transactionId: common.transactionId, command: .retry,
@@ -238,6 +239,7 @@ struct TransactionSummaryV: View {
}
struct TypeDetail: View {
+ let stack: CallStack
@Binding var transaction: Transaction
let hasDone: Bool
@@ -275,27 +277,25 @@ struct TransactionSummaryV: View {
} } } }
} // switch
} // ManualDetails or Confirm now (with bank)
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Chosen:", comment: "mini"),
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Chosen:", comment: "mini"),
topTitle: String(localized: "Chosen amount to withdraw:"),
baseURL: details.exchangeBaseUrl, large: false,
summary: nil, merchant: nil)
}
case .deposit(let depositTransaction): Group {
let details = depositTransaction.details
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Deposit:", comment: "mini"),
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Deposit:", comment: "mini"),
topTitle: String(localized: "Amount to deposit:"),
baseURL: nil, large: true, // TODO: baseURL
summary: nil, merchant: nil)
}
case .payment(let paymentTransaction): Group {
let details = paymentTransaction.details
- NavigationLink(destination: LazyView {
- LoadingView(url: nil, message: "Details")
- }) {
- Text("Show details")
- }
-// .buttonStyle(TalerButtonStyle(type: .bordered))
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Price:", comment: "mini"),
+// TransactionDetailV(paymentTx: paymentTransaction)
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Price:", comment: "mini"),
topTitle: String(localized: "Price (net):"),
baseURL: nil, large: true, // TODO: baseURL
summary: details.info.summary,
@@ -303,7 +303,8 @@ struct TransactionSummaryV: View {
}
case .refund(let refundTransaction): Group {
let details = refundTransaction.details // TODO: more details
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Refunded:", comment: "mini"),
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Refunded:", comment: "mini"),
topTitle: String(localized: "Refunded amount:"),
baseURL: nil, large: true, // TODO: baseURL
summary: details.info?.summary,
@@ -311,7 +312,8 @@ struct TransactionSummaryV: View {
}
case .reward(let rewardTransaction): Group {
let details = rewardTransaction.details
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Reward:", comment: "mini"),
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Reward:", comment: "mini"),
topTitle: String(localized: "Received Reward:"),
baseURL: details.exchangeBaseUrl, large: true,
summary: nil, merchant: nil) // TODO: summary
@@ -319,7 +321,8 @@ struct TransactionSummaryV: View {
case .refresh(let refreshTransaction): Group {
let details = refreshTransaction.details // TODO: details
Text(details.refreshReason.rawValue)
- ThreeAmountsSheet(common: common, topAbbrev: String(localized: "Refreshed:", comment: "mini"),
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common, topAbbrev: String(localized: "Refreshed:", comment: "mini"),
topTitle: String(localized: "Refreshed amount:"),
baseURL: nil, large: true, // TODO: baseURL
summary: nil, merchant: nil)
@@ -353,7 +356,8 @@ struct TransactionSummaryV: View {
let colon = ":"
let localizedType = transaction.isDone ? transaction.localizedTypePast
: transaction.localizedType
- ThreeAmountsSheet(common: common,
+ ThreeAmountsSheet(stack: stack.push(),
+ common: common,
topAbbrev: localizedType + colon,
topTitle: localizedType + colon,
baseURL: details.exchangeBaseUrl, large: false,