69 lines
2 KiB
Swift
69 lines
2 KiB
Swift
import AuthenticationServices
|
|
import SwiftUI
|
|
|
|
#if !os(macOS)
|
|
struct BurrowView: View {
|
|
@Environment(\.webAuthenticationSession)
|
|
private var webAuthenticationSession
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
VStack {
|
|
HStack {
|
|
Text("Networks")
|
|
.font(.largeTitle)
|
|
.fontWeight(.bold)
|
|
Spacer()
|
|
Menu {
|
|
Button("Hack Club", action: addHackClubNetwork)
|
|
Button("WireGuard", action: addWireGuardNetwork)
|
|
} label: {
|
|
Image(systemName: "plus.circle.fill")
|
|
.font(.title)
|
|
.accessibilityLabel("Add")
|
|
}
|
|
}
|
|
.padding(.top)
|
|
NetworkCarouselView()
|
|
Spacer()
|
|
TunnelStatusView()
|
|
TunnelButton()
|
|
.padding(.bottom)
|
|
}
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
private func addHackClubNetwork() {
|
|
guard
|
|
let issuerURL = URL(string: "https://slack.com"),
|
|
let redirectURI = URL(string: "https://burrow.rs/callback/oauth2") else { return }
|
|
Task {
|
|
do {
|
|
let session = try await OpenID.Session(
|
|
issuerURL: issuerURL,
|
|
redirectURI: redirectURI,
|
|
scopes: ["openid", "profile"],
|
|
clientID: "2210535565.6884042183125"
|
|
)
|
|
let response = try await session.authorize(webAuthenticationSession)
|
|
} catch {
|
|
print(error)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func addWireGuardNetwork() {
|
|
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct NetworkView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
BurrowView()
|
|
.environment(\.tunnel, PreviewTunnel())
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|