diff options
author | Shav Kinderlehrer <[email protected]> | 2023-12-15 10:41:00 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2023-12-15 10:41:00 -0500 |
commit | 2e3c12fed339c8bf3dc966217cbdf4c385fb98a1 (patch) | |
tree | 356a0bbfd24f98bf04545eb876cf20cd6179850e /Jel/Views/Settings | |
parent | 3994a6f408905049a5c280a303e30fe636b07968 (diff) | |
download | jel-2e3c12fed339c8bf3dc966217cbdf4c385fb98a1.tar.gz jel-2e3c12fed339c8bf3dc966217cbdf4c385fb98a1.zip |
Add settings view + fix signin flow
Diffstat (limited to 'Jel/Views/Settings')
-rw-r--r-- | Jel/Views/Settings/AppearancePicker.swift | 25 | ||||
-rw-r--r-- | Jel/Views/Settings/SettingsView.swift | 68 |
2 files changed, 93 insertions, 0 deletions
diff --git a/Jel/Views/Settings/AppearancePicker.swift b/Jel/Views/Settings/AppearancePicker.swift new file mode 100644 index 0000000..93edead --- /dev/null +++ b/Jel/Views/Settings/AppearancePicker.swift @@ -0,0 +1,25 @@ +// +// AppearancePicker.swift +// Jel +// +// Created by zerocool on 12/15/23. +// + +import SwiftUI + +struct AppearancePicker: View { + @ObservedObject var settingsController: SettingsController = SettingsController.shared + + var body: some View { + Picker("Appearance", selection: $settingsController.appearance) { + ForEach(AppearanceState.allCases) { option in + Text(String(describing: option)) + } + } + .pickerStyle(.menu) + } +} + +#Preview { + AppearancePicker() +} diff --git a/Jel/Views/Settings/SettingsView.swift b/Jel/Views/Settings/SettingsView.swift new file mode 100644 index 0000000..6eaa2e2 --- /dev/null +++ b/Jel/Views/Settings/SettingsView.swift @@ -0,0 +1,68 @@ +// +// 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() + } + + 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)) +} |