WIP
fix naming on variable fix tapping on exercise not updating external correctly
This commit is contained in:
@@ -37,13 +37,13 @@ struct AllWorkoutsView: View {
|
||||
@State private var showWorkoutDetail = false
|
||||
@State private var selectedWorkout: Workout? {
|
||||
didSet {
|
||||
bridgeModule.currentExerciseInfo.workout = selectedWorkout
|
||||
bridgeModule.currentWorkoutInfo.workout = selectedWorkout
|
||||
}
|
||||
}
|
||||
|
||||
@State private var selectedPlannedWorkout: Workout? {
|
||||
didSet {
|
||||
bridgeModule.currentExerciseInfo.workout = selectedPlannedWorkout
|
||||
bridgeModule.currentWorkoutInfo.workout = selectedPlannedWorkout
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ struct AllWorkoutsView: View {
|
||||
AllWorkoutPickerView(mainViews: MainViewTypes.allCases,
|
||||
selectedSegment: $selectedSegment,
|
||||
showCurrentWorkout: {
|
||||
selectedWorkout = bridgeModule.currentExerciseInfo.workout
|
||||
selectedWorkout = bridgeModule.currentWorkoutInfo.workout
|
||||
})
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ struct AllWorkoutsView: View {
|
||||
maybeUpdateShit()
|
||||
}
|
||||
.sheet(item: $selectedWorkout) { item in
|
||||
let isPreview = item.id == bridgeModule.currentExerciseInfo.workout?.id
|
||||
let isPreview = item.id == bridgeModule.currentWorkoutInfo.workout?.id
|
||||
let viewModel = WorkoutDetailViewModel(workout: item, isPreview: isPreview)
|
||||
WorkoutDetailView(viewModel: viewModel)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workout = bridgeModule.currentExerciseInfo.workout {
|
||||
if let workout = bridgeModule.currentWorkoutInfo.workout {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
HStack {
|
||||
@@ -32,7 +32,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
|
||||
VStack {
|
||||
ExtExerciseList(workout: workout,
|
||||
allSupersetExecerciseIndex: bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex)
|
||||
allSupersetExecerciseIndex: bridgeModule.currentWorkoutInfo.allSupersetExecerciseIndex)
|
||||
}
|
||||
.frame(width: metrics.size.width * 0.4, height: metrics.size.height * 0.8)
|
||||
.padding([.top, .bottom], 20)
|
||||
@@ -93,11 +93,11 @@ struct ExternalWorkoutDetailView: View {
|
||||
.onChange(of: bridgeModule.isInWorkout, perform: { _ in
|
||||
playVideos()
|
||||
})
|
||||
.onChange(of: bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex, perform: { _ in
|
||||
.onChange(of: bridgeModule.currentWorkoutInfo.allSupersetExecerciseIndex, perform: { _ in
|
||||
playVideos()
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(bridgeModule.currentExerciseInfo.workout == nil ? Color(red: 157/255, green: 138/255, blue: 255/255) : Color(uiColor: .systemBackground))
|
||||
.background(bridgeModule.currentWorkoutInfo.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()
|
||||
@@ -106,13 +106,13 @@ struct ExternalWorkoutDetailView: View {
|
||||
}
|
||||
|
||||
func playVideos() {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let currentExtercise = bridgeModule.currentWorkoutInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: extThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
workout: bridgeModule.currentWorkoutInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
@@ -120,9 +120,9 @@ struct ExternalWorkoutDetailView: View {
|
||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: .never,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: BridgeModule.shared.currentExerciseInfo.nextExerciseInfo?.exercise.videoURL,
|
||||
exerciseName: BridgeModule.shared.currentExerciseInfo.nextExerciseInfo?.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout),
|
||||
defaultVideoURLStr: BridgeModule.shared.currentWorkoutInfo.nextExerciseInfo?.exercise.videoURL,
|
||||
exerciseName: BridgeModule.shared.currentWorkoutInfo.nextExerciseInfo?.exercise.name,
|
||||
workout: bridgeModule.currentWorkoutInfo.workout),
|
||||
extShowNextVideo {
|
||||
smallAVPlayer = AVPlayer(url: smallVideoURL)
|
||||
smallAVPlayer.play()
|
||||
|
||||
@@ -23,7 +23,7 @@ struct ExerciseListView: View {
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: self.videoExercise?.videoURL,
|
||||
exerciseName: self.videoExercise?.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
workout: bridgeModule.currentWorkoutInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
@@ -42,8 +42,8 @@ struct ExerciseListView: View {
|
||||
VStack {
|
||||
HStack {
|
||||
if bridgeModule.isInWorkout &&
|
||||
supersetIndex == bridgeModule.currentExerciseInfo.supersetIndex &&
|
||||
exerciseIndex == bridgeModule.currentExerciseInfo.exerciseIndex {
|
||||
supersetIndex == bridgeModule.currentWorkoutInfo.supersetIndex &&
|
||||
exerciseIndex == bridgeModule.currentWorkoutInfo.exerciseIndex {
|
||||
Image(systemName: "figure.run")
|
||||
.foregroundColor(Color("appColor"))
|
||||
}
|
||||
@@ -92,15 +92,17 @@ struct ExerciseListView: View {
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
if bridgeModule.isInWorkout {
|
||||
bridgeModule.goToExerciseAt(section: supersetIndex, row: exerciseIndex)
|
||||
bridgeModule.currentWorkoutInfo.goToExerciseAt(
|
||||
supersetIndex: supersetIndex,
|
||||
exerciseIndex: exerciseIndex)
|
||||
} else {
|
||||
videoExercise = supersetExecercise.exercise
|
||||
}
|
||||
}
|
||||
|
||||
if bridgeModule.isInWorkout &&
|
||||
supersetIndex == bridgeModule.currentExerciseInfo.supersetIndex &&
|
||||
exerciseIndex == bridgeModule.currentExerciseInfo.exerciseIndex &&
|
||||
supersetIndex == bridgeModule.currentWorkoutInfo.supersetIndex &&
|
||||
exerciseIndex == bridgeModule.currentWorkoutInfo.exerciseIndex &&
|
||||
showExecersizeInfo {
|
||||
detailView(forExercise: supersetExecercise)
|
||||
}
|
||||
@@ -125,8 +127,8 @@ struct ExerciseListView: View {
|
||||
})
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex, perform: { newValue in
|
||||
if let newCurrentExercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
.onChange(of: bridgeModule.currentWorkoutInfo.allSupersetExecerciseIndex, perform: { newValue in
|
||||
if let newCurrentExercise = bridgeModule.currentWorkoutInfo.currentExercise {
|
||||
withAnimation {
|
||||
proxy.scrollTo(newCurrentExercise.id, anchor: .top)
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ struct WorkoutDetailView: View {
|
||||
|
||||
Button(action: {
|
||||
if let assetURL = ((avPlayer.currentItem?.asset) as? AVURLAsset)?.url,
|
||||
let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise,
|
||||
let currentExtercise = bridgeModule.currentWorkoutInfo.currentExercise,
|
||||
let otherVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: assetURL),
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
workout: bridgeModule.currentWorkoutInfo.workout) {
|
||||
avPlayer = AVPlayer(url: otherVideoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
@@ -98,7 +98,7 @@ struct WorkoutDetailView: View {
|
||||
Divider()
|
||||
.background(Color(uiColor: .secondaryLabel))
|
||||
HStack {
|
||||
Text("\(bridgeModule.currentExerciseInfo.currentRound) of \(bridgeModule.currentExerciseInfo.numberOfRoundsInCurrentSuperSet)")
|
||||
Text("\(bridgeModule.currentWorkoutInfo.currentRound) of \(bridgeModule.currentWorkoutInfo.numberOfRoundsInCurrentSuperSet)")
|
||||
.font(.title3)
|
||||
.bold()
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -107,7 +107,7 @@ struct WorkoutDetailView: View {
|
||||
CurrentWorkoutElapsedTimeView()
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
|
||||
Text("\(bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex+1)/\(bridgeModule.currentExerciseInfo.workout?.allSupersetExecercise?.count ?? -99)")
|
||||
Text("\(bridgeModule.currentWorkoutInfo.allSupersetExecerciseIndex+1)/\(bridgeModule.currentWorkoutInfo.workout?.allSupersetExecercise?.count ?? -99)")
|
||||
.font(.title3)
|
||||
.bold()
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
@@ -154,20 +154,20 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex, perform: { _ in
|
||||
.onChange(of: bridgeModule.currentWorkoutInfo.allSupersetExecerciseIndex, perform: { _ in
|
||||
playVideos()
|
||||
})
|
||||
.onChange(of: bridgeModule.isInWorkout, perform: { _ in
|
||||
playVideos()
|
||||
})
|
||||
.onAppear{
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let currentExtercise = bridgeModule.currentWorkoutInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
workout: bridgeModule.currentWorkoutInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
@@ -186,13 +186,13 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
|
||||
func playVideos() {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let currentExtercise = bridgeModule.currentWorkoutInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
workout: bridgeModule.currentWorkoutInfo.workout) {
|
||||
avPlayer = AVPlayer(url: videoURL)
|
||||
avPlayer.play()
|
||||
}
|
||||
@@ -204,7 +204,7 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
|
||||
func createWorkoutData() -> [String:Any]? {
|
||||
guard let workoutid = bridgeModule.currentExerciseInfo.workout?.id,
|
||||
guard let workoutid = bridgeModule.currentWorkoutInfo.workout?.id,
|
||||
let startTime = bridgeModule.workoutStartDate?.timeFormatForUpload,
|
||||
let endTime = bridgeModule.workoutEndDate?.timeFormatForUpload else {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user