ivanscorral / ivanscorral/KoWorkout
Add Sets To Workout Exercises
- Dominant language
- Swift
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
# Add Sets To Workout Exercises
### Summary
Provide UI to add a set for each workout exercise card. New sets should pre-fill target values from the exercise template defaults when available.
---
### Data Layer
Extend WorkoutRepository.update usage to mutate a workout’s exercise by `exerciseId` and call `WorkoutExercise.addSet(...)` (already defined in `KoWorkout/Models/WorkoutExercise.swift:21-39`).
Use `exerciseRepository` to fetch the exercise template for defaults via `exerciseId` stored on `WorkoutExercise`.
---
### ViewModel
Add `func addSet(to exerciseId: UUID)`:
- Lookup Exercise by `exerciseId` in `exerciseRepository`.
- Extract defaults: `defaultReps`, `defaultWeight`, or `defaultDurationSeconds` (for `.time`).
- Call `workoutRepository.update(workoutId) { inout workout in … }` to locate the exercise and `addSet(targetReps:…, targetWeight:…, targetDurationSeconds:…)`.
- Rebuild displays.
---
### UI/UX
In `WorkoutExerciseCard`:
- If there are sets, add a small **“Add Set”** button near the “Sets” header (`KoWorkout/Views/WorkoutDetailView.swift:76`).
- If no sets, add an **“Add Set”** button inside `WorkoutExerciseEmptySetsView` (`KoWorkout/Views/WorkoutDetailView.swift:166-183`).
- The new set should appear as “Set N” at the bottom with correct tags based on type and defaults.
---
### Acceptance Criteria
- [ ] Tapping “Add Set” on an exercise adds a new set with defaults applied based on the exercise type.
- [ ] Order index increments correctly; tag rendering updates immediately in the card.
- [ ] Works for both `.repsWeight` and `.time` exercises.
---
### Files To Touch
- `KoWorkout/Views/WorkoutDetailView.swift:74-86, :166-183`
- `KoWorkout/ViewModels/WorkoutDetailViewModel.swift` (new `addSet(to:)`)
- Repository usage as introduced in **Issue 1**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.