diff --git a/NearDrop/AppDelegate.swift b/NearDrop/AppDelegate.swift index b8371c5..0168049 100644 --- a/NearDrop/AppDelegate.swift +++ b/NearDrop/AppDelegate.swift @@ -22,6 +22,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele var welcomeWindow: NSWindow? var plusWindow: NSWindow? + var alertWindow: NSWindow? private var iapManager: IAPManager? var showsFirewallAlert = false @@ -85,6 +86,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele } UNUserNotificationCenter.current().delegate=self + + //openFirewallAlert() } @@ -171,6 +174,31 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele plusWindow?.makeKeyAndOrderFront(nil) plusWindow?.level = .normal } + + + + func openFirewallAlert() { + + // Create the welcome screen SwiftUI view + let firewallAlertView = FirewallIssueView() + + // Create an NSWindow to host the SwiftUI view + alertWindow = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: issueViewWidth, height: issueViewHeight), + styleMask: [.titled, .closable], + backing: .buffered, + defer: false + ) + + alertWindow?.center() + alertWindow?.isReleasedWhenClosed = false + alertWindow?.setFrameAutosaveName("FirewallAlert") + alertWindow?.contentView = NSHostingView(rootView: firewallAlertView) + + NSApp.activate(ignoringOtherApps: true) + alertWindow?.makeKeyAndOrderFront(nil) + alertWindow?.level = .normal + } func transmissionCount() -> Int { diff --git a/NearDrop/IssueViews/ApIsolationIssueView.swift b/NearDrop/IssueViews/ApIsolationIssueView.swift index 0542dda..e262442 100644 --- a/NearDrop/IssueViews/ApIsolationIssueView.swift +++ b/NearDrop/IssueViews/ApIsolationIssueView.swift @@ -128,6 +128,6 @@ func isHostReachable(_ host: String) -> Bool { #Preview { ApIsolationIssueView() - .frame(width: 600, height: 400) + .frame(width: issueViewWidth, height: issueViewHeight) } diff --git a/NearDrop/IssueViews/FirewallIssueView.swift b/NearDrop/IssueViews/FirewallIssueView.swift index 402fda7..9882f03 100644 --- a/NearDrop/IssueViews/FirewallIssueView.swift +++ b/NearDrop/IssueViews/FirewallIssueView.swift @@ -33,6 +33,6 @@ Once this is done, your phone will be able to connect to your Mac. #Preview { FirewallIssueView() - .frame(width: 600, height: 400) + .frame(width: issueViewWidth, height: issueViewHeight) } diff --git a/NearDrop/IssueViews/IssueView.swift b/NearDrop/IssueViews/IssueView.swift index 913feab..642dda1 100644 --- a/NearDrop/IssueViews/IssueView.swift +++ b/NearDrop/IssueViews/IssueView.swift @@ -8,6 +8,9 @@ import SwiftUI import Foundation +let issueViewWidth = 600.0 +let issueViewHeight = 300.0 + struct IssueView: View { @Environment(\.colorScheme) var colorScheme diff --git a/NearDrop/IssueViews/NetworkFilterIssueView.swift b/NearDrop/IssueViews/NetworkFilterIssueView.swift index c887cfc..bc0473a 100644 --- a/NearDrop/IssueViews/NetworkFilterIssueView.swift +++ b/NearDrop/IssueViews/NetworkFilterIssueView.swift @@ -27,6 +27,6 @@ Once this is done, you should be able to transfer files successfully. #Preview { NetworkFilterIssueView() - .frame(width: 600, height: 400) + .frame(width: issueViewWidth, height: issueViewHeight) }