From 1573b7af13c2c2a056313ee75b7ebc3d2cd886e4 Mon Sep 17 00:00:00 2001 From: Diogo Date: Tue, 11 Jun 2024 06:29:53 +0100 Subject: [PATCH] ios: prevented error on desktop in lack of camera permissions (#4306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 moved ScannerInView to separate module made it more extensible and ready to be reused * fix: 🐛 prevented error on desktop in lack of camera permissions right now, connect to desktop functionality was failing if you didn't accept permissions before jumping to this screen for the first time. In here I did pick from other sections where cases of no permissions or unknown permissions were correctly handled and did reuse the same mechanism * chore: 🤖 reverted file move * chore: 🤖 reverted class change * chore: 🤖 reverted uncessary change * chore: 🤖 removed leftover --- apps/ios/Shared/Views/NewChat/NewChatView.swift | 4 +++- .../Shared/Views/RemoteAccess/ConnectDesktopView.swift | 10 ++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/ios/Shared/Views/NewChat/NewChatView.swift b/apps/ios/Shared/Views/NewChat/NewChatView.swift index 7ece4fdee6..442f933ace 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatView.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatView.swift @@ -367,11 +367,12 @@ struct ScannerInView: View { @Binding var showQRCodeScanner: Bool let processQRCode: (_ resp: Result) -> Void @State private var cameraAuthorizationStatus: AVAuthorizationStatus? + var scanMode: ScanMode = .continuous var body: some View { Group { if showQRCodeScanner, case .authorized = cameraAuthorizationStatus { - CodeScannerView(codeTypes: [.qr], scanMode: .continuous, completion: processQRCode) + CodeScannerView(codeTypes: [.qr], scanMode: scanMode, completion: processQRCode) .aspectRatio(1, contentMode: .fit) .cornerRadius(12) .listRowBackground(Color.clear) @@ -436,6 +437,7 @@ struct ScannerInView: View { } } + private func linkTextView(_ link: String) -> some View { Text(link) .lineLimit(1) diff --git a/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift b/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift index 1d47d9a936..c749e09ca8 100644 --- a/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift +++ b/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift @@ -333,16 +333,10 @@ struct ConnectDesktopView: View { } } } - + private func scanDesctopAddressView() -> some View { Section("Scan QR code from desktop") { - CodeScannerView(codeTypes: [.qr], scanMode: .oncePerCode, completion: processDesktopQRCode) - .aspectRatio(1, contentMode: .fit) - .cornerRadius(12) - .listRowBackground(Color.clear) - .listRowSeparator(.hidden) - .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) - .padding(.horizontal) + ScannerInView(showQRCodeScanner: $showQRCodeScanner, processQRCode: processDesktopQRCode, scanMode: .oncePerCode) } }