WIP
This commit is contained in:
@@ -15,7 +15,8 @@ struct ExternalWorkoutDetailView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workout = bridgeModule.currentWorkout {
|
||||
if let workout = bridgeModule.currentExerciseInfo.workout,
|
||||
let exercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
HStack {
|
||||
@@ -26,8 +27,8 @@ struct ExternalWorkoutDetailView: View {
|
||||
}
|
||||
|
||||
VStack {
|
||||
ExtExerciseList(workout: workout,
|
||||
currentExerciseIdx: bridgeModule.currentExerciseIdx)
|
||||
ExtExerciseList(workout: workout,
|
||||
currentExercise: exercise)
|
||||
|
||||
if let currentExercisePositionString = bridgeModule.currentExercisePositionString {
|
||||
Text(currentExercisePositionString)
|
||||
@@ -53,18 +54,20 @@ struct ExternalWorkoutDetailView: View {
|
||||
.scaledToFill()
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
||||
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()
|
||||
.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()
|
||||
}
|
||||
}
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(bridgeModule.currentWorkout == nil ? Color(red: 157/255, green: 138/255, blue: 255/255) : Color(uiColor: .systemBackground))
|
||||
.background(bridgeModule.currentExerciseInfo.workout == nil ? Color(red: 157/255, green: 138/255, blue: 255/255) : Color(uiColor: .systemBackground))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +76,7 @@ struct TitleView: View {
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
if let workout = bridgeModule.currentWorkout {
|
||||
if let workout = bridgeModule.currentExerciseInfo.workout {
|
||||
Text(workout.name)
|
||||
.font(Font.system(size: 100))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -91,36 +94,64 @@ struct TitleView: View {
|
||||
|
||||
struct ExtExerciseList: View {
|
||||
var workout: Workout
|
||||
var currentExerciseIdx: Int
|
||||
var currentExercise: SupersetExercise
|
||||
|
||||
var body: some View {
|
||||
ScrollViewReader { proxy in
|
||||
List() {
|
||||
ForEach(workout.exercisesSortedByCreated_at.indices, id: \.self) { i in
|
||||
let obj = workout.exercisesSortedByCreated_at[i]
|
||||
HStack {
|
||||
if i == currentExerciseIdx {
|
||||
Image(systemName: "checkmark")
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
if let supersets = workout.supersets {
|
||||
ScrollViewReader { proxy in
|
||||
List() {
|
||||
ForEach(supersets.indices, id: \.self) { supersetIndex in
|
||||
let superset = supersets[supersetIndex]
|
||||
|
||||
Text(obj.exercise.name)
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(3)
|
||||
.padding()
|
||||
.id(i)
|
||||
Section(content: {
|
||||
ForEach(superset.exercises.indices, id: \.self) { exerciseIndex in
|
||||
let supersetExecercise = superset.exercises[exerciseIndex]
|
||||
|
||||
HStack {
|
||||
if supersetExecercise.id == currentExercise.id {
|
||||
Image(systemName: "checkmark")
|
||||
.foregroundColor(.green)
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
|
||||
Text(supersetExecercise.exercise.name)
|
||||
.id(exerciseIndex)
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(3)
|
||||
.padding()
|
||||
.id(exerciseIndex)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}, header: {
|
||||
HStack {
|
||||
Text(superset.name ?? "--")
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(3)
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
Text("\(superset.rounds) rounds")
|
||||
.font(Font.system(size: 55))
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(3)
|
||||
.padding()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.onChange(of: currentExercise, perform: { newValue in
|
||||
withAnimation {
|
||||
proxy.scrollTo(newValue, anchor: .top)
|
||||
}
|
||||
})
|
||||
}
|
||||
.onChange(of: currentExerciseIdx, perform: { newValue in
|
||||
withAnimation {
|
||||
proxy.scrollTo(newValue, anchor: .top)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +162,7 @@ struct ExtCountdownView: View {
|
||||
var body: some View {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
if let currenExercise = bridgeModule.currentExercise {
|
||||
if let currenExercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
HStack {
|
||||
Text(currenExercise.exercise.name)
|
||||
.font(.system(size: 200))
|
||||
@@ -203,15 +234,15 @@ struct ExtCountdownView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct ExternalWorkoutDetailView_Previews: PreviewProvider {
|
||||
static var bridge = BridgeModule.shared
|
||||
|
||||
static var previews: some View {
|
||||
ExternalWorkoutDetailView().environmentObject({ () -> BridgeModule in
|
||||
let envObj = BridgeModule.shared
|
||||
envObj.currentWorkout = nil //PreviewData.workout()
|
||||
bridge.currentExercise = PreviewData.workout().exercisesSortedByCreated_at.first!
|
||||
return envObj
|
||||
}() )
|
||||
}
|
||||
}
|
||||
//struct ExternalWorkoutDetailView_Previews: PreviewProvider {
|
||||
// static var bridge = BridgeModule.shared
|
||||
//
|
||||
// static var previews: some View {
|
||||
// ExternalWorkoutDetailView().environmentObject({ () -> BridgeModule in
|
||||
// let envObj = BridgeModule.shared
|
||||
// envObj.currentWorkout = nil //PreviewData.workout()
|
||||
// bridge.currentExercise = PreviewData.workout().exercisesSortedByCreated_at.first!
|
||||
// return envObj
|
||||
// }() )
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user