taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 7881d915b3ea68bc8568919ba4faa0f246367a25
parent b5df75a04c9056bcda0b0cef81502070cfbad66a
Author: Marc Stibane <marc@taler.net>
Date:   Wed,  7 Oct 2026 14:57:31 +0200

simplify

Diffstat:
MTalerWallet1/Views/Sheets/Payment/PaymentScan.swift | 1-
MTalerWallet1/Views/Transactions/PaymentTransactionView.swift | 33++++++++++++++++-----------------
2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentScan.swift b/TalerWallet1/Views/Sheets/Payment/PaymentScan.swift @@ -164,7 +164,6 @@ struct PaymentView2: View, Sendable { let baseURL: String? // let terms: MerchantContractTerms let summary: String? - let products: [ProductSold]? let balanceDetails: PaymentInsufficientBalanceDetails? func computeFee(raw: Amount?, eff: Amount?) -> Amount? { diff --git a/TalerWallet1/Views/Transactions/PaymentTransactionView.swift b/TalerWallet1/Views/Transactions/PaymentTransactionView.swift @@ -115,6 +115,19 @@ struct PaymentTransactionView: View { var isNotClaiming: Bool { !common.isClaiming } + + func selectedOrFirst(_ choices: [ChoiceTriple]) -> ChoiceTriple? { + if let selectedChoice { + if selectedChoice < choices.count { + return choices[selectedChoice] + } + } + if let choice = choices.first { + return choice + } + return nil + } + var body: some View { #if PRINT_CHANGES let _ = Self._printChanges() @@ -164,10 +177,9 @@ struct PaymentTransactionView: View { } } - let summary = details.info?.locSummary ?? - String(localized: "No summary", comment: "OrderShortInfo.summary") - if let selectedChoice { - let choice = choices[selectedChoice] + if let choice = selectedOrFirst(choices) { + let summary = details.info?.locSummary ?? + String(localized: "No summary", comment: "OrderShortInfo.summary") let selectionDetail: ChoiceSelectionDetail = choice.0 // let contractChoice: ContractChoice = choice.1 PaymentView2(stack: stack.push(), // TODO: details.info.merchant.name @@ -177,19 +189,6 @@ struct PaymentTransactionView: View { firstScope: scope, baseURL: nil, summary: summary, - products: terms.products ?? [], - balanceDetails: selectionDetail.balanceDetails) - } else if let choice = choices.first { - let selectionDetail: ChoiceSelectionDetail = choice.0 - - PaymentView2(stack: stack.push(), // TODO: details.info.merchant.name - paid: false, - raw: selectionDetail.amountRaw, - effective: nil, - firstScope: scope, - baseURL: nil, - summary: summary, - products: terms.products ?? [], balanceDetails: selectionDetail.balanceDetails) } } else { // should never happen...