Files
workouts/Workouts/Views/Settings/SettingsView.swift
rzen 8b6250e4d6 Refactor UI: move Splits to Settings, redesign ExerciseView
Schema & Models:
- Add notes, loadType, duration fields to WorkoutLog
- Align Watch schema with iOS (use duration Date instead of separate mins/secs)
- Add duration helper properties to Exercise and WorkoutLog

UI Changes:
- Remove Splits and Settings tabs, single Workout Logs view
- Add gear button in nav bar to access Settings as sheet
- Move Splits section into Settings view with inline list
- Redesign ExerciseView with read-only Plan/Notes tiles and Edit buttons
- Add PlanEditView and NotesEditView with Cancel/Save buttons
- Auto-dismiss ExerciseView when completing last set
- Navigate to ExerciseView when adding new exercise

Data Flow:
- Plan edits sync to both WorkoutLog and corresponding Exercise
- Changes propagate up navigation chain via CoreData
2026-01-19 16:10:37 -05:00

107 lines
3.8 KiB
Swift

//
// 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<Split>
@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)
}