summaryrefslogtreecommitdiff
path: root/Jel/Views/ContentView.swift
blob: 203bbaa8b164c741bb3f693337f98b7b7590e853 (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
51
52
53
54
55
56
57
//
//  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 {
        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()
        }
      }
    }
    .sheet(isPresented: $isSignedIn.not) {
      SignInView()
        .interactiveDismissDisabled()
    }
    .onChange(of: authState.loggedIn, {
      isSignedIn = authState.loggedIn
    })
    .onChange(of: authState.loaded, {
      isSignedIn = authState.loggedIn
    })
  }
}

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