commit 4a8e217b08d7e9b735ffb657d2660556bc945923 parent 407d4a7cd017e66c830bb49752d49fdd5c7169d7 Author: Marc Stibane <marc@taler.net> Date: Mon, 10 Jul 2023 13:28:49 +0200 no need to call urlCommand async Diffstat:
| M | TalerWallet1/Views/Sheets/URLSheet.swift | | | 43 | +++++++++++++++++-------------------------- |
1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/TalerWallet1/Views/Sheets/URLSheet.swift b/TalerWallet1/Views/Sheets/URLSheet.swift @@ -11,36 +11,27 @@ struct URLSheet: View { var urlToOpen: URL @EnvironmentObject private var controller: Controller - @State private var urlCommand: UrlCommand? = nil - var body: some View { + let urlCommand = controller.openURL(urlToOpen) + Group { - if let urlCommand { - switch urlCommand { - case .withdraw: - WithdrawURIView(url: urlToOpen) - case .pay: - PaymentURIView(url: urlToOpen) - case .payPull: - P2pPayURIView(url: urlToOpen) - case .payPush: - P2pReceiveURIView(url: urlToOpen) - case .unknown: + switch urlCommand { + case .withdraw: + WithdrawURIView(url: urlToOpen) + case .pay: + PaymentURIView(url: urlToOpen) + case .payPull: + P2pPayURIView(url: urlToOpen) + case .payPush: + P2pReceiveURIView(url: urlToOpen) + case .unknown: // Error view + VStack { Text("unknown command") - } - } else { - VStack { // Error view - Spacer() - Text(controller.messageForSheet ?? urlToOpen.absoluteString) - .font(.title) - Spacer() - Spacer() - } - .navigationTitle(navTitle) + .font(.title) + Text(controller.messageForSheet ?? urlToOpen.absoluteString) + } + .navigationTitle(navTitle) } - }.task { - symLog.log(urlToOpen) - urlCommand = controller.openURL(urlToOpen) } } }