Restructure into a three-tab app with Progress, goals, and Meditation
The UX redesign's first landing (spec in UX-REDESIGN.md): ContentView becomes a Today / Progress / Settings TabView, "Routine" replaces "Split" in every user-facing string and view name (code-level types keep their names), and workout starting moves to shared WorkoutStarter / StartedWorkoutNavigator plumbing. - New Progress tab: weekly goal streaks, workout trends, per-exercise weight progression, achievements, and the full history list (WorkoutLogsView -> WorkoutHistoryView). - Goals: stable categories workouts roll up to, managed from Settings. - New Meditation exercise + starter routine; timed sits record to Apple Health as Mind & Body sessions. Claude-Session: https://claude.ai/code/session_012qw2itfzKyEJ1HpsFt8Ex4
This commit is contained in:
@@ -35,16 +35,16 @@ struct WorkoutLogListView: View {
|
||||
_doc = State(initialValue: WorkoutDocument(fromLive: workout) ?? .deletedPlaceholder)
|
||||
}
|
||||
|
||||
/// The split this workout came from (read-only on the watch), used to offer
|
||||
/// The routine this workout came from (read-only on the watch), used to offer
|
||||
/// additional exercises that aren't logged yet. Fetched imperatively — *not* via
|
||||
/// `@Query` — so the list body never observes the live `Split` or traverses its
|
||||
/// `@Query` — so the list body never observes the live `Routine` or traverses its
|
||||
/// `exercises` relationship during a render. Doing so (a `@Query`-observed model
|
||||
/// whose to-many relationship is read in `body`) drove a SwiftData re-render loop
|
||||
/// that hung the watch. `availableExercises` is therefore only ever evaluated from
|
||||
/// the picker sheet's closure, not from `body`.
|
||||
private var split: Split? {
|
||||
guard let splitID = doc.splitID else { return nil }
|
||||
return CacheMapper.fetchSplit(id: splitID, in: modelContext)
|
||||
private var routine: Routine? {
|
||||
guard let routineID = doc.routineID else { return nil }
|
||||
return CacheMapper.fetchRoutine(id: routineID, in: modelContext)
|
||||
}
|
||||
|
||||
private var sortedLogs: [WorkoutLogDocument] {
|
||||
@@ -52,9 +52,9 @@ struct WorkoutLogListView: View {
|
||||
}
|
||||
|
||||
private var availableExercises: [Exercise] {
|
||||
guard let split else { return [] }
|
||||
guard let routine else { return [] }
|
||||
let existingNames = Set(doc.logs.map { $0.exerciseName })
|
||||
return split.exercisesArray.filter { !existingNames.contains($0.name) }
|
||||
return routine.exercisesArray.filter { !existingNames.contains($0.name) }
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -74,10 +74,10 @@ struct WorkoutLogListView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// Gate on the *resolved* split, not the stale `splitID` string — a split
|
||||
// Gate on the *resolved* routine, not the stale `routineID` string — a routine
|
||||
// deleted on the phone leaves the id dangling, and offering Add Exercise
|
||||
// against it would only show a misleading "All exercises added" picker.
|
||||
if split != nil {
|
||||
if routine != nil {
|
||||
Section {
|
||||
Button {
|
||||
showingExercisePicker = true
|
||||
@@ -96,13 +96,13 @@ struct WorkoutLogListView: View {
|
||||
ContentUnavailableView(
|
||||
"No Exercises",
|
||||
systemImage: "figure.strengthtraining.traditional",
|
||||
description: Text(split == nil
|
||||
description: Text(routine == nil
|
||||
? "No exercises in this workout."
|
||||
: "Tap + to add exercises.")
|
||||
)
|
||||
}
|
||||
}
|
||||
.navigationTitle(doc.splitName ?? Split.unnamed)
|
||||
.navigationTitle(doc.routineName ?? Routine.unnamed)
|
||||
// Absorb phone edits while this screen is open (H1's watch-side gap):
|
||||
// without this, the snapshot stays frozen at init, and the next watch
|
||||
// tick — made against a state that's missing the phone's edit — would be
|
||||
@@ -120,7 +120,7 @@ struct WorkoutLogListView: View {
|
||||
}
|
||||
}
|
||||
.navigationDestination(item: $selectedLogID) { logID in
|
||||
// RunFlowView hosts the run and, in a flow-mode split, auto-advances across
|
||||
// RunFlowView hosts the run and, in a flow-mode routine, auto-advances across
|
||||
// exercises. It owns the live-run mirror wiring (incoming-frame filter,
|
||||
// `navigatedRunID`, and the parameterized live-ended signal) since the on-screen
|
||||
// log advances during a flowing run.
|
||||
|
||||
Reference in New Issue
Block a user