Created onboardingview
Added onboardingview to the app. First use only
This commit is contained in:
parent
534e615919
commit
30886771c5
9 changed files with 114 additions and 24 deletions
|
|
@ -1,32 +1,44 @@
|
|||
import NetworkExtension
|
||||
import SwiftUI
|
||||
|
||||
@available(macOS 13.0, *)
|
||||
@main
|
||||
@MainActor
|
||||
struct BurrowApp: App {
|
||||
//To connect to the App Delegate
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
||||
|
||||
|
||||
// To connect to the App Delegate
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self)
|
||||
var delegate
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
TunnelView()
|
||||
}
|
||||
WindowGroup(id: "onboarding", content: {
|
||||
OnboardingView().frame(width: 1000, height: 600.0).scaledToFill().fixedSize()
|
||||
}).windowStyle(.hiddenTitleBar).windowResizability(.contentSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@available(macOS 13.0, *)
|
||||
@MainActor
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
static let tunnel = Tunnel { manager, proto in
|
||||
proto.serverAddress = "hackclub.com"
|
||||
manager.localizedDescription = "Burrow"
|
||||
}
|
||||
|
||||
// Verifies app status
|
||||
func checkFirstTime() {
|
||||
let launchedBefore = UserDefaults.standard.bool(forKey: "launchedBefore")
|
||||
if launchedBefore {
|
||||
print("Not first launch.")
|
||||
closeApp()
|
||||
} else {
|
||||
print("First launch, setting UserDefault.")
|
||||
setVisited()
|
||||
}
|
||||
}
|
||||
|
||||
var statusItem: NSStatusItem?
|
||||
var popOver = NSPopover()
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
checkFirstTime()
|
||||
let menuView = MenuView(tunnel: AppDelegate.tunnel)
|
||||
// Creating apopOver
|
||||
popOver.behavior = .transient
|
||||
|
|
@ -41,13 +53,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
menuButton.action = #selector(menuButtonToggle)
|
||||
}
|
||||
}
|
||||
@objc func menuButtonToggle() {
|
||||
|
||||
|
||||
@objc func
|
||||
menuButtonToggle() {
|
||||
if let menuButton = statusItem?.button {
|
||||
|
||||
self.popOver.show(relativeTo: menuButton.bounds, of: menuButton, preferredEdge: NSRectEdge.minY)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue