taler-ios

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

TransactionPayDetailV.swift (3111B)


      1 /*
      2  * This file is part of GNU Taler, ©2022-25 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             Text("Order-ID:")
     42                 .talerFont(.title3)
     43                 .listRowSeparator(.hidden)
     44             Text(info?.orderId ?? "Unknown")
     45                 .talerFont(.body)
     46 //            Text(info.merchant.name)
     47 
     48             if let info {
     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 abortReason = details.abortReason {
     62                 if let exchangeResponse = abortReason.exchangeResponse,
     63                    let hint2 = exchangeResponse.hint {
     64                     Text(hint2)
     65                         .talerFont(.body)
     66                 }
     67                 if developerMode {
     68                     if let hint = abortReason.hint {
     69                         Text(hint)
     70                             .talerFont(.body)
     71                     }
     72                 }
     73             }
     74         }
     75         if let products = info?.products {
     76             ForEach(products) { product in
     77                 if let product_id = product.product_id {
     78                     Section {
     79                         Text(product_id)
     80                             .talerFont(.body)
     81                     }
     82                 }
     83             }
     84         }
     85     }
     86 }
     87 
     88 // MARK: -
     89 //#Preview {
     90 //    TransactionDetailV()
     91 //}