Compare commits

...
Sign in to create a new pull request.

2 commits
main ... ios-ui

Author SHA1 Message Date
Jasper Mayone
1651872939
Merge branch 'main' into ios-ui 2023-11-05 18:44:31 -05:00
Conrad Kramer
2152fc3081 Created simple burrow UI for iOS
Edited the existing view so that if running on an iOS device it would
provide a basic UI with a toggle switch that will allow the user to
connect/disconnect from the VPN.
2023-10-14 10:25:03 -07:00
2 changed files with 48 additions and 28 deletions

View file

@ -15,7 +15,7 @@ struct BurrowApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
TunnelView() TunnelView(tunnel: Self.tunnel)
} }
} }
} }

View file

@ -1,36 +1,56 @@
import SwiftUI import SwiftUI
struct TunnelView: View { struct TunnelView: View {
// @ObservedObject var tunnel: Tunnel @ObservedObject var tunnel: Tunnel
@State var useBurrow = false
var body: some View { var body: some View {
#if os(iOS)
Text("Burrow")
.font(.largeTitle)
.fontWeight(.heavy)
VStack {
switch tunnel.status {
case .connecting, .disconnecting:
ProgressView().controlSize(.large).padding()
case .permissionRequired:
var useBurrow = false
Button("Configure VPN", action: configure).buttonStyle(.borderedProminent).tint(.red).padding()
default:
// for someone else to do: clean up my code and make the toggle VERY large that it's juicy. - R. Ruiz (allthesquares)
Toggle("", isOn: $useBurrow)
.disabled(tunnel.status == .unknown || tunnel.status == .configurationReadWriteFailed || tunnel.status == .invalid)
.labelsHidden()
.controlSize(.large)
.padding()
.toggleStyle(SwitchToggleStyle(tint: .red))
.onChange(of: useBurrow) { value in
if value == true {
start()
} else {
stop()
}
}
}
Text(verbatim: tunnel.status.description)
}
.task { await tunnel.update() }
#else
EmptyView() EmptyView()
// VStack { #endif
// Text(verbatim: tunnel.status.description)
// switch tunnel.status {
// case .connected:
// Button("Disconnect", action: stop)
// case .permissionRequired:
// Button("Allow", action: configure)
// case .disconnected:
// Button("Start", action: start)
// default:
// EmptyView()
// }
// }
// .task { await tunnel.update() }
// .padding()
} }
// private func start() { private func start() {
// try? tunnel.start() try? tunnel.start()
// } }
//
// private func stop() { private func stop() {
// tunnel.stop() tunnel.stop()
// } }
//
// private func configure() { private func configure() {
// Task { try await tunnel.configure() } Task { try await tunnel.configure() }
// } }
} }