Created onboardingview

Added onboardingview to the app. First use only
This commit is contained in:
AndromedaHelix 2023-05-25 23:07:08 -06:00 committed by Conrad Kramer
parent 534e615919
commit 30886771c5
9 changed files with 114 additions and 24 deletions

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "background.jpeg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View file

@ -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)
}
}
}

View file

@ -12,7 +12,6 @@ struct MenuView: View {
@ObservedObject var tunnel: Tunnel
private func start() {
do {
try tunnel.start()
} catch {

View file

@ -0,0 +1,54 @@
//
// OnboardingView.swift
// App
//
// Created by Juan Pablo Gutierrez on 25/05/23.
//
// Represents the onboarding screen
import SwiftUI
//Sets burrow visited status
func setVisited() {
UserDefaults.standard.set(true, forKey: "launchedBefore")
}
func closeApp() {
setVisited()
NSApp.windows.first?.close()
}
@available(macOS 13.0, *)
struct OnboardingView: View {
var body: some View {
ZStack(alignment: .center) {
Image("OnboardingBackground")
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fit)
.scaledToFill()
Color.black
.opacity(0.6)
.cornerRadius(15)
.blur(radius: 0.2)
.edgesIgnoringSafeArea(.all)
.frame(width: 450, height: 300)
VStack(alignment: .center) {
Text("Welcome to burrow").font(.system(size: 24, weight: .bold, design: .rounded))
Spacer().frame(height: /*@START_MENU_TOKEN@*/20.0/*@END_MENU_TOKEN@*/)
Text("It is a best-in-class tool for burrowing through firewalls.").font(.system(size: 14))
Spacer().frame(height: 10.0)
Text("Built by teenagers at HackClub").font(.system(size: 14))
Button(action: closeApp, label: {
Text("Start burrowing")
.font(
.system(
size : 14,
weight: .regular,
design: .rounded))
.padding(.all, 30.0)
.foregroundColor(.white)
}).buttonBorderShape(.roundedRectangle).buttonStyle(.borderless)
}.padding(20.0)
}
}
}

View file

@ -2,7 +2,6 @@ import Foundation
import NetworkExtension
extension Tunnel {
enum Status: CustomStringConvertible, Equatable, Hashable {
case unknown
case permissionRequired