This commit is contained in:
Trey t
2023-07-28 11:15:13 -05:00
parent 2dcd260887
commit 1997abeff6
13 changed files with 264 additions and 101 deletions

View File

@@ -14,6 +14,7 @@ class CurrentWorkoutInfo {
var complete: (() -> Void)?
var currentRound = 1
var allSupersetExecerciseIndex = 0
var superset: [Superset] {
return workout?.supersets?.sorted(by: { $0.order < $1.order }) ?? [Superset]()
@@ -57,6 +58,7 @@ class CurrentWorkoutInfo {
let superset = supersets[supersetIndex]
let exercise = superset.exercises[exerciseIndex]
allSupersetExecerciseIndex += 1
return exercise
}
@@ -84,6 +86,12 @@ class CurrentWorkoutInfo {
let superset = supersets[supersetIndex]
let exercise = superset.exercises[exerciseIndex]
allSupersetExecerciseIndex -= 1
if allSupersetExecerciseIndex < 0 {
allSupersetExecerciseIndex = 0
}
return exercise
}
@@ -96,12 +104,21 @@ class CurrentWorkoutInfo {
supersetIndex = 0
exerciseIndex = 0
currentRound = 1
allSupersetExecerciseIndex = 0
self.workout = nil
}
func goToWorkoutAt(supersetIndex: Int, exerciseIndex: Int) -> SupersetExercise? {
self.supersetIndex = supersetIndex
self.exerciseIndex = exerciseIndex
self.currentRound = 1
let currentExercise = currentExercise
if let firstIdx = workout?.allSupersetExecercise?.firstIndex(where: {
$0.exercise.id == currentExercise?.exercise.id
}) {
allSupersetExecerciseIndex = firstIdx
}
return currentExercise
}