jel/Jel/Views/ContentView.swift

58 lines
1.2 KiB
Swift
Raw Permalink Normal View History

2023-12-11 19:27:48 +00:00
//
// ContentView.swift
// Jel
//
// Created by zerocool on 12/11/23.
//
import SwiftUI
2023-12-13 00:51:54 +00:00
import PulseUI
2023-12-11 19:27:48 +00:00
struct ContentView: View {
2023-12-15 15:41:00 +00:00
@StateObject var authState: AuthStateController = AuthStateController.shared
@State var isSignedIn: Bool = true
2023-12-12 06:22:43 +00:00
var body: some View {
VStack() {
if isSignedIn {
2023-12-15 15:41:00 +00:00
NavigationStack {
DashboardView()
2023-12-11 19:27:48 +00:00
}
} else {
HStack {
Spacer()
VStack(alignment: .center) {
Spacer()
Text("You are not currently signed into a Jellyfin instance.")
.multilineTextAlignment(.center)
.padding()
Button {
// toggle logged in so that it invalidates isSignedIn
authState.loggedIn = true
authState.loggedIn = false
} label: {
Text("Sign in")
}
Spacer()
}
Spacer()
}
2023-12-13 00:51:54 +00:00
}
2023-12-11 19:27:48 +00:00
}
.sheet(isPresented: $isSignedIn.not) {
SignInView()
.interactiveDismissDisabled()
}
.onChange(of: authState.loggedIn, {
isSignedIn = authState.loggedIn
})
.onChange(of: authState.loaded, {
isSignedIn = authState.loggedIn
})
2023-12-13 00:51:54 +00:00
}
2023-12-11 19:27:48 +00:00
}
2024-01-08 17:57:25 +00:00
//#Preview {
// ContentView()
//}