jel/Jel/Views/Settings/SettingsView.swift

90 lines
2.0 KiB
Swift
Raw Normal View History

2023-12-15 15:41:00 +00:00
//
// SettingsView.swift
// Jel
//
// Created by zerocool on 12/13/23.
//
import SwiftUI
import PulseUI
struct SettingsView: View {
@Binding var showingSettingsView: Bool
@ObservedObject var authState: AuthStateController = AuthStateController.shared
2023-12-15 15:41:00 +00:00
@ObservedObject var settingsController: SettingsController = SettingsController.shared
2023-12-15 15:41:00 +00:00
var body: some View {
NavigationStack {
Form {
2024-01-07 21:58:38 +00:00
Section() {
LabeledContent("Username") {
Text("\(authState.username ?? "---")")
.textSelection(.enabled)
}
LabeledContent("Auth Token") {
Text("\(authState.authToken ?? "---")")
.textSelection(.enabled)
}
2024-01-08 13:26:46 +00:00
LabeledContent("Server URL") {
Text("\(authState.serverUrl?.absoluteString ?? "---")")
.textSelection(.enabled)
}
2024-01-07 21:58:38 +00:00
Button(role: .destructive) {
authState.loggedIn = false
authState.authToken = nil
2024-01-07 21:58:38 +00:00
authState.save()
showingSettingsView.toggle()
settingsController.save()
2024-01-07 21:58:38 +00:00
} label: {
Text("Sign out")
}
} header: {
Text("Current User")
}
Section() {
2023-12-15 15:41:00 +00:00
NavigationLink {
ConsoleView()
.closeButtonHidden()
} label: {
Text("Logs")
}
2024-01-07 21:58:38 +00:00
} header: {
Text("Debug")
2023-12-15 15:41:00 +00:00
}
2024-02-24 04:54:13 +00:00
Section() {
NavigationLink {
LibrariesView()
} label: {
Text("Acknowledgements")
}
2024-02-24 05:15:46 +00:00
} header: {
Text("About")
2024-02-24 04:54:13 +00:00
}
2023-12-15 15:41:00 +00:00
}
.navigationTitle("Settings")
.toolbar {
ToolbarItem {
Button {
showingSettingsView.toggle()
settingsController.save()
} label: {
Text("Done")
.bold()
}
}
}
}
}
}
2024-01-08 13:26:46 +00:00
//#Preview {
// SettingsView(showingSettingsView: .constant(true))
//}