jel/Jel/Views/SignIn/SignInView.swift

46 lines
905 B
Swift

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