commit 28d896ab5d3f11a0ab9f97f1a8c304f31830b5b1
parent ebd67d9a3f0dfc1c464b09386f7c18b3e86f9acb
Author: Marc Stibane <marc@taler.net>
Date: Thu, 30 Jul 2026 09:00:06 +0200
w.i.p.: try to automatically write back totp codes after payment
Diffstat:
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/GradientBorder.swift b/TalerWallet1/Views/HelperViews/GradientBorder.swift
@@ -126,6 +126,7 @@ extension FixedWidthInteger {
struct BorderWithNFC<Content: View>: View {
let totpString: String // might be a TOTP code
let nfcHint: Bool
+ let automaticNfc: Bool?
let size: CGFloat
let scanHints: (String, String)?
var content: () -> Content
@@ -134,6 +135,7 @@ struct BorderWithNFC<Content: View>: View {
@AppStorage("showQRauto16") var showQRauto16: Bool = true // iOS 16 doesn't have NFC emulation
@AppStorage("showQRauto17") var showQRauto17: Bool = false // but iOS 17 does
@State private var showTOTP = false
+ @State private var didWriteTOTP = false
@ObservedObject var nfcWriter = NFCWriter()
var lockImage: Image { // "lock.badge.clock"
@@ -178,7 +180,16 @@ struct BorderWithNFC<Content: View>: View {
if true { // TODO: check for write capabilities
VStack {
- if nfcHint { // QRCodeDetailView
+ if let automaticNfc, automaticNfc, !didWriteTOTP {
+ Text("\(nfcLogo) Point your iPhone to the NFC device")
+ .tint(WalletColors().primaryAccent)
+ .task {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.9) {
+ nfcWriter.write(totpData)
+ didWriteTOTP = true
+ }
+ }
+ } else if nfcHint { // QRCodeDetailView
if showTOTP {
if !minimalistic {
Text("\(nfcLogo) Tap for NFC")
diff --git a/TalerWallet1/Views/Transactions/TransactionPayDetailV.swift b/TalerWallet1/Views/Transactions/TransactionPayDetailV.swift
@@ -29,10 +29,13 @@ struct TransactionPayDetailV: View {
.listRowSeparator(.hidden)
let totp = Text(posConfirmation)
.talerFont(.title1)
+ let posConfirmationViaNfc = details.posConfirmationViaNfc
+ let isPaying = common.isDialog // We are ALWAYS already finished with the tx
if #available(iOS 17.7, *) {
- BorderWithNFC(totpString: posConfirmation, nfcHint: true, size: 250, scanHints: nil) {
- totp
- }
+ BorderWithNFC(totpString: posConfirmation, nfcHint: true,
+ automaticNfc: isPaying ? posConfirmationViaNfc : false,
+ size: 250, scanHints: nil
+ ) { totp }
} else {
totp
}