burrow/Apple/App/TunnelView.swift
Conrad Kramer 3c30a4b336 Enable SwiftLint inside of Xcode
This commit also fixes all linter warnings and errors.
2023-05-09 23:01:36 -04:00

35 lines
803 B
Swift

import SwiftUI
struct TunnelView: View {
@ObservedObject var tunnel: Tunnel
var body: some View {
VStack {
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() {
try? tunnel.start()
}
private func stop() {
tunnel.stop()
}
private func configure() {
Task { try await tunnel.configure() }
}
}