WIP
This commit is contained in:
@@ -12,6 +12,9 @@ import HealthKit
|
||||
|
||||
enum WatchActions: Codable {
|
||||
case nextExercise
|
||||
case restartExercise
|
||||
case previousExercise
|
||||
case stopWorkout
|
||||
case workoutComplete(Data)
|
||||
}
|
||||
|
||||
@@ -169,6 +172,30 @@ class BridgeModule: NSObject, ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func previousExercise() {
|
||||
currentExerciseIdx -= 1
|
||||
if currentExerciseIdx < 0 {
|
||||
currentExerciseIdx = 0
|
||||
}
|
||||
if let currentWorkout = currentWorkout {
|
||||
if currentExerciseIdx < currentWorkout.exercises.count {
|
||||
let nextExercise = currentWorkout.exercises[currentExerciseIdx]
|
||||
updateCurrent(exercise: nextExercise)
|
||||
} else {
|
||||
completeWorkout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func restartExercise() {
|
||||
if let currentWorkout = currentWorkout {
|
||||
if currentExerciseIdx < currentWorkout.exercises.count {
|
||||
let nextExercise = currentWorkout.exercises[currentExerciseIdx]
|
||||
updateCurrent(exercise: nextExercise)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func addOneToWorkoutRunTime() {
|
||||
currentWorkoutRunTimeInSeconds += 1
|
||||
}
|
||||
@@ -265,6 +292,12 @@ extension BridgeModule: WCSessionDelegate {
|
||||
totalCaloire = Float(model.totalBurnedEnergery)
|
||||
heartRates = model.allHeartRates
|
||||
completedWorkout?()
|
||||
case .restartExercise:
|
||||
restartExercise()
|
||||
case .previousExercise:
|
||||
previousExercise()
|
||||
case .stopWorkout:
|
||||
completeWorkout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user