summaryrefslogtreecommitdiff
path: root/Jel/Views/ContentView.swift
blob: 398339214ad5a4c8ba2bff789f894e189cf353d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
//  ContentView.swift
//  Jel
//
//  Created by zerocool on 12/11/23.
//

import SwiftUI
import PulseUI

struct ContentView: View {
  @StateObject var authState: AuthStateController = AuthStateController.shared
  @State var isSignedIn: Bool = true
  
  var body: some View {
    VStack {
      if isSignedIn {
        NavigationStack {
          DashboardView()
        }
      } else {
        VStack {
          Text("You are not currently signed into a Jellyfin instance.")
            .padding()
          Button {
            // toggle logged in so that it invalidates isSignedIn
            authState.loggedIn = true
            authState.loggedIn = false
          } label: {
            Text("Sign in")
          }
        }
      }
    }
    .sheet(isPresented: $isSignedIn.not) {
      SignInView()
        .interactiveDismissDisabled()
    }
    .onChange(of: authState.loggedIn, {
      isSignedIn = authState.loggedIn
    })
    .onChange(of: authState.loaded, {
      isSignedIn = authState.loggedIn
    })
  }
}

//#Preview {
//  ContentView()
//}