summaryrefslogtreecommitdiff
path: root/Jel/Views/Settings/SettingsView.swift
blob: 676b9777962e2c272907a4787f3f0045eacb30be (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
58
59
60
61
62
63
64
65
66
67
68
69
70
//
//  SettingsView.swift
//  Jel
//
//  Created by zerocool on 12/13/23.
//

import SwiftUI
import PulseUI

struct SettingsView: View {
  @Binding var showingSettingsView: Bool
  
  @StateObject var authState: AuthStateController = AuthStateController.shared
  
  @ObservedObject var settingsController: SettingsController = SettingsController.shared
  var body: some View {
    NavigationStack {
      Form {
        Section() {
          AppearancePicker()
        } header: {
          Text("Accessibility")
        }
        
        Section {
          NavigationLink {
            ConsoleView()
              .closeButtonHidden()
          } label: {
            Text("Logs")
          }
          
          Button(role: .destructive) {
            authState.loggedIn = false
            authState.save()
          } label: {
            Text("Sign out")
          }
        }
      }
      .navigationTitle("Settings")
      .toolbar {
        ToolbarItem {
          Button {
            showingSettingsView.toggle()
            settingsController.save()
          } label: {
            Text("Done")
              .bold()
          }
        }
      }
      .preferredColorScheme({
        switch settingsController.appearance {
          case .dark:
            return ColorScheme.dark
          case .light:
            return ColorScheme.light
          case .automatic:
            return .none
        }
      }())
    }
  }
}

#Preview {
  SettingsView(showingSettingsView: .constant(true))
}