complete then get health data on completion screen
This commit is contained in:
@@ -95,7 +95,9 @@ struct WorkoutDetailView: View {
|
||||
bridgeModule.completeWorkout()
|
||||
}, planWorkout: { workout in
|
||||
workoutToPlan = workout
|
||||
}, workout: workout, showAddToCalendar: viewModel.isPreview)
|
||||
}, workout: workout, showAddToCalendar: viewModel.isPreview, startWorkoutAction: {
|
||||
startWorkout(workout: workout)
|
||||
})
|
||||
.frame(height: 44)
|
||||
|
||||
}
|
||||
@@ -104,7 +106,6 @@ struct WorkoutDetailView: View {
|
||||
case .completedWorkout(let data):
|
||||
CompletedWorkoutView(postData: data,
|
||||
workout: workout,
|
||||
healthKitUUID: bridgeModule.healthKitUUID,
|
||||
completedWorkoutDismissed: { uploaded in
|
||||
if uploaded {
|
||||
dismiss()
|
||||
@@ -157,13 +158,6 @@ struct WorkoutDetailView: View {
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
bridgeModule.completedWorkout = {
|
||||
if let workoutData = createWorkoutData() {
|
||||
presentedSheet = .completedWorkout(workoutData)
|
||||
bridgeModule.resetCurrentWorkout()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(
|
||||
for: UIScene.willEnterForegroundNotification)) { _ in
|
||||
@@ -171,6 +165,17 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func startWorkout(workout: Workout) {
|
||||
bridgeModule.completedWorkout = {
|
||||
if let workoutData = createWorkoutData() {
|
||||
presentedSheet = .completedWorkout(workoutData)
|
||||
bridgeModule.resetCurrentWorkout()
|
||||
}
|
||||
}
|
||||
|
||||
bridgeModule.start(workout: workout)
|
||||
}
|
||||
|
||||
func createWorkoutData() -> [String:Any]? {
|
||||
guard let workoutid = bridgeModule.currentExerciseInfo.workout?.id,
|
||||
let startTime = bridgeModule.workoutStartDate?.timeFormatForUpload,
|
||||
|
||||
Reference in New Issue
Block a user