commit 3770e0b49e113905d8d13017a81343457b46f115
parent 0a71cf14dde80a2a2dfe5afcea59b02a637c6aa3
Author: Marc Stibane <marc@taler.net>
Date: Mon, 3 Aug 2026 18:02:13 +0200
use TransferOption
Diffstat:
2 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -110,8 +110,9 @@ struct ManualDetailsV: View {
}
if let transferOptions = account.transferOptions {
+ if let firstOption = transferOptions.first {
let countA = transferOptions.count
- let countB = transferOptions.first?.qrCodes?.count ?? 0
+ let countB = firstOption.qrCodes?.count ?? 0
if countA > 1 || countB > 1 {
qrCodesRow(transferOptions,
receiverStr: receiverStr,
@@ -120,16 +121,16 @@ struct ManualDetailsV: View {
} else if countA > 0 { // show the single QR directly
// Text("If your banking software runs on another device, you can scan this QR code:")
// .listRowSeparator(.hidden)
- if let qrCodeSpecs = transferOptions.first?.qrCodes {
+ if let qrCodeSpecs = firstOption.qrCodes {
if let qrCode = qrCodeSpecs.first {
let message = payto.messageStr ?? EMPTYSTRING
let textToShare = String(receiverStr + "\n" + amountStr.0 + "\n" + message)
- QRcodeCopyShare(spec: qrCode,
- textToShare: textToShare)
+ QRcodeCopyShare(option: firstOption)
.listRowSeparator(.automatic)
}
}
}
+ }
}
#if DEBUG
if developerMode {
diff --git a/TalerWallet1/Views/Transactions/QRcodesForPayto.swift b/TalerWallet1/Views/Transactions/QRcodesForPayto.swift
@@ -10,24 +10,45 @@ import OrderedCollections
import taler_swift
struct QRcodeCopyShare: View {
- let spec: QrCodeSpec
- let textToShare: String
+ let option: TransferOption
@State private var qrImage: UIImage? = nil
+ func textToShare() -> String? {
+ if let paytoUri = option.paytoUri {
+ let payto = PayTo(paytoUri)
+ if let receiverStr = payto.receiver {
+ if let amountStr = payto.amountStr {
+ if let messageStr = option.qrReferenceNumber ?? payto.messageStr {
+ return String(receiverStr + "\n" + amountStr + "\n" + messageStr)
+ }
+ }
+ }
+ }
+ return nil
+ }
+
var body: some View {
// Text(spec.type)
- let logo = spec.type == "spc" ? Image(SWISS_QR) : nil
- let size = 276.0 // 46x46mm, swiss flag = 7x7mm plus border 276*9/46 = 54
- QRGeneratorView(text: spec.qrContent, size: size, logo: logo, logoSize: size * 9 / 46, image: $qrImage)
- .frame(maxWidth: .infinity, alignment: .center)
- .listRowSeparator(.hidden)
- HStack {
- Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator
- .accessibilityHidden(true)
- .foregroundColor(Color.clear)
- // Spacer()
- CopyShare(textToShare, image: qrImage)
- .disabled(false)
+ if let qrCodes = option.qrCodes {
+ ForEach(qrCodes, id: \.self) { qrCodeSpec in
+ let logo = qrCodeSpec.type == "spc" ? Image(SWISS_QR) : nil
+ let size = 276.0 // 46x46mm, swiss flag = 7x7mm plus border 276*9/46 = 54
+ QRGeneratorView(text: qrCodeSpec.qrContent, size: size,
+ logo: logo, logoSize: size * 9 / 46,
+ image: $qrImage)
+ .frame(maxWidth: .infinity, alignment: .center)
+ .listRowSeparator(.hidden)
+ }
+ }
+ if let textToShare = textToShare() {
+ HStack {
+// Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator
+// .accessibilityHidden(true)
+// .foregroundColor(Color.clear)
+// Spacer()
+ CopyShare(textToShare, image: qrImage)
+ .disabled(false)
+ }
}
}
}
@@ -44,20 +65,14 @@ struct QRcodesForPayto: View {
@AppStorage("minimalistic") var minimalistic: Bool = false
var body: some View {
- let message = messageStr ?? EMPTYSTRING
- let textToShare = String(receiverStr + "\n" + amountStr + "\n" + message)
List {
if !minimalistic {
Text("If your banking software runs on another device, you can scan one of these QR codes:")
.listRowSeparator(.hidden)
}
ForEach(transferOptions, id: \.self) { option in
- if let qrCodes = option.qrCodes {
- ForEach(qrCodes, id: \.self) { spec in
- QRcodeCopyShare(spec: spec, textToShare: textToShare)
- .listRowSeparator(.automatic)
- }
- }
+ QRcodeCopyShare(option: option)
+ .listRowSeparator(.automatic)
}
}
.navigationTitle(navTitle)