taler-ios

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

commit 6e3ef769dbabd57809ef28dc5066acd4fe4891a0
parent 763554efd0542006e5a5c999eff88385995da421
Author: Marc Stibane <marc@taler.net>
Date:   Fri, 30 May 2025 20:39:25 +0200

QRCodewithNFC

Diffstat:
MTalerWallet1/Views/HelperViews/QRCodeDetailView.swift | 57+++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift @@ -9,6 +9,38 @@ import SwiftUI import taler_swift import AVFoundation +@available(iOS 18.3, *) +struct QRCodewithNFC<Content: View>: View { + let talerURI: String + var content: () -> Content + + @AppStorage("minimalistic") var minimalistic: Bool = false + @StateObject private var tagEmulation = TagEmulation() + + var body: some View { + if tagEmulation.canUseHCE { + if !minimalistic { + Text("Tap QR for NFC:") + } + let screenWidth = UIScreen.screenWidth + GradientBorder(size: screenWidth/1.8, + color: .accentColor, + background: WalletColors().backgroundColor) + { + content() + .onTapGesture { + tagEmulation.emulateTag(talerURI) + } + } + .onDisappear() { + tagEmulation.killEmulation() + } + } else { + content() + } + } +} + struct QRCodeDetailView: View { let talerURI: String let talerCopyShare: String @@ -58,19 +90,20 @@ struct QRCodeDetailView: View { var body: some View { if talerURI.count > 10 { Section { + let qrView = QRGeneratorView(text: talerURI) + .frame(maxWidth: .infinity, alignment: .center) Group { -// if #available(iOS 16.4, *) { -// let screenWidth = UIScreen.screenWidth -// GradientBorder(size: screenWidth/1.8, -// color: .accentColor, -// background: WalletColors().backgroundColor) { -// QRGeneratorView(text: talerURI) -// .frame(maxWidth: .infinity, alignment: .center) -// } -// } else { - QRGeneratorView(text: talerURI) - .frame(maxWidth: .infinity, alignment: .center) -// } +#if TALER_NIGHTLY || GNU_TALER + if #available(iOS 18.3, *) { + QRCodewithNFC(talerURI: talerURI) { + qrView + } + } else { + qrView + } +#else + qrView +#endif } .accessibilityLabel(Text("QR Code", comment: "a11y")) .listRowSeparator(.hidden)