Skip to content

Commit

Permalink
Introduce initial UI for connecting to networks
Browse files Browse the repository at this point in the history
  • Loading branch information
conradev committed Mar 10, 2024
1 parent 51fd638 commit 0fe6308
Show file tree
Hide file tree
Showing 33 changed files with 1,453 additions and 316 deletions.
5 changes: 2 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ opt_in_rules:
- multiline_parameters
- multiline_parameters_brackets
- no_extension_access_modifier
- no_grouping_extension
- nslocalizedstring_key
- nslocalizedstring_require_bundle
- number_separator
Expand Down Expand Up @@ -76,9 +75,7 @@ opt_in_rules:
- sorted_first_last
- sorted_imports
- static_operator
- strict_fileprivate
- strong_iboutlet
- switch_case_on_newline
- test_case_accessibility
- toggle_bool
- trailing_closure
Expand All @@ -97,3 +94,5 @@ disabled_rules:
- force_try
- nesting
- todo
- trailing_comma
- switch_case_on_newline
5 changes: 5 additions & 0 deletions Apple/App/App.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ INFOPLIST_KEY_UIStatusBarStyle[sdk=iphone*] = UIStatusBarStyleDefault
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight
TARGETED_DEVICE_FAMILY[sdk=iphone*] = 1,2
EXCLUDED_SOURCE_FILE_NAMES = MainMenu.xib

EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] =
INFOPLIST_KEY_LSUIElement[sdk=macosx*] = YES
INFOPLIST_KEY_NSMainNibFile[sdk=macosx*] = MainMenu
INFOPLIST_KEY_NSPrincipalClass[sdk=macosx*] = NSApplication
INFOPLIST_KEY_LSApplicationCategoryType[sdk=macosx*] = public.app-category.utilities

CODE_SIGN_ENTITLEMENTS = App/App-iOS.entitlements
Expand Down
3 changes: 2 additions & 1 deletion Apple/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AppKit
import SwiftUI

@MainActor
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
private let quitItem: NSMenuItem = {
let quitItem = NSMenuItem(
Expand All @@ -16,7 +17,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}()

private let toggleItem: NSMenuItem = {
let toggleView = NSHostingView(rootView: MenuItemToggleView(tunnel: BurrowApp.tunnel))
let toggleView = NSHostingView(rootView: MenuItemToggleView())
toggleView.frame.size = CGSize(width: 300, height: 32)
toggleView.autoresizingMask = [.width]

Expand Down
20 changes: 20 additions & 0 deletions Apple/App/Assets.xcassets/HackClub.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x50",
"green" : "0x37",
"red" : "0xEC"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
12 changes: 12 additions & 0 deletions Apple/App/Assets.xcassets/HackClub.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "flag-standalone-wtransparent.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
20 changes: 20 additions & 0 deletions Apple/App/Assets.xcassets/WireGuard.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x1A",
"green" : "0x17",
"red" : "0x88"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
15 changes: 15 additions & 0 deletions Apple/App/Assets.xcassets/WireGuard.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "WireGuard.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
6 changes: 6 additions & 0 deletions Apple/App/Assets.xcassets/WireGuard.imageset/WireGuard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Apple/App/Assets.xcassets/WireGuardTitle.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "WireGuardTitle.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 4 additions & 12 deletions Apple/App/BurrowApp.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import SwiftUI

@main
#if !os(macOS)
@MainActor
@main
struct BurrowApp: App {
static let tunnel = Tunnel { manager, proto in
proto.serverAddress = "hackclub.com"
manager.localizedDescription = "Burrow"
}

#if os(macOS)
@NSApplicationDelegateAdaptor(AppDelegate.self)
var delegate
#endif

var body: some Scene {
WindowGroup {
TunnelView(tunnel: Self.tunnel)
BurrowView()
}
}
}
#endif
26 changes: 26 additions & 0 deletions Apple/App/BurrowView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import SwiftUI

struct BurrowView: View {
var body: some View {
NavigationStack {
VStack {
NetworkCarouselView()
Spacer()
TunnelStatusView()
TunnelButton()
.padding(.bottom)
}
.padding()
.navigationTitle("Networks")
}
}
}

#if DEBUG
struct NetworkView_Previews: PreviewProvider {
static var previews: some View {
BurrowView()
.environment(\.tunnel, PreviewTunnel())
}
}
#endif
50 changes: 50 additions & 0 deletions Apple/App/FloatingButtonStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import SwiftUI

struct FloatingButtonStyle: ButtonStyle {
static let duration = 0.08

var color: Color
var cornerRadius: CGFloat

func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.headline)
.foregroundColor(.white)
.frame(minHeight: 48)
.padding(.horizontal)
.background(
RoundedRectangle(cornerRadius: cornerRadius)
.fill(
LinearGradient(
colors: [
configuration.isPressed ? color.opacity(0.9) : color.opacity(0.9),
configuration.isPressed ? color.opacity(0.9) : color
],
startPoint: .init(x: 0.2, y: 0),
endPoint: .init(x: 0.8, y: 1)
)
)
.background(
RoundedRectangle(cornerRadius: cornerRadius)
.fill(configuration.isPressed ? .black : .white)
)
)
.shadow(color: .black.opacity(configuration.isPressed ? 0.0 : 0.1), radius: 2.5, x: 0, y: 2)
.scaleEffect(configuration.isPressed ? 0.975 : 1.0)
.padding(.bottom, 2)
.animation(
configuration.isPressed ? .easeOut(duration: Self.duration) : .easeIn(duration: Self.duration),
value: configuration.isPressed
)
}
}

extension ButtonStyle where Self == FloatingButtonStyle {
static var floating: FloatingButtonStyle {
floating()
}

static func floating(color: Color = .accentColor, cornerRadius: CGFloat = 10) -> FloatingButtonStyle {
FloatingButtonStyle(color: color, cornerRadius: cornerRadius)
}
}
Loading

0 comments on commit 0fe6308

Please sign in to comment.