WIP
This commit is contained in:
@@ -23,7 +23,6 @@ struct WorkoutDetailView: View {
|
||||
|
||||
@State var presentedSheet: Sheet?
|
||||
@State var workoutToPlan: Workout?
|
||||
var showAddToCalendar = true
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
@@ -80,7 +79,7 @@ struct WorkoutDetailView: View {
|
||||
bridgeModule.completeWorkout()
|
||||
}, planWorkout: { workout in
|
||||
workoutToPlan = workout
|
||||
}, workout: workout, showAddToCalendar: showAddToCalendar)
|
||||
}, workout: workout, showAddToCalendar: viewModel.isPreview)
|
||||
.frame(height: 44)
|
||||
|
||||
}
|
||||
@@ -101,24 +100,28 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: thotStyle,
|
||||
defaultVideoURLStr: newValue?.exercise.videoURL,
|
||||
exerciseName: newValue?.exercise.name,
|
||||
workout: bridgeModule.currentWorkout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
.onChange(of: bridgeModule.currentExerciseInfo.exerciseIndex, perform: { newValue in
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: thotStyle,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
})
|
||||
.onAppear{
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: thotStyle,
|
||||
defaultVideoURLStr: bridgeModule.currentExercise?.exercise.videoURL,
|
||||
exerciseName: bridgeModule.currentExercise?.exercise.name,
|
||||
workout: bridgeModule.currentWorkout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: thotStyle,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
bridgeModule.completedWorkout = {
|
||||
@@ -132,7 +135,7 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
|
||||
func createWorkoutData() -> [String:Any]? {
|
||||
guard let workoutid = bridgeModule.currentWorkout?.id,
|
||||
guard let workoutid = bridgeModule.currentExerciseInfo.workout?.id,
|
||||
let startTime = bridgeModule.workoutStartDate?.timeFormatForUpload,
|
||||
let endTime = bridgeModule.workoutEndDate?.timeFormatForUpload else {
|
||||
return nil
|
||||
@@ -154,6 +157,6 @@ struct WorkoutDetailView: View {
|
||||
struct WorkoutDetailView_Previews: PreviewProvider {
|
||||
static let workoutDetail = PreviewData.workout()
|
||||
static var previews: some View {
|
||||
WorkoutDetailView(viewModel: WorkoutDetailViewModel(workout: WorkoutDetailView_Previews.workoutDetail, status: .showWorkout(WorkoutDetailView_Previews.workoutDetail)))
|
||||
WorkoutDetailView(viewModel: WorkoutDetailViewModel(workout: WorkoutDetailView_Previews.workoutDetail, status: .showWorkout(WorkoutDetailView_Previews.workoutDetail), isPreview: true))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user