taler-ios

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

commit f87b3169d407635aa9a6ad4f1543742ed1b97410
parent ba3c5f1ea54944cf447efb476531491a5b723c77
Author: Marc Stibane <marc@taler.net>
Date:   Thu,  5 Nov 2026 18:59:09 +0100

TalDir: Export

Diffstat:
MTalerWallet1/Views/TalDir/ContactsView.swift | 79++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 66 insertions(+), 13 deletions(-)

diff --git a/TalerWallet1/Views/TalDir/ContactsView.swift b/TalerWallet1/Views/TalDir/ContactsView.swift @@ -9,26 +9,30 @@ import SwiftUI import taler_swift import SymLog +#if GNU_TALER || TALER_NIGHTLY // MARK: - struct ContactRowView: View { let stack: CallStack let contact: ContactEntry + let index: Int + @Binding var showExport: Int? let talerURI: String? let subject: String? @EnvironmentObject private var model: WalletModel - @State private var showAlert: Bool = false + @State private var showSend: Bool = false + @State private var qrImage: UIImage? = nil private var cancelButton: some View { Button("Cancel", role: .cancel) { - showAlert = false + showSend = false } } private var sendNowButton: some View { Button(contact.petname.isEmpty ? "Send now" : "Send to \(contact.petname)") { - showAlert = false + showSend = false if let talerURI { Task { try? await model.sendTalerUriMailboxMessage(talerURI, @@ -40,14 +44,57 @@ struct ContactRowView: View { } } + var contactURI: String { + var mboxBaseURL = contact.mailboxBaseUrl + if mboxBaseURL.hasPrefix(HTTPS) { + mboxBaseURL.removeFirst(HTTPS.count) + } + var addContact = TALER + "add-contact/" + + contact.aliasType + SLASH + + contact.alias + SLASH + + mboxBaseURL + SLASH + + contact.mailboxAddress + let source = contact.source + if source.isEmpty { + return addContact + } + return addContact + "?sourceBaseUrl=" + + source.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! + } + var body: some View { - let label = VStack(alignment: .leading) { - if !contact.petname.isEmpty { - Text(contact.petname) - .talerFont(.title3) + let label = VStack { + HStack { + VStack(alignment: .leading) { + if !contact.petname.isEmpty { + Text(contact.petname) + .talerFont(.title3) + } + Text(contact.alias) + .talerFont(.body) + } + Spacer() + if showExport == index { + Button("Export") { + showExport = nil + }.buttonStyle(.plain) + } else { + Button("Export") { + showExport = index + }.buttonStyle(.borderless) + } + } + if showExport == index { + let size = 240.0 + QRGeneratorView(image: qrImage, size: size, + logo: nil, logoSize: size / 4) + .task { + print("🚩 \(contactURI)") + if let image = QRCode(from: contactURI) { + qrImage = image + } + } } - Text(contact.alias) - .talerFont(.body) } if let talerURI { // send this to the selected contact @@ -55,17 +102,16 @@ struct ContactRowView: View { .contentShape(.rect) .frame(maxWidth: .infinity, alignment: .leading) .background { - Color.primary.opacity(showAlert ? 0.12 : INVISIBLE) + Color.primary.opacity(showSend ? 0.12 : INVISIBLE) } - .onTapGesture { showAlert.toggle() } + .onTapGesture { showSend.toggle() } .alert("Send to \(contact.petname)", - isPresented: $showAlert, + isPresented: $showSend, actions: { sendNowButton cancelButton }, message: { if let subject { Text(subject) } }) - } else { // edit the selected contact NavigationLink { let title = String(localized: "TitleEditContact", @@ -91,6 +137,7 @@ struct ContactsView: View { @State private var contacts: [ContactEntry]? = nil @State private var showAddDialog: Bool = false + @State private var showExport: Int? = nil var navTitle: String { String(localized: "TitleContacts", defaultValue: "Contacts") @@ -118,6 +165,8 @@ struct ContactsView: View { ForEachWithIndex(array: ownEntries) { index, contact in ContactRowView(stack: stack.push(), contact: contact, + index: index, + showExport: $showExport, talerURI: talerURI, subject: subject) } @@ -127,9 +176,12 @@ struct ContactsView: View { if otherEntries.isEmpty { Text("No contacts yet...") } else { + let count = ownEntries.count ForEachWithIndex(array: otherEntries) { index, contact in ContactRowView(stack: stack.push(), contact: contact, + index: index + count, + showExport: $showExport, talerURI: talerURI, subject: subject) } @@ -151,3 +203,4 @@ struct ContactsView: View { } } // body } +#endif