diff --git a/CHANGELOG.md b/CHANGELOG.md index a526a84..f16d28d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ **July 2026** +Adding an exercise to a split now picks from the app's exercise library — the moves with animated form guides — replacing the old gym-machine and bodyweight starter lists. + Starter routines now appear automatically the first time you use the app, instead of waiting behind a button in Settings. Editing a starter split now turns it into your own copy, so the built-in version can always be brought back later. diff --git a/CLAUDE.md b/CLAUDE.md index 62993c4..d643081 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,18 +59,18 @@ All in `Shared/Model/`: - iOS 26 / watchOS 26; Swift 6 with `SWIFT_STRICT_CONCURRENCY: complete` on both targets. - Build number (git commit count), `BuildDate`, and `BuildHash` are stamped by the `app-versioning` skill's `update_build_info.sh` (referenced in place from `../indie-skills`, a post-build phase; release tagging is opt-in via `RELEASE_TAGGING=1`). `Scripts/` holds the App Store / TestFlight release pipeline. - Entitlements: iOS uses CloudDocuments + HealthKit; watch uses HealthKit only. **No CloudKit service, no App Group.** -- SPM packages: `IndieSync` (file-side iCloud sync core), `IndieAbout` (in-app About / changelog / license UI), and `Yams` (YAML parsing). +- SPM packages: `IndieSync` (file-side iCloud sync core) and `IndieAbout` (in-app About / changelog / license UI). ### Key Directories - `Shared/` (compiled into both targets): `Model/`, `Persistence/`, `Connectivity/`, `Utils/`, `Screenshots/` -- `Workouts/` (iOS): `Sync/` (the persistence/sync layer), `Connectivity/`, `HealthKit/`, `Seed/`, `Views/` (`Common/`, `Exercises/`, `Settings/`, `Splits/`, `WorkoutLogs/`), `Resources/` (Info.plist, entitlements, `*.exercises.yaml` catalogs) +- `Workouts/` (iOS): `Sync/` (the persistence/sync layer), `Connectivity/`, `HealthKit/`, `Seed/`, `Views/` (`Common/`, `Exercises/`, `Settings/`, `Splits/`, `WorkoutLogs/`), `Resources/` (Info.plist, entitlements, `StarterSplits/`, `ExerciseMotions/`) - `Workouts Watch App/` (watchOS): `Connectivity/`, `Views/`, plus `WorkoutSessionManager`, `WatchAppDelegate`, `WatchAppServices` - Root: `project.yml`, `Scripts/`, and `CHANGELOG.md` / `README.md` / `LICENSE.md` (bundled into the iOS app for IndieAbout) ### Starter Data (deterministic seeds) - **Starter splits**: shipped as byte-canonical `SplitDocument` JSON in `Workouts/Resources/StarterSplits/*.split.json` with **fixed ULIDs** (shared `01DXF6DT00` prefix, frozen 2020 timestamp) and fixed content, regenerated only by `Scripts/generate_starter_splits.swift`. `SeedLibrary` (`Workouts/Seed/`) loads the catalog; **seeds are immutable** — `SyncEngine.save(split:)` transparently clones an edited seed to a fresh ULID and soft-deletes the seed, whose stub is exempt from pruning and vetoes resurrection forever (open views follow the identity swap via `sync.currentSplitID(for:)`). - **Auto-seed**: `SyncEngine.autoSeedIfEmpty()` writes the verbatim bundle bytes after connect, only into a verifiably empty container (no data files, no stubs) re-checked after a settle delay — wrong guesses are harmless because identical bytes make same-path conflicts empty and stubs reap resurrected seeds. The on-demand path (`SplitSeeder.seedDefaults`, "Add Starter Splits") restores deleted seeds (lifting the veto stub) or writes missing ones, skipping live names. -- **Exercise catalogs**: `Workouts/Resources/*.exercises.yaml` (Planet Fitness + bodyweight), parsed with Yams, used by the exercise picker as a reference catalog. +- **Exercise library**: authored in `Exercise Library/` at the repo root (per-exercise `info.md`, SVG visuals, motion rigs, Python render pipeline); the app bundles the exported `Workouts/Resources/ExerciseMotions/*.motion.json` rigs, which double as the exercise picker's list (`ExerciseMotionLibrary.exerciseNames`). ## Guidelines diff --git a/README.md b/README.md index 3ccf7d6..136aa59 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,9 @@ your own iCloud Drive. machine routines, plus an equipment-free **Bodyweight Core** circuit with its own warm-up) appear automatically on first launch; editing one makes it your own copy, and deleted starters can be restored from Settings. -- **Exercise library** — a bundled catalog of starter exercises (bodyweight and - machine-based) to populate your splits, plus a growing reference library - (`Exercise Library/`) with per-exercise setup, cues, mistakes, progressions, - and a rig-animated stick-figure visual system. +- **Exercise library** — a bundled library of exercises to populate your splits, + authored in `Exercise Library/` with per-exercise setup, cues, mistakes, + progressions, and a rig-animated stick-figure visual system. - **Run a workout** — start a session from a split, then tap an exercise to run it as a paged flow: a **Ready?** lead-in, count-up work phases, count-down rests, and a **Finish** page — mirroring the Apple Watch. Swipe a row to mark it complete, or diff --git a/Workouts/ExerciseFigure/ExerciseMotion.swift b/Workouts/ExerciseFigure/ExerciseMotion.swift index a40cf04..0bd6bc2 100644 --- a/Workouts/ExerciseFigure/ExerciseMotion.swift +++ b/Workouts/ExerciseFigure/ExerciseMotion.swift @@ -83,6 +83,19 @@ enum ExerciseMotionLibrary { let body: ExerciseBodyProfile } + /// Every exercise with a bundled motion script, sorted alphabetically. XcodeGen + /// flattens resource groups, so `.motion.json` files land in the + /// bundle root alongside `body.json` — enumerate all json and filter on the + /// compound suffix (which `body.json` doesn't match). + static let exerciseNames: [String] = { + let urls = Bundle.main.urls(forResourcesWithExtension: "json", subdirectory: nil) ?? [] + return urls + .map(\.lastPathComponent) + .filter { $0.hasSuffix(".motion.json") } + .map { String($0.dropLast(".motion.json".count)) } + .sorted() + }() + /// The motion script plus the neutral body profile for `exerciseName`, or `nil` /// when no bundled motion matches (most exercises have none — the caller keeps /// its space empty). diff --git a/Workouts/Resources/bodyweight-starter.exercises.yaml b/Workouts/Resources/bodyweight-starter.exercises.yaml deleted file mode 100644 index 1f22cb7..0000000 --- a/Workouts/Resources/bodyweight-starter.exercises.yaml +++ /dev/null @@ -1,77 +0,0 @@ -name: Starter Set - Bodyweight -source: Home or Minimal Equipment -exercises: - - name: Pull-Up - descr: Grip a bar with hands shoulder-width or wider. Pull your chin above the bar, engaging your back and arms. Lower with control. - type: Bodyweight - split: Upper Body - - - name: Inverted Row - descr: Lie underneath a bar or sturdy edge, pull your chest toward the bar while keeping your body straight. Squeeze shoulder blades together. - type: Bodyweight - split: Upper Body - - - name: Pike Push-Up - descr: Begin in downward dog position. Lower your head toward the ground by bending your elbows, then press back up. Focus on shoulder engagement. - type: Bodyweight - split: Upper Body - - - name: Push-Up - descr: With hands just outside shoulder width, lower your body until elbows are at 90°, then push back up. Keep your body in a straight line. - type: Bodyweight - split: Upper Body - - - name: Tricep Dip - descr: Using a chair or bench, lower your body by bending your elbows behind you, then press back up. Keep elbows tight to your body. - type: Bodyweight - split: Upper Body - - - name: Towel Curl - descr: Sit on the floor with a towel looped under your feet. Pull against the towel using biceps, optionally resisting with your legs. - type: Bodyweight - split: Upper Body - - - name: Crunch - descr: Lie on your back with knees bent. Curl your upper back off the floor using your abdominal muscles, then return slowly. - type: Bodyweight - split: Core - - - name: Russian Twist - descr: Sit with knees bent and feet off the ground. Twist your torso side to side while keeping your abs engaged. - type: Bodyweight - split: Core - - - name: Bodyweight Squat - descr: Stand with feet shoulder-width apart. Lower your hips back and down, keeping your heels on the floor. Rise back to standing. - type: Bodyweight - split: Lower Body - - - name: Wall Sit - descr: Lean your back against a wall and lower into a seated position. Hold as long as possible while maintaining good form. - type: Bodyweight - split: Lower Body - - - name: Glute Bridge - descr: Lie on your back with knees bent. Push through your heels to lift your hips, then lower slowly. Focus on hamstrings and glutes. - type: Bodyweight - split: Lower Body - - - name: Hamstring Walkout - descr: Start in a glute bridge, then slowly walk your heels outward and back in, maintaining control and tension in the hamstrings. - type: Bodyweight - split: Lower Body - - - name: Side-Lying Leg Raise (Inner) - descr: Lie on your side with bottom leg straight. Raise the bottom leg upward, engaging the inner thigh. - type: Bodyweight - split: Lower Body - - - name: Side-Lying Leg Raise (Outer) - descr: Lie on your side with top leg straight. Raise the top leg upward to engage the outer thigh and glute. - type: Bodyweight - split: Lower Body - - - name: Calf Raise - descr: Stand on the balls of your feet (on flat ground or a step). Raise your heels, then lower slowly for a full stretch. - type: Bodyweight - split: Lower Body diff --git a/Workouts/Resources/pf-starter.exercises.yaml b/Workouts/Resources/pf-starter.exercises.yaml deleted file mode 100644 index 7cb829d..0000000 --- a/Workouts/Resources/pf-starter.exercises.yaml +++ /dev/null @@ -1,83 +0,0 @@ -name: Starter Set -source: Planet Fitness -exercises: -- name: Lat Pull Down - descr: Sit upright with your knees secured under the pad. Grip the bar wider than - shoulder-width. Pull the bar down to your chest, squeezing your shoulder blades - together. Avoid leaning back excessively or using momentum. - type: Machine-Based - split: Upper Body -- name: Seated Row - descr: With your chest firmly against the pad, grip the handles and pull straight - back while keeping your elbows close to your body. Focus on retracting your shoulder - blades and avoid rounding your back. - type: Machine-Based - split: Upper Body -- name: Shoulder Press - descr: Sit with your back against the pad, grip the handles just outside shoulder-width. - Press upward without locking out your elbows. Keep your neck relaxed and avoid - shrugging your shoulders. - type: Machine-Based - split: Upper Body -- name: Chest Press - descr: Adjust the seat so the handles are at mid-chest height. Push forward until arms - are nearly extended, then return slowly. Keep wrists straight and dont let your elbows - drop too low. - type: Machine-Based - split: Upper Body -- name: Tricep Press - descr: With elbows close to your sides, press the handles downward in a controlled - motion. Avoid flaring your elbows or using your shoulders to assist the motion. - type: Machine-Based - split: Upper Body -- name: Arm Curl - descr: Position your arms over the pad and grip the handles. Curl the weight upward - while keeping your upper arms stationary. Avoid using momentum and fully control - the lowering phase. - type: Machine-Based - split: Upper Body -- name: Abdominal - descr: Sit with the pads resting against your chest. Contract your abs to curl forward, - keeping your lower back in contact with the pad. Avoid pulling with your arms - or hips. - type: Machine-Based - split: Core -- name: Rotary - descr: Rotate your torso from side to side in a controlled motion, keeping your - hips still. Focus on using your obliques to generate the twist, not momentum or - the arms. - type: Machine-Based - split: Core -- name: Leg Press - descr: Place your feet shoulder-width on the platform. Press upward through your - heels without locking your knees. Keep your back flat against the pad throughout - the motion. - type: Machine-Based - split: Lower Body -- name: Leg Extension - descr: Sit upright and align your knees with the pivot point. Extend your legs to - a straightened position, then lower with control. Avoid jerky movements or lifting - your hips off the seat. - type: Machine-Based - split: Lower Body -- name: Leg Curl - descr: Lie face down or sit depending on the version. Curl your legs toward your - glutes, focusing on hamstring engagement. Avoid arching your back or using momentum. - type: Machine-Based - split: Lower Body -- name: Adductor - descr: Sit with legs placed outside the pads. Bring your legs together using inner - thigh muscles. Control the motion both in and out, avoiding fast swings. - type: Machine-Based - split: Lower Body -- name: Abductor - descr: Sit with legs inside the pads and push outward to engage outer thighs and - glutes. Avoid leaning forward and keep the motion controlled throughout. - type: Machine-Based - split: Lower Body -- name: Calfs - descr: Place the balls of your feet on the platform with heels hanging off. Raise - your heels by contracting your calves, then slowly lower them below the platform - level for a full stretch. - type: Machine-Based - split: Lower Body diff --git a/Workouts/Views/Exercises/ExerciseListLoader.swift b/Workouts/Views/Exercises/ExerciseListLoader.swift deleted file mode 100644 index 14604e6..0000000 --- a/Workouts/Views/Exercises/ExerciseListLoader.swift +++ /dev/null @@ -1,75 +0,0 @@ -// -// ExerciseListLoader.swift -// Workouts -// -// Copyright 2025 Rouslan Zenetl. All Rights Reserved. -// - -import Foundation -import Yams - -class ExerciseListLoader { - struct ExerciseListData: Codable { - let name: String - let source: String - let exercises: [ExerciseItem] - - struct ExerciseItem: Codable, Identifiable { - let name: String - let descr: String - let type: String - let split: String - - var id: String { name } - } - } - - static func loadExerciseLists() -> [String: ExerciseListData] { - var exerciseLists: [String: ExerciseListData] = [:] - - guard let resourcePath = Bundle.main.resourcePath else { - print("Could not find resource path") - return exerciseLists - } - - do { - let fileManager = FileManager.default - let resourceURL = URL(fileURLWithPath: resourcePath) - let yamlFiles = try fileManager.contentsOfDirectory(at: resourceURL, includingPropertiesForKeys: nil) - .filter { $0.pathExtension == "yaml" && $0.lastPathComponent.hasSuffix(".exercises.yaml") } - - for yamlFile in yamlFiles { - let fileName = yamlFile.lastPathComponent - do { - let yamlString = try String(contentsOf: yamlFile, encoding: .utf8) - if let exerciseList = try Yams.load(yaml: yamlString) as? [String: Any], - let name = exerciseList["name"] as? String, - let source = exerciseList["source"] as? String, - let exercisesData = exerciseList["exercises"] as? [[String: Any]] { - - var exercises: [ExerciseListData.ExerciseItem] = [] - - for exerciseData in exercisesData { - if let name = exerciseData["name"] as? String, - let descr = exerciseData["descr"] as? String, - let type = exerciseData["type"] as? String, - let split = exerciseData["split"] as? String { - let exercise = ExerciseListData.ExerciseItem(name: name, descr: descr, type: type, split: split) - exercises.append(exercise) - } - } - - let exerciseList = ExerciseListData(name: name, source: source, exercises: exercises) - exerciseLists[fileName] = exerciseList - } - } catch { - print("Error loading YAML file \(fileName): \(error)") - } - } - } catch { - print("Error listing directory contents: \(error)") - } - - return exerciseLists - } -} diff --git a/Workouts/Views/Exercises/ExercisePickerView.swift b/Workouts/Views/Exercises/ExercisePickerView.swift index 0fbfa2d..c6681e2 100644 --- a/Workouts/Views/Exercises/ExercisePickerView.swift +++ b/Workouts/Views/Exercises/ExercisePickerView.swift @@ -11,8 +11,6 @@ import SwiftUI struct ExercisePickerView: View { @Environment(\.dismiss) private var dismiss - @State private var exerciseLists: [String: ExerciseListLoader.ExerciseListData] = [:] - @State private var selectedListName: String? = nil @State private var selectedExercises: Set = [] var onExerciseSelected: ([String]) -> Void @@ -25,117 +23,52 @@ struct ExercisePickerView: View { var body: some View { NavigationStack { - Group { - if selectedListName == nil { - // Show list of exercise list files - List { - ForEach(Array(exerciseLists.keys.sorted()), id: \.self) { fileName in - if let list = exerciseLists[fileName] { - Button(action: { - selectedListName = fileName - }) { - VStack(alignment: .leading) { - Text(list.name) - .font(.headline) - Text(list.source) - .font(.subheadline) - .foregroundColor(.secondary) - Text("\(list.exercises.count) exercises") - .font(.caption) - .foregroundColor(.secondary) - } - .padding(.vertical, 4) - } + List(ExerciseMotionLibrary.exerciseNames, id: \.self) { exerciseName in + if allowMultiSelect { + Button(action: { + if selectedExercises.contains(exerciseName) { + selectedExercises.remove(exerciseName) + } else { + selectedExercises.insert(exerciseName) + } + }) { + HStack { + Text(exerciseName) + Spacer() + if selectedExercises.contains(exerciseName) { + Image(systemName: "checkmark") + .foregroundColor(.accentColor) } } } - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button("Cancel") { + } else { + Button(action: { + onExerciseSelected([exerciseName]) + dismiss() + }) { + Text(exerciseName) + } + } + } + .navigationTitle("Exercise Library") + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button("Cancel") { + dismiss() + } + } + if allowMultiSelect { + ToolbarItem(placement: .navigationBarTrailing) { + Button("Select") { + if !selectedExercises.isEmpty { + onExerciseSelected(Array(selectedExercises)) dismiss() } } + .disabled(selectedExercises.isEmpty) } - .navigationTitle("Exercise Lists") - } else if let fileName = selectedListName, let list = exerciseLists[fileName] { - // Show exercises in the selected list grouped by split - List { - let exercisesByGroup = Dictionary(grouping: list.exercises) { $0.split } - let sortedGroups = exercisesByGroup.keys.sorted() - - ForEach(sortedGroups, id: \.self) { splitName in - Section(header: Text(splitName)) { - ForEach(exercisesByGroup[splitName]?.sorted(by: { $0.name < $1.name }) ?? [], id: \.id) { exercise in - if allowMultiSelect { - Button(action: { - if selectedExercises.contains(exercise.name) { - selectedExercises.remove(exercise.name) - } else { - selectedExercises.insert(exercise.name) - } - }) { - HStack { - VStack(alignment: .leading) { - Text(exercise.name) - .font(.headline) - Text(exercise.type) - .font(.caption) - .foregroundColor(.secondary) - } - .padding(.vertical, 2) - - Spacer() - - if selectedExercises.contains(exercise.name) { - Image(systemName: "checkmark") - .foregroundColor(.accentColor) - } - } - } - } else { - Button(action: { - onExerciseSelected([exercise.name]) - dismiss() - }) { - VStack(alignment: .leading) { - Text(exercise.name) - .font(.headline) - Text(exercise.type) - .font(.caption) - .foregroundColor(.secondary) - } - .padding(.vertical, 2) - } - } - } - } - } - } - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button("Back") { - selectedListName = nil - selectedExercises.removeAll() - } - } - if allowMultiSelect { - ToolbarItem(placement: .navigationBarTrailing) { - Button("Select") { - if !selectedExercises.isEmpty { - onExerciseSelected(Array(selectedExercises)) - dismiss() - } - } - .disabled(selectedExercises.isEmpty) - } - } - } - .navigationTitle(list.name) } } } - .onAppear { - exerciseLists = ExerciseListLoader.loadExerciseLists() - } } } diff --git a/project.yml b/project.yml index 1ad1935..a9856e0 100644 --- a/project.yml +++ b/project.yml @@ -22,9 +22,6 @@ packages: IndieSync: url: https://git.rzen.dev/rzen/indie-sync.git from: "0.3.0" - Yams: - url: https://github.com/jpsim/Yams - from: "6.0.0" targets: # ---- iOS app (owns iCloud Drive sync; embeds the watch app) ---------------- @@ -49,7 +46,6 @@ targets: dependencies: - package: IndieAbout - package: IndieSync - - package: Yams - target: Workouts Watch App postBuildScripts: - script: '"${SRCROOT}/../indie-skills/skills/app-versioning/scripts/update_build_info.sh"'