WIP
This commit is contained in:
@@ -11,8 +11,10 @@ import AVKit
|
||||
struct ExternalWorkoutDetailView: View {
|
||||
@StateObject var bridgeModule = BridgeModule.shared
|
||||
@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
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workout = bridgeModule.currentExerciseInfo.workout,
|
||||
@@ -20,11 +22,13 @@ struct ExternalWorkoutDetailView: View {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
HStack {
|
||||
PlayerView(player: $avPlayer)
|
||||
.frame(width: metrics.size.width * 0.5, height: metrics.size.height * 0.8)
|
||||
.onAppear{
|
||||
avPlayer.play()
|
||||
}
|
||||
if extThotStyle != .off {
|
||||
PlayerView(player: $avPlayer)
|
||||
.frame(width: metrics.size.width * 0.5, height: metrics.size.height * 0.8)
|
||||
.onAppear{
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
ExtExerciseList(workout: workout,
|
||||
@@ -42,9 +46,25 @@ struct ExternalWorkoutDetailView: View {
|
||||
.frame(width: metrics.size.width * 0.4, height: metrics.size.height * 0.8)
|
||||
}
|
||||
|
||||
ExtCountdownView()
|
||||
.frame(width: metrics.size.width-50, height: metrics.size.height * 0.2)
|
||||
.padding([.leading, .trailing], 50)
|
||||
HStack {
|
||||
if extShowBothVideos && extThotStyle != .off {
|
||||
ExtCountdownView()
|
||||
.frame(width: metrics.size.width * 0.8, height: metrics.size.height * 0.2)
|
||||
.padding(.leading, 50)
|
||||
.padding(.trailing, 5)
|
||||
|
||||
PlayerView(player: $smallAVPlayer)
|
||||
.frame(width: metrics.size.width * 0.2, height: metrics.size.height * 0.2)
|
||||
.padding(.trailing, 50)
|
||||
.onAppear{
|
||||
avPlayer.play()
|
||||
}
|
||||
} else {
|
||||
ExtCountdownView()
|
||||
.frame(width: metrics.size.width-50, height: metrics.size.height * 0.2)
|
||||
.padding([.leading, .trailing], 50)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -54,6 +74,29 @@ struct ExternalWorkoutDetailView: View {
|
||||
.scaledToFill()
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.isInWorkout, perform: { newValue in
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: extThotStyle,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
|
||||
if extShowBothVideos {
|
||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
smallAVPlayer = AVPlayer(url: smallVideoURL)
|
||||
smallAVPlayer.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.onChange(of: bridgeModule.currentExerciseInfo.exerciseIndex, perform: { newValue in
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
@@ -63,11 +106,27 @@ struct ExternalWorkoutDetailView: View {
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
|
||||
if extShowBothVideos {
|
||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
smallAVPlayer = AVPlayer(url: smallVideoURL)
|
||||
smallAVPlayer.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(bridgeModule.currentExerciseInfo.workout == nil ? Color(red: 157/255, green: 138/255, blue: 255/255) : Color(uiColor: .systemBackground))
|
||||
.onReceive(NotificationCenter.default.publisher(
|
||||
for: UIScene.willEnterForegroundNotification)) { _ in
|
||||
avPlayer.play()
|
||||
smallAVPlayer.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,17 +175,16 @@ struct ExtExerciseList: View {
|
||||
.lineLimit(1)
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
|
||||
|
||||
Text(supersetExecercise.exercise.name)
|
||||
.id(exerciseIndex)
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(3)
|
||||
.padding()
|
||||
.id(exerciseIndex)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.id(supersetExecercise.id)
|
||||
}
|
||||
}, header: {
|
||||
HStack {
|
||||
@@ -148,7 +206,8 @@ struct ExtExerciseList: View {
|
||||
}
|
||||
.onChange(of: currentExercise, perform: { newValue in
|
||||
withAnimation {
|
||||
proxy.scrollTo(newValue, anchor: .top)
|
||||
print(newValue.id)
|
||||
proxy.scrollTo(newValue.id, anchor: .top)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -164,22 +223,13 @@ struct ExtCountdownView: View {
|
||||
VStack {
|
||||
if let currenExercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
HStack {
|
||||
Text(currenExercise.exercise.name)
|
||||
Text(currenExercise.exercise.extName)
|
||||
.font(.system(size: 200))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
if currenExercise.exercise.side.count > 0 {
|
||||
Text(" - " + currenExercise.exercise.side)
|
||||
.font(.system(size: 200))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
||||
Text("\(Double(bridgeModule.currentWorkoutRunTimeInSeconds).asString(style: .positional))")
|
||||
.font(Font.system(size: 100))
|
||||
|
||||
Reference in New Issue
Block a user