62 lines
1.6 KiB
Swift
62 lines
1.6 KiB
Swift
//
|
|||
|
|
// SettingsView.swift
|
||
|
|
// QueueCube
|
||
|
|
//
|
||
|
|
// Created by James Magahern on 5/2/25.
|
||
|
|
//
|
||
|
|
|
||
|
|
import SwiftUI
|
||
|
|
|
||
|
|
struct SettingsView: View
|
||
|
|
{
|
||
|
|
let onDone: () -> Void
|
||
|
|
@State private var navigationPath: [SettingsPage]
|
||
|
|
|
||
|
|
init(onDone: @escaping () -> Void) {
|
||
|
|
self.onDone = onDone
|
||
|
|
self.navigationPath = if !Settings.fromDefaults().isConfigured {
|
||
|
|
// Show server settings if not configured.
|
||
|
|
[ .servers ]
|
||
|
|
} else {
|
||
|
|
[]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
var body: some View {
|
||
|
|
NavigationStack(path: $navigationPath) {
|
||
|
|
List {
|
||
|
|
NavigationLink(value: SettingsPage.general) {
|
||
|
|
Image(systemName: "gear")
|
||
|
|
Text(.general)
|
||
|
|
}
|
||
|
|
|
||
|
|
NavigationLink(value: SettingsPage.servers) {
|
||
|
|
Image(systemName: "server.rack")
|
||
|
|
Text(.servers)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.navigationDestination(for: SettingsPage.self, destination: { page in
|
||
|
|
Group {
|
||
|
|
switch page {
|
||
|
|
case .general: GeneralSettingsView()
|
||
|
|
case .servers: ServerListSettingsView()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.navigationBarTitleDisplayMode(.inline)
|
||
|
|
})
|
||
|
|
.navigationBarTitleDisplayMode(.inline)
|
||
|
|
.navigationTitle(.settings)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// MARK: - Types
|
||
|
|
|
||
|
|
enum SettingsPage: String, Identifiable
|
||
|
|
{
|
||
|
|
var id: String { rawValue }
|
||
|
|
|
||
|
|
case general
|
||
|
|
case servers
|
||
|
|
}
|
||
|
|
}
|