// // SettingsView.swift // Workouts // // Copyright 2025 Rouslan Zenetl. All Rights Reserved. // import SwiftUI import CoreData import IndieAbout struct SettingsView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest( sortDescriptors: [ NSSortDescriptor(keyPath: \Split.order, ascending: true), NSSortDescriptor(keyPath: \Split.name, ascending: true) ], animation: .default ) private var splits: FetchedResults @State private var showingAddSplitSheet = false var body: some View { NavigationStack { Form { // MARK: - Splits Section Section(header: Text("Splits")) { if splits.isEmpty { HStack { Spacer() VStack(spacing: 8) { Image(systemName: "dumbbell.fill") .font(.largeTitle) .foregroundColor(.secondary) Text("No Splits Yet") .font(.headline) .foregroundColor(.secondary) Text("Create a split to organize your workout routine.") .font(.caption) .foregroundColor(.secondary) .multilineTextAlignment(.center) } .padding(.vertical) Spacer() } } else { ForEach(splits, id: \.objectID) { split in NavigationLink { SplitDetailView(split: split) } label: { HStack { Image(systemName: split.systemImage) .foregroundColor(Color.color(from: split.color)) .frame(width: 24) Text(split.name) Spacer() Text("\(split.exercisesArray.count)") .foregroundColor(.secondary) } } } } Button { showingAddSplitSheet = true } label: { HStack { Image(systemName: "plus.circle.fill") .foregroundColor(.accentColor) Text("Add Split") } } } // MARK: - Account Section Section(header: Text("Account")) { Text("Settings coming soon") .foregroundColor(.secondary) } // MARK: - About Section Section { IndieAbout(configuration: AppInfoConfiguration( documents: [ .custom(title: "Changelog", filename: "CHANGELOG", extension: "md"), .license(), .acknowledgements() ] )) } } .navigationTitle("Settings") .sheet(isPresented: $showingAddSplitSheet) { SplitAddEditView(split: nil) } } } } #Preview { SettingsView() .environment(\.managedObjectContext, PersistenceController.preview.viewContext) }