From 711519ded52a7a0fde39daa3812ce1d1fd3dea61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sun, 18 May 2025 12:22:34 +0200 Subject: [PATCH] Ap Isolation check only when opening troubleshooting --- QuickDrop.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/QuickDrop.xcscheme | 1 + QuickDrop/AppDelegate.swift | 40 +------ QuickDrop/IssueViews/IssueView.swift | 112 +++++++++--------- QuickDrop/WelcomeScreen.swift | 3 + 5 files changed, 67 insertions(+), 93 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 7d3d62c..290e3f7 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -825,7 +825,7 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 37; + SHARED_BUILD = 38; SHARED_VERSION = 1.9; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -884,7 +884,7 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 37; + SHARED_BUILD = 38; SHARED_VERSION = 1.9; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDrop.xcscheme b/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDrop.xcscheme index 10ab85a..3d12e57 100644 --- a/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDrop.xcscheme +++ b/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDrop.xcscheme @@ -34,6 +34,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "en" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index fbaf989..4dc56d0 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -93,30 +93,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele } UNUserNotificationCenter.current().delegate = self - - let monitor = NWPathMonitor() - monitor.pathUpdateHandler = { path in - if path.status == .satisfied { - if path.supportsIPv4 && !path.supportsIPv6 { - log("Detected IPv4-only network.") - self.performDeviceToDeviceCheck() - } else if !path.supportsIPv4 && path.supportsIPv6 { - log("IPv6-only network, likely iPhone hotspot. Skipping device-to-device check.") - } else if path.supportsIPv4 && path.supportsIPv6 { - log("Detected Dual stack network.") - self.performDeviceToDeviceCheck() - } else { - log("Detected no IP support") - } - } else { - log("Network unavailable") - } - - monitor.cancel() - } - - let queue = DispatchQueue(label: "NetworkMonitor") - monitor.start(queue: queue) hasConnectionMonitor.pathUpdateHandler = { path in DispatchQueue.main.async { @@ -141,20 +117,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele log("✅ Device-to-device likely allowed (peer responded on LAN).") self.apIsolationAlertWindow?.close() } else { - - log("❌ First check failed. Retrying in 10 seconds...") - - DispatchQueue.main.asyncAfter(deadline: .now() + 10) { - scanner.scan { allowed in - if allowed { - log("✅ Device-to-device likely allowed (peer responded on LAN).") - self.apIsolationAlertWindow?.close() - } else { - log("❌ Second check failed. Informing user...") - self.openAlert(type: .ApIsolation) - } - } - } + log("❌ Device-to-device check failed. Informing user...") + self.openAlert(type: .ApIsolation) } } } diff --git a/QuickDrop/IssueViews/IssueView.swift b/QuickDrop/IssueViews/IssueView.swift index bcf53c2..0b506a0 100644 --- a/QuickDrop/IssueViews/IssueView.swift +++ b/QuickDrop/IssueViews/IssueView.swift @@ -25,70 +25,76 @@ struct IssueView: View { @State var isLoading = false var body: some View { - - let imageSize = 120.0 - ScrollView { + ZStack { - ZStack { - - if colorScheme == .light { - Color.gray.opacity(0.1) - } - else { - Color.black.opacity(0.2) - } - - Image(image) - .resizable() - .frame(width: imageSize, height: imageSize) - .overlay( - Image(systemName: "exclamationmark.circle.fill") - .font(.system(size: imageSize * 0.2)) - .background(Circle().foregroundColor(.white)) - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing) - .foregroundColor(.red) - - .padding(imageSize * 0.09) - .padding(.trailing, image == .filter ? 15 : 0) - .padding(.bottom, imageSize * 0.03) - ) - .padding(.vertical) - + if colorScheme == .light { + Color.white } - .padding(.bottom, 20) - Text(header) - .font(.title2) - .fontWeight(.bold) - .multilineTextAlignment(.center) - - Text(description) - .fixedSize(horizontal: false, vertical: true) - .opacity(0.7) - .padding() - - if let actionLabel = actionLabel, let action = action { - Button(actionLabel) { + let imageSize = 120.0 + ScrollView { + + ZStack { - withAnimation { - isLoading = true + if colorScheme == .light { + Color.gray.opacity(0.1) + } + else { + Color.black.opacity(0.2) } - Task { - await action() + Image(image) + .resizable() + .frame(width: imageSize, height: imageSize) + .overlay( + Image(systemName: "exclamationmark.circle.fill") + .font(.system(size: imageSize * 0.2)) + .background(Circle().foregroundColor(.white)) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing) + .foregroundColor(.red) + + .padding(imageSize * 0.09) + .padding(.trailing, image == .filter ? 15 : 0) + .padding(.bottom, imageSize * 0.03) + ) + .padding(.vertical) + + } + .padding(.bottom, 20) + + Text(header) + .font(.title2) + .fontWeight(.bold) + .multilineTextAlignment(.center) + + Text(description) + .fixedSize(horizontal: false, vertical: true) + .opacity(0.7) + .padding() + + if let actionLabel = actionLabel, let action = action { + Button(actionLabel) { withAnimation { - isLoading = false + isLoading = true + } + + Task { + await action() + + withAnimation { + isLoading = false + } } } - } - .opacity(isLoading ? 0 : 1) - .overlay( - ProgressView() - .opacity(isLoading ? 1 : 0) - .scaleEffect(0.7) + .opacity(isLoading ? 0 : 1) + .overlay( + ProgressView() + .opacity(isLoading ? 1 : 0) + .scaleEffect(0.7) ) - .padding(.bottom, 30) + .padding(.bottom, 30) + } } } } diff --git a/QuickDrop/WelcomeScreen.swift b/QuickDrop/WelcomeScreen.swift index 222a08f..0f812c2 100644 --- a/QuickDrop/WelcomeScreen.swift +++ b/QuickDrop/WelcomeScreen.swift @@ -93,6 +93,9 @@ struct WelcomeScreen: View { case .troubleshooting: TutorialView(title: "Troubleshooting", text: "TroubleshootingDescription", showsLicense: false, openIAP: openPlusScreen) + .onAppear { + checkForNetworkIssues() + } case .app: TutorialView(title: "AndroidApp", text: "AndroidAppDescription", showsLicense: false, showsBetaJoinButton: true, openIAP: openPlusScreen)