WIP
This commit is contained in:
@@ -11,7 +11,8 @@ 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")!)
|
||||
|
||||
@AppStorage("showNSFWVideos") private var showNSFWVideos = false
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workout = bridgeModule.currentWorkout {
|
||||
@@ -23,7 +24,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
|
||||
ExtExerciseList(workout: workout,
|
||||
currentExerciseIdx: bridgeModule.currentExerciseIdx)
|
||||
.frame(width: metrics.size.width * 0.4, height: metrics.size.height * 0.8)
|
||||
.frame(width: metrics.size.width * 0.3, height: metrics.size.height * 0.8)
|
||||
|
||||
}
|
||||
|
||||
@@ -38,9 +39,16 @@ struct ExternalWorkoutDetailView: View {
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
||||
if let viddd = newValue?.exercise.videoURL,
|
||||
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||
avPlayer = AVPlayer(url: url)
|
||||
if showNSFWVideos {
|
||||
if let viddd = newValue?.exercise.nsfwVideoURL,
|
||||
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||
avPlayer = AVPlayer(url: url)
|
||||
}
|
||||
} else {
|
||||
if let viddd = newValue?.exercise.videoURL,
|
||||
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||
avPlayer = AVPlayer(url: url)
|
||||
}
|
||||
}
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
@@ -74,21 +82,35 @@ struct ExtExerciseList: View {
|
||||
var currentExerciseIdx: Int
|
||||
|
||||
var body: some View {
|
||||
List() {
|
||||
ForEach(workout.exercisesSortedByCreated_at.indices, id: \.self) { i in
|
||||
let obj = workout.exercisesSortedByCreated_at[i]
|
||||
HStack {
|
||||
if i == currentExerciseIdx {
|
||||
Image(systemName: "checkmark")
|
||||
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: 75))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
|
||||
Text(obj.exercise.name)
|
||||
.font(Font.system(size: 75))
|
||||
.foregroundColor(.green)
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.padding()
|
||||
.id(i)
|
||||
}
|
||||
|
||||
Text(obj.exercise.name)
|
||||
.font(Font.system(size: 75))
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.onChange(of: currentExerciseIdx, perform: { newValue in
|
||||
withAnimation {
|
||||
proxy.scrollTo(newValue, anchor: .top)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,32 +119,49 @@ struct ExtCountdownView: View {
|
||||
@StateObject var bridgeModule = BridgeModule.shared
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if let currenExercise = bridgeModule.currentExercise {
|
||||
HStack {
|
||||
Text(currenExercise.exercise.name)
|
||||
.font(Font.system(size: 100))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
if let currenExercise = bridgeModule.currentExercise {
|
||||
HStack {
|
||||
Text(currenExercise.exercise.name)
|
||||
.font(.system(size: 200))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
||||
Text("\(bridgeModule.currentWorkoutRunTimeInSeconds)")
|
||||
.font(Font.system(size: 100))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.padding(.trailing, 100)
|
||||
}
|
||||
}
|
||||
.frame(height: metrics.size.height * 0.5)
|
||||
|
||||
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
||||
Text("\(bridgeModule.currentWorkoutRunTimeInSeconds)")
|
||||
.font(Font.system(size: 100))
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.padding(.trailing, 100)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
if let duration = currenExercise.duration {
|
||||
ProgressView(value: Float(bridgeModule.currentExerciseTimeLeft), total: Float(duration))
|
||||
.scaleEffect(x: 1, y: 6, anchor: .center)
|
||||
Text("\(bridgeModule.currentExerciseTimeLeft)")
|
||||
.font(Font.system(size: 75))
|
||||
.padding([.leading, .trailing])
|
||||
} else if let reps = currenExercise.reps {
|
||||
Text("\(reps)")
|
||||
.font(Font.system(size: 75))
|
||||
.padding([.leading, .trailing])
|
||||
HStack {
|
||||
if let duration = currenExercise.duration {
|
||||
ProgressView(value: Float(bridgeModule.currentExerciseTimeLeft), total: Float(duration))
|
||||
.scaleEffect(x: 1, y: 6, anchor: .center)
|
||||
Text("\(bridgeModule.currentExerciseTimeLeft)")
|
||||
.font(Font.system(size: 75))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.padding([.leading, .trailing])
|
||||
} else if let reps = currenExercise.reps {
|
||||
Text("\(reps)")
|
||||
.font(Font.system(size: 75))
|
||||
.scaledToFit()
|
||||
.minimumScaleFactor(0.01)
|
||||
.lineLimit(1)
|
||||
.padding([.leading, .trailing])
|
||||
}
|
||||
}
|
||||
.frame(height: metrics.size.height * 0.5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user