From 460bd1634757dd2445edfea7956128518398cc3f Mon Sep 17 00:00:00 2001 From: Trey t Date: Thu, 13 Jun 2024 19:07:33 -0500 Subject: [PATCH] show next up video --- Werkout_ios/BridgeModule.swift | 4 +++ Werkout_ios/CurrentWorkoutInfo.swift | 28 +++++++++++++++++++ .../Views/AccountView/AccountView.swift | 6 ++-- .../Views/ExternalWorkoutDetailView.swift | 14 +++++----- Werkout_ios/Werkout_iosApp.swift | 2 +- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Werkout_ios/BridgeModule.swift b/Werkout_ios/BridgeModule.swift index e0122c4..f038fbf 100644 --- a/Werkout_ios/BridgeModule.swift +++ b/Werkout_ios/BridgeModule.swift @@ -85,6 +85,10 @@ class BridgeModule: NSObject, ObservableObject { } } + var nextExerciseObject: SupersetExercise? { + currentExerciseInfo.nextExercise + } + func resetCurrentWorkout() { DispatchQueue.main.async { self.currentWorkoutRunTimeInSeconds = 0 diff --git a/Werkout_ios/CurrentWorkoutInfo.swift b/Werkout_ios/CurrentWorkoutInfo.swift index 7fce53c..2a39660 100644 --- a/Werkout_ios/CurrentWorkoutInfo.swift +++ b/Werkout_ios/CurrentWorkoutInfo.swift @@ -38,6 +38,34 @@ class CurrentWorkoutInfo { return obj } + var nextExerciseInfo: SupersetExercise? { + guard let workout = workout else { return nil } + guard let supersets = workout.supersets else { return nil } + + var _exerciseIndex = exerciseIndex + 1 + var _supersetIndex = supersetIndex + let currentSuperSet = supersets[_supersetIndex] + + if _exerciseIndex >= currentSuperSet.exercises.count { + var _currentRound = currentRound + 1 + + if currentRound > currentSuperSet.rounds { + _supersetIndex = _supersetIndex + 1 + _currentRound = 1 + + if supersetIndex >= supersets.count { + return nil + } + } + + _exerciseIndex = 0 + } + + let superset = supersets[_supersetIndex] + let exercise = superset.exercises[_exerciseIndex] + return exercise + } + var nextExercise: SupersetExercise? { guard let workout = workout else { return nil } guard let supersets = workout.supersets else { return nil } diff --git a/Werkout_ios/Views/AccountView/AccountView.swift b/Werkout_ios/Views/AccountView/AccountView.swift index 24112b1..f7e5b57 100644 --- a/Werkout_ios/Views/AccountView/AccountView.swift +++ b/Werkout_ios/Views/AccountView/AccountView.swift @@ -14,7 +14,7 @@ struct AccountView: View { @State var showCompletedWorkouts: Bool = false @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never - @AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false + @AppStorage(Constants.extShowNextVideo) private var extShowNextVideo: Bool = false @AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female" var body: some View { @@ -105,8 +105,8 @@ struct AccountView: View { Group { Divider() - Toggle(isOn: $extShowBothVideos, label: { - Text("Show both videos on external") + Toggle(isOn: $extShowNextVideo, label: { + Text("Show next up video") }) } diff --git a/Werkout_ios/Views/ExternalWorkoutDetailView.swift b/Werkout_ios/Views/ExternalWorkoutDetailView.swift index 9ae84e4..cc40c9d 100644 --- a/Werkout_ios/Views/ExternalWorkoutDetailView.swift +++ b/Werkout_ios/Views/ExternalWorkoutDetailView.swift @@ -13,7 +13,7 @@ struct ExternalWorkoutDetailView: View { @State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!) @State var smallAVPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!) @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never - @AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false + @AppStorage(Constants.extShowNextVideo) private var extShowNextVideo: Bool = false @AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female" var body: some View { @@ -47,7 +47,7 @@ struct ExternalWorkoutDetailView: View { } HStack { - if extShowBothVideos && extThotStyle != .off { + if extShowNextVideo && extThotStyle != .off { ExtCountdownView() .frame(width: metrics.size.width * 0.8, height: metrics.size.height * 0.2) .padding(.leading, 50) @@ -85,7 +85,7 @@ struct ExternalWorkoutDetailView: View { avPlayer = AVPlayer(url: videoURL) avPlayer.play() - if extShowBothVideos { + if extShowNextVideo { if let smallVideoURL = VideoURLCreator.videoURL( thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL), gender: thotGenderOption, @@ -110,12 +110,12 @@ struct ExternalWorkoutDetailView: View { avPlayer = AVPlayer(url: videoURL) avPlayer.play() - if extShowBothVideos { + if extShowNextVideo { if let smallVideoURL = VideoURLCreator.videoURL( - thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL), + thotStyle: .never, gender: thotGenderOption, - defaultVideoURLStr: currentExtercise.exercise.videoURL, - exerciseName: currentExtercise.exercise.name, + defaultVideoURLStr: BridgeModule.shared.currentExerciseInfo.nextExerciseInfo?.exercise.videoURL, + exerciseName: BridgeModule.shared.currentExerciseInfo.nextExerciseInfo?.exercise.name, workout: bridgeModule.currentExerciseInfo.workout) { smallAVPlayer = AVPlayer(url: smallVideoURL) smallAVPlayer.play() diff --git a/Werkout_ios/Werkout_iosApp.swift b/Werkout_ios/Werkout_iosApp.swift index 558dfda..bdc9b80 100644 --- a/Werkout_ios/Werkout_iosApp.swift +++ b/Werkout_ios/Werkout_iosApp.swift @@ -13,7 +13,7 @@ import AVKit struct Constants { static let phoneThotStyle = "phoneThotStyle" static let extThotStyle = "extThotStyle" - static let extShowBothVideos = "extShowBothVideos" + static let extShowNextVideo = "extShowNextVideo" static let thotGenderOption = "thotGenderOption" }