diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 9b714bb..d196fb7 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -203,6 +203,8 @@ EB9925892E45F13500357055 /* QRCode in Frameworks */ = {isa = PBXBuildFile; productRef = EB9925882E45F13500357055 /* QRCode */; }; EBADEB8F2E8029750021B5E4 /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = EBADEB8E2E8029750021B5E4 /* DeviceKit */; }; EBADEB912E802A830021B5E4 /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = EBADEB902E802A830021B5E4 /* DeviceKit */; }; + EBBC93B22EC8B76600F541A1 /* LocalNetworkPermissionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBC93B12EC8B75F00F541A1 /* LocalNetworkPermissionView.swift */; }; + EBBC93B32EC8B76600F541A1 /* LocalNetworkPermissionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBC93B12EC8B75F00F541A1 /* LocalNetworkPermissionView.swift */; }; EBC05C5B2E33937200EECC18 /* ErrorAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC05C5A2E33936C00EECC18 /* ErrorAlertHandler.swift */; }; EBC05C5C2E3394EF00EECC18 /* ErrorAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC05C5A2E33936C00EECC18 /* ErrorAlertHandler.swift */; }; EBC05C712E33B57D00EECC18 /* Converter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC05C6D2E33B57D00EECC18 /* Converter.swift */; }; @@ -368,6 +370,7 @@ EB97A0162E51DF4F008B8C5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; EB97A0192E51EA9C008B8C5C /* UIAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlert.swift; sourceTree = ""; }; EB99257F2E45D53E00357055 /* sharing_enums.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sharing_enums.pb.swift; sourceTree = ""; }; + EBBC93B12EC8B75F00F541A1 /* LocalNetworkPermissionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNetworkPermissionView.swift; sourceTree = ""; }; EBC05C5A2E33936C00EECC18 /* ErrorAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorAlertHandler.swift; sourceTree = ""; }; EBC05C6D2E33B57D00EECC18 /* Converter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Converter.swift; sourceTree = ""; }; EBC05C6E2E33B57D00EECC18 /* Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; }; @@ -592,6 +595,7 @@ EB979F8E2E50CA23008B8C5C /* ContentView.swift */, EB979F8F2E50CA23008B8C5C /* FilePicker.swift */, EB97A0192E51EA9C008B8C5C /* UIAlert.swift */, + EBBC93B12EC8B75F00F541A1 /* LocalNetworkPermissionView.swift */, EB979F992E50CAA6008B8C5C /* PieProgressView.swift */, ); path = View; @@ -1043,6 +1047,7 @@ EB5C37FC2E377CE70052EFD7 /* OutboundNearbyConnection.swift in Sources */, EB1325D62E701D8E00FD749C /* Settings.swift in Sources */, EB5C37FD2E377CE70052EFD7 /* Logger.swift in Sources */, + EBBC93B32EC8B76600F541A1 /* LocalNetworkPermissionView.swift in Sources */, EB97A00F2E511124008B8C5C /* ReceiveModel.swift in Sources */, EB5C37FE2E377CE70052EFD7 /* offline_wire_formats.pb.swift in Sources */, EB4F9D1F2EC26C8100A74A0F /* EXIFUtils.swift in Sources */, @@ -1087,6 +1092,7 @@ EB950B512E520436002D68FA /* securemessage.pb.swift in Sources */, EB950B522E520436002D68FA /* NearbyConnectionManager.swift in Sources */, EB950B532E520436002D68FA /* ukey.pb.swift in Sources */, + EBBC93B22EC8B76600F541A1 /* LocalNetworkPermissionView.swift in Sources */, EB05DFC02E5A2EAA00EF567A /* TrustedDevicesView.swift in Sources */, EB950B542E520436002D68FA /* HKDF.swift in Sources */, EB1325D52E701D8E00FD749C /* Settings.swift in Sources */, diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index 704ef15..8b3f5c2 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -28183,6 +28183,472 @@ } } }, + "introduction_local_network_access" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "الوصول إلى الشبكة" + } + }, + "ca" : { + "stringUnit" : { + "state" : "translated", + "value" : "Accés a la xarxa" + } + }, + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Přístup k síti" + } + }, + "da" : { + "stringUnit" : { + "state" : "translated", + "value" : "Netværksadgang" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Netzwerkzugriff" + } + }, + "el" : { + "stringUnit" : { + "state" : "translated", + "value" : "Πρόσβαση στο δίκτυο" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Network Access" + } + }, + "en-AU" : { + "stringUnit" : { + "state" : "translated", + "value" : "Network Access" + } + }, + "en-CA" : { + "stringUnit" : { + "state" : "translated", + "value" : "Network Access" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "Network Access" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Acceso a la red" + } + }, + "es-419" : { + "stringUnit" : { + "state" : "translated", + "value" : "Acceso a la red" + } + }, + "fi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Verkkoyhteys" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Accès au réseau" + } + }, + "fr-CA" : { + "stringUnit" : { + "state" : "translated", + "value" : "Accès au réseau" + } + }, + "he" : { + "stringUnit" : { + "state" : "translated", + "value" : "גישה לרשת" + } + }, + "hi" : { + "stringUnit" : { + "state" : "translated", + "value" : "नेटवर्क एक्सेस" + } + }, + "hr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Pristup mreži" + } + }, + "hu" : { + "stringUnit" : { + "state" : "translated", + "value" : "Hálózati hozzáférés" + } + }, + "id" : { + "stringUnit" : { + "state" : "translated", + "value" : "Akses Jaringan" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Accesso alla rete" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "ネットワークアクセス" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "네트워크 접근" + } + }, + "ms" : { + "stringUnit" : { + "state" : "translated", + "value" : "Akses Rangkaian" + } + }, + "nb" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nettverkstilgang" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Netwerktoegang" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Dostęp do sieci" + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "Acesso à Rede" + } + }, + "pt-PT" : { + "stringUnit" : { + "state" : "translated", + "value" : "Acesso à Rede" + } + }, + "ro" : { + "stringUnit" : { + "state" : "translated", + "value" : "Acces la rețea" + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "Доступ к сети" + } + }, + "sv" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nätverksåtkomst" + } + }, + "th" : { + "stringUnit" : { + "state" : "translated", + "value" : "การเข้าถึงเครือข่าย" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ağ Erişimi" + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "Доступ до мережі" + } + }, + "vi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Truy cập mạng" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "网络访问" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "網路存取權" + } + } + } + }, + "introduction_local_network_access_description" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "يحتاج QuickDrop إلى الوصول إلى الشبكة المحلية لنقل الملفات عبر شبكة Wi-Fi الخاصة بك. اضغط على \"متابعة\" لمنح هذا الإذن." + } + }, + "ca" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop necessita accés a la xarxa local per transmetre fitxers via Wi-Fi. Toca «Continua» per concedir aquest permís." + } + }, + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop potřebuje přístup k místní síti pro přenos souborů přes vaše Wi-Fi. Klepněte na „Pokračovat“, abyste udělili toto oprávnění." + } + }, + "da" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop har brug for adgang til det lokale netværk for at overføre filer via dit Wi-Fi. Tryk på “Fortsæt” for at give tilladelsen." + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop benötigt lokalen Netzwerkzugriff, um Dateien über dein WLAN zu übertragen. Tippe auf „Fortfahren“, um diese Berechtigung zu erteilen." + } + }, + "el" : { + "stringUnit" : { + "state" : "translated", + "value" : "Το QuickDrop χρειάζεται πρόσβαση στο τοπικό δίκτυο για τη μετάδοση αρχείων μέσω Wi-Fi. Πατήστε «Συνέχεια» για να δώσετε αυτήν την άδεια." + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop needs local network access to transmit files on your Wi-Fi. Tap “Continue“ to grant this permission." + } + }, + "en-AU" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop needs local network access to transmit files on your Wi-Fi. Tap “Continue“ to grant this permission." + } + }, + "en-CA" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop needs local network access to transmit files over your Wi-Fi. Tap “Continue” to grant this permission." + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop needs local network access to transmit files on your Wi-Fi. Tap “Continue” to grant this permission." + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop necesita acceso a la red local para transferir archivos por Wi-Fi. Pulsa “Continuar” para otorgar este permiso." + } + }, + "es-419" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop necesita acceso a la red local para transferir archivos por Wi-Fi. Toca \"Continuar\" para otorgar este permiso." + } + }, + "fi" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop tarvitsee paikallisverkon käyttöoikeuden tiedostojen siirtoon Wi-Fi-verkossasi. Jatka myöntääksesi luvan." + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop a besoin d'accéder au réseau local pour transférer des fichiers via votre Wi-Fi. Appuyez sur « Continuer » pour accorder cette autorisation." + } + }, + "fr-CA" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop a besoin d’un accès au réseau local pour transmettre des fichiers via votre Wi-Fi. Touchez « Continuer » pour accorder cette permission." + } + }, + "he" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop זקוק לגישה לרשת המקומית כדי להעביר קבצים ב-Wi-Fi שלך. לחץ על \"המשך\" כדי לאשר את ההרשאה." + } + }, + "hi" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop को फाइल भेजने के लिए आपके Wi-Fi पर लोकल नेटवर्क एक्सेस चाहिए। यह अनुमति देने के लिए 'जारी रखें' टैप करें।" + } + }, + "hr" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop treba pristup lokalnoj mreži za prijenos datoteka putem Wi-Fi veze. Dodirnite „Nastavi“ za odobrenje." + } + }, + "hu" : { + "stringUnit" : { + "state" : "translated", + "value" : "A QuickDrop-nak helyi hálózati hozzáférésre van szüksége a fájlok Wi-Fi-n keresztüli átviteléhez. Koppints a „Folytatás” gombra az engedély megadásához." + } + }, + "id" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop memerlukan akses jaringan lokal untuk mengirim file melalui Wi-Fi Anda. Ketuk \"Lanjutkan\" untuk memberikan izin ini." + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop necessita dell’accesso alla rete locale per inviare file tramite il tuo Wi-Fi. Tocca “Continua” per concedere il permesso." + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDropがWi-Fi経由でファイルを送信するには、ローカルネットワークへのアクセスが必要です。「続行」をタップして許可してください。" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop이 와이파이에서 파일을 전송하려면 로컬 네트워크 접근 권한이 필요합니다. '계속'을 눌러 권한을 허용하세요." + } + }, + "ms" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop memerlukan akses rangkaian tempatan untuk menghantar fail melalui Wi-Fi anda. Ketik “Teruskan“ untuk memberikan kebenaran ini." + } + }, + "nb" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop trenger tilgang til lokalt nettverk for å overføre filer via Wi-Fi. Trykk «Fortsett» for å gi tillatelse." + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop heeft toegang tot het lokale netwerk nodig om bestanden via je wifi te versturen. Tik op 'Doorgaan' om deze toestemming te geven." + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop potrzebuje dostępu do lokalnej sieci, aby przesyłać pliki przez Wi-Fi. Naciśnij „Kontynuuj”, aby przyznać to uprawnienie." + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "O QuickDrop precisa de acesso à rede local para transferir arquivos pelo seu Wi-Fi. Toque em “Continuar” para conceder essa permissão." + } + }, + "pt-PT" : { + "stringUnit" : { + "state" : "translated", + "value" : "O QuickDrop precisa de acesso à rede local para transferir ficheiros através do seu Wi-Fi. Toque em \"Continuar\" para conceder esta permissão." + } + }, + "ro" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop are nevoie de acces la rețeaua locală pentru a transmite fișiere prin Wi-Fi. Apasă „Continuă” pentru a acorda această permisiune." + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop требуется доступ к локальной сети для передачи файлов по Wi-Fi. Нажмите «Продолжить», чтобы предоставить разрешение." + } + }, + "sv" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop behöver åtkomst till lokalt nätverk för att överföra filer via ditt Wi-Fi. Tryck på ”Fortsätt” för att ge behörighet." + } + }, + "th" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop ต้องการเข้าถึงเครือข่ายภายในเพื่อส่งไฟล์ผ่าน Wi-Fi ของคุณ แตะ “ดำเนินการต่อ” เพื่ออนุญาต" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop, dosya aktarımı için yerel ağa erişim gerektirir. Bu izni vermek için “Devam Et”e dokunun." + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop потребує доступу до локальної мережі для передачі файлів через Wi-Fi. Натисніть «Продовжити», щоб надати дозвіл." + } + }, + "vi" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop cần quyền truy cập mạng cục bộ để truyền tệp qua Wi-Fi của bạn. Nhấn “Tiếp tục” để cho phép." + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop 需要本地网络访问权限,以通过您的 Wi-Fi 传输文件。请点击“继续”以授予此权限。" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "QuickDrop 需要本地網路權限,才能在您的 Wi-Fi 下傳輸檔案。請點擊「繼續」以授權。" + } + } + } + }, "plusview_description" : { "localizations" : { "ar" : { diff --git a/QuickDrop/ViewModel/ReceiveModel.swift b/QuickDrop/ViewModel/ReceiveModel.swift index a650742..2c40513 100644 --- a/QuickDrop/ViewModel/ReceiveModel.swift +++ b/QuickDrop/ViewModel/ReceiveModel.swift @@ -157,10 +157,10 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { let totalProgress = processes.values.reduce(0, +) let averageProgress = totalProgress / Double(processes.count) - #if os(iOS) +#if os(iOS) ProgressAlert.shared.updateProgress(averageProgress, onCancel: { NearbyConnectionManager.shared.cancelTransfer(id: connectionID) - }) + }, completion: {}) #else DispatchQueue.main.async { self.progress = averageProgress @@ -185,7 +185,7 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { finish() #else if self.processes.isEmpty { - ProgressAlert.shared.updateProgress(nil) { + ProgressAlert.shared.updateProgress(nil, onCancel: {}) { finish() } } diff --git a/QuickDropiOS/Configuration.swift b/QuickDropiOS/Configuration.swift index b71f37a..4279917 100644 --- a/QuickDropiOS/Configuration.swift +++ b/QuickDropiOS/Configuration.swift @@ -29,7 +29,7 @@ let configuration = LUIConfiguration( usesAutomaticReviewPrompt: false, - usesPagedIntroduction: false, + usesPagedIntroduction: true, supportsSplitView: false, diff --git a/QuickDropiOS/View/ContentView.swift b/QuickDropiOS/View/ContentView.swift index 9837b8f..9f5bc19 100644 --- a/QuickDropiOS/View/ContentView.swift +++ b/QuickDropiOS/View/ContentView.swift @@ -32,6 +32,8 @@ struct ContentView: View { NavigationLinkLabel(imageName: "checkmark.shield.fill", text: "ManageTrustedDevices", backgroundColor: .green) } } + }, firstIntroductionView: { + LocalNetworkPermissionView() }) } } @@ -44,6 +46,7 @@ struct DeviceListView: View { #if !EXTENSION @StateObject var receiveModel = ReceiveModel(controlPlusScreen: { show in log("[DeviceListView] Setting showPlusScreen to \(show)") + errorVibration() DeviceListViewModel.sharedInstance.showPlusScreen = show }) #endif @@ -62,36 +65,39 @@ struct DeviceListView: View { BottomBarView(header: "QuickDrop", navigationBarLayout: isShareExtension() ? .SmallOnlyAlways : .Default, bottomViewHeight: 30) { VStack { - VStack(alignment: .leading, spacing: 8) { - - let attachments = nearbyConnectionManager.attachments - - FormHeader(name: attachments == nil ? "YouAreVisibleAs".localized() : "YouAreSending".localized()) - - HStack { + if nearbyConnectionManager.hasLocalNetworkPermission { + VStack(alignment: .leading, spacing: 8) { - if let image = attachments?.previewImage { - image - .resizable() - .scaledToFill() - .frame(width: 10, height: 10) + let attachments = nearbyConnectionManager.attachments + + FormHeader(name: attachments == nil ? "YouAreVisibleAs".localized() : "YouAreSending".localized()) + + HStack { + + if let image = attachments?.previewImage { + image + .resizable() + .scaledToFill() + .frame(width: 10, height: 10) + } + + LUIText(attachments?.shortDescription ?? NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized(), isBold: true) + .lineLimit(1) } - - LUIText(attachments?.shortDescription ?? NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized(), isBold: true) - .lineLimit(1) + .padding(.horizontal, 16) + .padding(.vertical, 6) + .background(sheetActive ? Color.sheetForegroundColor : Color.defaultForegroundColor) + .cornerRadius(24) } - .padding(.horizontal, 16) - .padding(.vertical, 6) - .background(sheetActive ? Color.sheetForegroundColor : Color.defaultForegroundColor) - .cornerRadius(24) + .padding(.horizontal) + .padding(.top, 8) + .frame(maxWidth: .infinity, alignment: .leading) } - .padding(.horizontal) - .padding(.top, 8) - .frame(maxWidth: .infinity, alignment: .leading) if !nearbyConnectionManager.hasLocalNetworkPermission { CardView(backgroundColor: .red, title: "NoNetworkAccess", titleSymbol: "network.slash") { - CardSubView(symbol: "exclamationmark.triangle.fill", text: "NoLocalNetworkAccessDescription") + LUIText("NoLocalNetworkAccessDescription", color: .white) + .frame(maxWidth: .infinity, alignment: .leading) } .padding(.bottom, 10) .onTapGesture { diff --git a/QuickDropiOS/View/LocalNetworkPermissionView.swift b/QuickDropiOS/View/LocalNetworkPermissionView.swift new file mode 100644 index 0000000..1337004 --- /dev/null +++ b/QuickDropiOS/View/LocalNetworkPermissionView.swift @@ -0,0 +1,52 @@ +// +// LocalNetworkPermissionView.swift +// QuickDrop +// +// Created by Leon Böttger on 15.11.25. +// + +import SwiftUI +import LUI + +public struct LocalNetworkPermissionView: View { + + @State var requestedLocalNetworkAccess = false + @Environment(\.scenePhase) var scenePhase + + public var body: some View { + + PermissionView(title: "introduction_local_network_access", symbol: "", subtitle: "introduction_local_network_access_description", permissionAction: { + + if requestedLocalNetworkAccess { + // Something went wrong, user pressed again on continue. In this case, just continue with setup + IntroductionViewController.sharedInstance.canProceed = true + } + else { + // init manager to force local network access prompt + requestedLocalNetworkAccess = true + let manager = NearbyConnectionManager.shared + manager.startDeviceDiscovery() + } + }, canSkip: false, nextView: { + IntroductionDoneView() + }, nextViewSkip: {}, frontMockup: { + AppMockupFrontView() + }, backMockup: { + SymbolMockupView(symbol: "globe") + }) + .onChange(of: scenePhase) { newValue in + + // alert was removed from screen, app is foreground again -> continue with intro + if newValue == .active && requestedLocalNetworkAccess { + IntroductionViewController.sharedInstance.canProceed = true + } + } + } +} + + +#Preview { + NavigationView { + LocalNetworkPermissionView() + } +} diff --git a/QuickDropiOS/View/UIAlert.swift b/QuickDropiOS/View/UIAlert.swift index acc7cf4..0f73825 100644 --- a/QuickDropiOS/View/UIAlert.swift +++ b/QuickDropiOS/View/UIAlert.swift @@ -76,7 +76,7 @@ final class ProgressAlert { // MARK: - Update Progress // progress: 0…1 → update progress, nil → finished - func updateProgress(_ progress: Double?, onCancel: @escaping () -> Void, completion: @escaping () -> Void = {}) { + func updateProgress(_ progress: Double?, onCancel: @escaping () -> Void, completion: @escaping () -> Void) { // No progress to show, nothing shown currently → just complete if progressAlert == nil && progress == nil { @@ -86,21 +86,22 @@ final class ProgressAlert { DispatchQueue.main.async { - // Show progress if not shown yet - if self.progressAlert == nil { - self.showProgressAlert(onCancel: onCancel) - } - if let p = progress { + // Show progress if not shown yet + if self.progressAlert == nil { + self.showProgressAlert(onCancel: onCancel) + } + self.progressView?.setProgress(Float(p), animated: true) completion() - } else { + } + else { // Completed: dismiss progress and show final alert self.progressAlert?.dismiss(animated: true) { completion() + self.progressAlert = nil + self.progressView = nil } - self.progressAlert = nil - self.progressView = nil } } }