// 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: String, CaseIterable { case general = "General" case appearance = "Appearance" case map = "Map" case stages = "Stages" case templates = "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.rawValue) .font(.Theme.SmallControl.regular) } .frame( width: Dimensions.Preferences.Toolbar.width, height: Dimensions.Preferences.Toolbar.height ) .padding(.horizontal, Dimensions.Spacing.coziest) .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() }