88 lines
2.2 KiB
Swift
88 lines
2.2 KiB
Swift
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@State private var selectedTab: SettingsTab = .general
|
|
|
|
var body: some View {
|
|
NavigationSplitView {
|
|
List(SettingsTab.allCases, selection: $selectedTab) { tab in
|
|
Label(tab.label, systemImage: tab.icon)
|
|
.tag(tab)
|
|
.accessibilityIdentifier("settings.tab.\(tab.rawValue)")
|
|
}
|
|
.listStyle(.sidebar)
|
|
.navigationSplitViewColumnWidth(min: 180, ideal: 200)
|
|
} detail: {
|
|
ScrollView {
|
|
detailView.padding()
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
}
|
|
.frame(minWidth: 600, minHeight: 400)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var detailView: some View {
|
|
switch selectedTab {
|
|
case .general:
|
|
GeneralSettingsView()
|
|
case .appearance:
|
|
AppearanceSettingsView()
|
|
case .workspaces:
|
|
WorkspacesSettingsView()
|
|
case .animation:
|
|
AnimationSettingsView()
|
|
case .terminal:
|
|
TerminalSettingsView()
|
|
case .hotkeys:
|
|
HotkeySettingsView()
|
|
case .about:
|
|
AboutSettingsView()
|
|
}
|
|
}
|
|
}
|
|
|
|
enum SettingsTab: String, CaseIterable, Identifiable {
|
|
case general, appearance, workspaces, animation, terminal, hotkeys, about
|
|
|
|
var id: String { rawValue }
|
|
|
|
var label: String {
|
|
switch self {
|
|
case .general:
|
|
"General"
|
|
case .appearance:
|
|
"Appearance"
|
|
case .workspaces:
|
|
"Workspaces"
|
|
case .animation:
|
|
"Animation"
|
|
case .terminal:
|
|
"Terminal"
|
|
case .hotkeys:
|
|
"Hotkeys"
|
|
case .about:
|
|
"About"
|
|
}
|
|
}
|
|
|
|
var icon: String {
|
|
switch self {
|
|
case .general:
|
|
"gearshape"
|
|
case .appearance:
|
|
"paintbrush"
|
|
case .workspaces:
|
|
"rectangle.3.group"
|
|
case .animation:
|
|
"bolt.fill"
|
|
case .terminal:
|
|
"terminal"
|
|
case .hotkeys:
|
|
"keyboard"
|
|
case .about:
|
|
"info.circle"
|
|
}
|
|
}
|
|
}
|