taler-ios

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

commit 6e6f68033a8e428798d6f9e7e46354166862e3e9
parent 6315ce7b211c6990d409f3f137dca8a9d84a758c
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 20 Jul 2024 07:02:07 +0200

Warning if scanning outgoing from request view

Diffstat:
MTalerWallet1/Views/Sheets/URLSheet.swift | 24+++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/TalerWallet1/Views/Sheets/URLSheet.swift b/TalerWallet1/Views/Sheets/URLSheet.swift @@ -15,15 +15,19 @@ struct URLSheet: View { let navTitle = String(localized: "Checking Link") var urlToOpen: URL + @AppStorage("shouldShowWarning") var shouldShowWarning: Bool = true @EnvironmentObject private var controller: Controller @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) @State private var summary = EMPTYSTRING + @State private var showAlert: Bool = false + @State private var urlCommand: UrlCommand = .unknown + var body: some View { #if PRINT_CHANGES let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let urlCommand = controller.openURL(urlToOpen, stack: stack.push()) + let warning = String(localized: "It seems you wanted to request money - but this transaction will let you pay...") Group { switch urlCommand { @@ -54,6 +58,24 @@ struct URLSheet: View { .navigationTitle(navTitle) } } + .task { + let incomingExpected = controller.frontendState == 1 + let command = controller.openURL(urlToOpen, stack: stack.push()) + if incomingExpected && command.isOutgoing { + showAlert = true + } + urlCommand = command + } + .alert(warning, isPresented: $showAlert, actions: { + Button("Cancel", role: .cancel) { + showAlert = false + dismissTop(stack.push()) + } + Button("OK") { + showAlert = false + } + }, message: { Text("\nWarnings can be switched off in Settings") } + ) } } // MARK: -