jel/Jel/Views/Settings/SettingsView.swift

76 lines
1.7 KiB
Swift

//
// 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() {
LabeledContent("Username") {
Text("\(authState.username ?? "---")")
.textSelection(.enabled)
}
LabeledContent("Auth Token") {
Text("\(authState.authToken ?? "---")")
.textSelection(.enabled)
}
LabeledContent("Server URL") {
Text("\(authState.serverUrl?.absoluteString ?? "---")")
.textSelection(.enabled)
}
Button(role: .destructive) {
authState.loggedIn = false
authState.save()
} label: {
Text("Sign out")
}
} header: {
Text("Current User")
}
Section() {
NavigationLink {
ConsoleView()
.closeButtonHidden()
} label: {
Text("Logs")
}
} header: {
Text("Debug")
}
}
.navigationTitle("Settings")
.toolbar {
ToolbarItem {
Button {
showingSettingsView.toggle()
settingsController.save()
} label: {
Text("Done")
.bold()
}
}
}
}
}
}
//#Preview {
// SettingsView(showingSettingsView: .constant(true))
//}