TransactionPayDetailV.swift (3861B)
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 paymentTx: PaymentTransaction 14 15 #if DEBUG 16 @AppStorage("developerMode") var developerMode: Bool = true 17 #else 18 @AppStorage("developerMode") var developerMode: Bool = false 19 #endif 20 21 var body: some View { 22 let common = paymentTx.common 23 let details = paymentTx.details 24 let info = details.info 25 Section { 26 if let posConfirmation = details.posConfirmation { 27 Text("Confirmation:", comment: "purchase may have a pos validation / confirmation") 28 .talerFont(.title3) 29 .listRowSeparator(.hidden) 30 let totp = Text(posConfirmation) 31 .talerFont(.title1) 32 if #available(iOS 17.7, *) { 33 BorderWithNFC(totpString: posConfirmation, nfcHint: true, size: 250, scanHints: nil) { 34 totp 35 } 36 } else { 37 totp 38 } 39 } 40 // Text(info.summary) 41 if let info { 42 // Text(info.merchant.name) TODO: show name & logo here? 43 Text("Order-ID:") 44 .talerFont(.title3) 45 .listRowSeparator(.hidden) 46 Text(info.orderId) 47 .talerFont(.body) 48 49 if let fulfillmentUrl = info.fulfillmentUrl { 50 if let destination = URL(string: fulfillmentUrl) { 51 let buttonTitle = info.fulfillmentMessage ?? String(localized: "Open merchant website") 52 Link(buttonTitle, destination: destination) 53 .buttonStyle(TalerButtonStyle(type: .prominent)) 54 .accessibilityHint(String(localized: "Will go to the merchant website.", comment: "a11y")) 55 } 56 } else if let fulfillmentMessage = info.fulfillmentMessage { 57 Text(fulfillmentMessage) 58 .talerFont(.body) 59 } 60 } 61 if let failReason = common.failReason { 62 if let hint = failReason.hint { 63 Text(hint) 64 .talerFont(.title3) 65 } 66 } 67 if let abortReason = details.abortReason { 68 if let exchangeResponse = abortReason.exchangeResponse, 69 let hint2 = exchangeResponse.hint { 70 Text(hint2) 71 .talerFont(.body) 72 } 73 if developerMode { 74 if let hint3 = abortReason.hint { 75 Text(hint3) 76 .talerFont(.body) 77 } 78 } 79 } 80 if let choiceIndex = details.choiceIndex { 81 if let contractTerms = details.contractTerms { 82 if let choices = contractTerms.choices, 83 choices.indices.contains(choiceIndex) { 84 let choice = choices[choiceIndex] 85 Text(choice.descI18n ?? "Index: \(choiceIndex)") // should never happen 86 .talerFont(.body) 87 } 88 } 89 } 90 } 91 if let products = info?.products { 92 ForEach(products) { product in 93 if let product_id = product.product_id { 94 Section { 95 Text(product_id) 96 .talerFont(.body) 97 } 98 } 99 } 100 } 101 } 102 } 103 104 // MARK: - 105 //#Preview { 106 // TransactionDetailV() 107 //}