QRcodesForPayto.swift (2944B)
1 /* 2 * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. 3 * See LICENSE.md 4 */ 5 /** 6 * @author Marc Stibane 7 */ 8 import SwiftUI 9 import OrderedCollections 10 import taler_swift 11 12 struct QRcodeCopyShare: View { 13 let spec: QrCodeSpec 14 15 @State private var qrImage: UIImage? = nil 16 17 var body: some View { 18 Text(spec.type) 19 let size = 200.0 20 QRGeneratorView(text: spec.qrContent, size: size, image: $qrImage) 21 .frame(maxWidth: .infinity, alignment: .center) 22 .accessibilityLabel(Text("QR Code", comment: "a11y")) 23 .listRowSeparator(.hidden) 24 HStack { 25 Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator 26 .accessibilityHidden(true) 27 .foregroundColor(Color.clear) 28 // Spacer() 29 CopyShare(textToCopy: spec.qrContent, image: qrImage) 30 .disabled(false) 31 }.listRowSeparator(.automatic) 32 } 33 } 34 35 struct QRcodesForPayto: View { 36 let stack: CallStack 37 @Binding var qrCodeSpecs: [QrCodeSpec] 38 let navTitle = String(localized: "Wire transfer", comment: "ViewTitle of wire-transfer QR codes") 39 40 @AppStorage("minimalistic") var minimalistic: Bool = false 41 42 var body: some View { 43 List { 44 if !minimalistic { 45 Text("If your banking software runs on another device, you can scan one of these QR codes:") 46 .listRowSeparator(.hidden) 47 } 48 ForEach(qrCodeSpecs, id: \.self) { spec in 49 QRcodeCopyShare(spec: spec) 50 } 51 } 52 .navigationTitle(navTitle) 53 .onAppear() { 54 // symLog.log("onAppear") 55 DebugViewC.shared.setViewID(VIEW_WITHDRAW_QRCODES, stack: stack.push()) 56 } 57 } 58 } 59 // MARK: - 60 #if DEBUG 61 //struct QRcodesForPayto_Previews: PreviewProvider { 62 // static var previews: some View { 63 // let common = TransactionCommon(type: .withdrawal, 64 // txState: TransactionState(major: .done), 65 // amountEffective: Amount(currency: LONGCURRENCY, cent: 110), 66 // amountRaw: Amount(currency: LONGCURRENCY, cent: 220), 67 // transactionId: "someTxID", 68 // timestamp: Timestamp(from: 1_666_666_000_000), 69 // txActions: []) 70 // let payto = "payto://iban/SANDBOXX/DE159593?receiver-name=Exchange+Company" 71 // let details = WithdrawalDetails(type: .manual, 72 // reservePub: "ReSeRvEpUbLiC_KeY_FoR_WiThDrAwAl", 73 // reserveIsReady: false, 74 // confirmed: false) 75 // List { 76 // QRcodesForPayto(stack: CallStack("Preview"), qrCodeSpecs: details) 77 // } 78 // } 79 //} 80 #endif