Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1651872939 | ||
|
|
2152fc3081 |
2 changed files with 48 additions and 28 deletions
|
|
@ -15,7 +15,7 @@ struct BurrowApp: App {
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
TunnelView()
|
TunnelView(tunnel: Self.tunnel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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() }
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue