jel/Jel/Views/SignIn/SignInView.swift

46 lines
905 B
Swift
Raw Normal View History

2023-12-12 22:09:15 +00:00
//
// SignInView.swift
// Jel
//
// Created by zerocool on 12/12/23.
//
import SwiftUI
2023-12-15 15:41:00 +00:00
import PulseUI
2023-12-12 22:09:15 +00:00
struct SignInView: View {
@EnvironmentObject var jellyfinClient: JellyfinClientController
2023-12-15 15:41:00 +00:00
@StateObject var authState: AuthStateController = AuthStateController.shared
2023-12-12 22:09:15 +00:00
@State var serverUrlIsValid: Bool = false
2023-12-15 15:41:00 +00:00
@State var showingConsoleSheet: Bool = false
2023-12-12 22:09:15 +00:00
var body: some View {
NavigationStack {
2023-12-15 15:41:00 +00:00
AddServerView(serverUrlIsValid: $serverUrlIsValid)
2023-12-12 22:09:15 +00:00
.navigationDestination(isPresented: $serverUrlIsValid) {
2023-12-15 15:41:00 +00:00
SignInToServerView()
2023-12-12 22:09:15 +00:00
}
}
.onAppear {
Task {
await checkLoadedServerUrl()
}
}
}
func checkLoadedServerUrl() async {
if authState.serverUrl == nil {
return
}
2023-12-15 15:41:00 +00:00
if await jellyfinClient.getPublicServerInfo() != nil {
2023-12-12 22:09:15 +00:00
serverUrlIsValid = true
}
}
}
#Preview {
2023-12-15 15:41:00 +00:00
SignInView()
2023-12-12 22:09:15 +00:00
}