WIP
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user