blob: 202a637d6c6e30f711441ecca6e981b4582a55a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright (C) 2024 Rubén Beltrán del Río
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see https://map.tranquil.systems.
import SwiftUI
enum PreferencesTab: CaseIterable {
case general
case appearance
case map
case stages
case templates
var localizedStringKey: LocalizedStringKey {
switch self {
case .general:
return "preferences.menu.general"
case .appearance:
return "preferences.menu.appearance"
case .map:
return "preferences.menu.map"
case .stages:
return "preferences.menu.stages"
case .templates:
return "preferences.menu.templates"
}
}
var systemImage: String {
switch self {
case .general:
return "gearshape"
case .appearance:
return "paintpalette"
case .map:
return "map"
case .stages:
return "list.number"
case .templates:
return "doc.text"
}
}
}
struct PreferencesWindow: View {
@State private var selectedTab: PreferencesTab = .general
var body: some View {
Group {
switch selectedTab {
case .general:
GeneralPreferencesView()
case .appearance:
AppearancePreferencesView()
case .map:
MapPreferencesView()
case .stages:
StagesPreferencesView()
case .templates:
TemplatesPreferencesView()
}
}
.frame(width: Dimensions.Preferences.Window.width, height: Dimensions.Preferences.Window.height)
.toolbar {
ToolbarItem(placement: .principal) {
HStack(spacing: Dimensions.Spacing.loose) {
ForEach(PreferencesTab.allCases, id: \.self) { tab in
Button(action: { selectedTab = tab }) {
VStack(spacing: Dimensions.Spacing.coziest) {
Image(systemName: tab.systemImage)
.font(.system(size: Dimensions.Preferences.Toolbar.size))
Text(tab.localizedStringKey)
.font(.Theme.SmallControl.regular)
}
.frame(
width: Dimensions.Preferences.Toolbar.width,
height: Dimensions.Preferences.Toolbar.height
)
.padding(.horizontal, Dimensions.Spacing.cozy)
.background(
selectedTab == tab ? Color.Theme.UI.accent : Color.background.opacity(0.01)
)
.foregroundColor(selectedTab == tab ? Color.white : Color.Theme.UI.foreground)
.cornerRadius(Dimensions.Preferences.Toolbar.radius)
}
.buttonStyle(.plain)
}
}
}
}
}
}
#Preview {
PreferencesWindow()
}
|