// 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: 600, height: 400) .toolbar { ToolbarItem(placement: .principal) { HStack(spacing: 12) { ForEach(PreferencesTab.allCases, id: \.self) { tab in Button(action: { selectedTab = tab }) { VStack(spacing: 2) { Image(systemName: tab.systemImage) .font(.system(size: 16)) Text(tab.rawValue) .font(.caption2) } .frame(width: 60, height: 40) .background(selectedTab == tab ? Color.accentColor.opacity(0.2) : Color.clear) .foregroundColor(selectedTab == tab ? .accentColor : .primary) .cornerRadius(6) } .buttonStyle(.plain) } } } } } } #Preview { PreferencesWindow() }