TransactionPayDetailV.swift (4160B)
1 /* 2 * This file is part of GNU Taler, ©2022-26 Taler Systems S.A. 3 * See LICENSE.md 4 */ 5 /** 6 * Overview when there's more than 1 currency/exchange 7 * 8 * @author Marc Stibane 9 */ 10 import SwiftUI 11 12 struct TransactionPayDetailV: View { 13 let stack: CallStack 14 let paymentTx: PaymentTransaction 15 16 #if DEBUG 17 @AppStorage("developerMode") var developerMode: Bool = true 18 #else 19 @AppStorage("developerMode") var developerMode: Bool = false 20 #endif 21 22 var body: some View { 23 let common = paymentTx.common 24 let details = paymentTx.details 25 let info = details.info 26 Section { 27 if let posConfirmation = details.posConfirmation { 28 Text("Confirmation:", comment: "purchase may have a pos validation / confirmation") 29 .talerFont(.title3) 30 .listRowSeparator(.hidden) 31 let totp = Text(posConfirmation) 32 .talerFont(.title1) 33 let posConfirmationViaNfc = details.posConfirmationViaNfc 34 let isPaying = common.isDialog // We are ALWAYS already finished with the tx 35 if #available(iOS 17.7, *) { 36 BorderWithNFC(totpString: posConfirmation, nfcHint: true, 37 automaticNfc: isPaying ? posConfirmationViaNfc : false, 38 size: 250, scanHints: nil 39 ) { totp } 40 } else { 41 totp 42 } 43 } 44 // Text(info.summary) 45 if let info { 46 // Text(info.merchant.name) TODO: show name & logo here? 47 Text("Order-ID:") 48 .talerFont(.title3) 49 .listRowSeparator(.hidden) 50 Text(info.orderId) 51 .talerFont(.body) 52 53 if let fulfillmentUrl = info.fulfillmentUrl { 54 if let destination = URL(string: fulfillmentUrl) { 55 let buttonTitle = info.fulfillmentMessage ?? String(localized: "Open merchant website") 56 Link(buttonTitle, destination: destination) 57 .buttonStyle(TalerButtonStyle(type: .prominent)) 58 .accessibilityHint(String(localized: "Will go to the merchant website.", comment: "a11y")) 59 } 60 } else if let fulfillmentMessage = info.fulfillmentMessage { 61 Text(fulfillmentMessage) 62 .talerFont(.body) 63 } 64 } 65 if let failReason = common.failReason { 66 if let hint = failReason.hint { 67 Text(hint) 68 .talerFont(.title3) 69 } 70 } 71 if let abortReason = details.abortReason { 72 if let exchangeResponse = abortReason.exchangeResponse, 73 let hint2 = exchangeResponse.hint { 74 Text(hint2) 75 .talerFont(.body) 76 } 77 if developerMode { 78 if let hint3 = abortReason.hint { 79 Text(hint3) 80 .talerFont(.body) 81 } 82 } 83 } 84 if let choiceIndex = details.choiceIndex { 85 if let contractTerms = details.contractTerms { 86 if let choices = contractTerms.choices, 87 choices.indices.contains(choiceIndex) { 88 let choice = choices[choiceIndex] 89 Text(choice.descI18n ?? "Index: \(choiceIndex)") // should never happen 90 .talerFont(.body) 91 } 92 } 93 } 94 } 95 if let products = info?.products { 96 ForEach(products) { product in 97 if let product_id = product.product_id { 98 Section { 99 Text(product_id) 100 .talerFont(.body) 101 } 102 } 103 } 104 } 105 } 106 } 107 108 // MARK: - 109 //#Preview { 110 // TransactionDetailV() 111 //}