ivanscorral / ivanscorral/KoWorkout

Edit/Delete/Reorder Sets For Workout Exercises

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 3) Edit/Delete/Reorder Sets For Workout Exercises

### Summary
Allow editing a set’s target/actual values, deleting, and reordering sets within a workout exercise.

---

### Data Layer
Extend `WorkoutRepository.update` usage to:
- Update a set in-place by `exerciseId` and `setId`.
- Delete a set and resequence `orderIndex` for remaining sets.
- Move a set (drag reorder) and resequence `orderIndex`.

No new repository types are required if `WorkoutRepository.update` allows arbitrary mutations.

---

### ViewModel
Add:
- `func updateSet(exerciseId: UUID, setId: UUID, targetReps: Int?, targetWeight: WeightValue?, targetDurationSeconds: Int?, actualReps: Int?, actualWeight: WeightValue?, actualDurationSeconds: Int?, rpe: Int?, rir: Int?)`
- `func deleteSet(exerciseId: UUID, setId: UUID)`
- `func moveSet(exerciseId: UUID, from source: Int, to destination: Int)`

Each method calls `workoutRepository.update` and then rebuilds displays.

---

### UI/UX
New `WorkoutSetEditorView` (sheet) with fields:
- **Targets:** reps/weight OR duration (based on `ExerciseType`)
- **Actuals:** reps/weight OR duration
- **Effort:** RPE, RIR

**Entry points:**
- Tap a set row (`KoWorkout/Views/WorkoutDetailView.swift:102-129`) to edit.
- Context menu or inline buttons for “Edit” and “Delete”.
- Optional drag-and-drop reorder if sets are refactored into a `List` with `onMove`, or add explicit up/down controls.

Validate numeric fields; use number/integer keyboards where appropriate.

---

### Acceptance Criteria
- ✅ Editing any set field updates its displayed tags immediately.
- ✅ Deleting resequences set titles (“Set 1…N”).
- ✅ Reordering changes the visual order and persists `orderIndex`.
- ✅ Works for both exercise types (`.repsWeight` and `.time`).

---

### Files To Touch
- `KoWorkout/Views/WorkoutDetailView.swift:102-129` (tap/edit affordances)
- **New:** `KoWorkout/Views/WorkoutSetEditorView.swift`
- `KoWorkout/ViewModels/WorkoutDetailViewModel.swift` (new methods)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at KoWorkout/Views/WorkoutDetailView.swift:102-129 and read WorkoutDetailViewModel.swift alongside the existing WorkoutRepository.update usage. Add WorkoutSetEditorView and the specified edit, delete, and move entry points, then verify that both exercise types update immediately, deletions resequence set titles, and reordering persists orderIndex.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.