WIP
This commit is contained in:
@@ -19,52 +19,65 @@ struct WorkoutDetailView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
Button("i dont want to do this", action: {
|
||||
bridgeModule.currentWorkout = nil
|
||||
dismiss()
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.red)
|
||||
|
||||
Button("ohhh lets do it", action: {
|
||||
runItemAt(idx: 0)
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.green)
|
||||
}
|
||||
.frame(height: 88)
|
||||
List() {
|
||||
ForEach(viewModel.workout.exercisesSortedByCreated_at.indices, id: \.self) { i in
|
||||
let obj = viewModel.workout.exercisesSortedByCreated_at[i]
|
||||
Text(obj.exercise.name ?? "")
|
||||
.onTapGesture { selectedIdx = i }
|
||||
ZStack {
|
||||
switch viewModel.status {
|
||||
case .loading:
|
||||
Text("Loading")
|
||||
case .showWorkout(let workout):
|
||||
VStack {
|
||||
HStack {
|
||||
Button("i dont want to do this", action: {
|
||||
bridgeModule.currentWorkout = nil
|
||||
dismiss()
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.red)
|
||||
|
||||
Button("ohhh lets do it", action: {
|
||||
runItemAt(idx: 0)
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.green)
|
||||
}
|
||||
.frame(height: 88)
|
||||
List() {
|
||||
ForEach(workout.exercisesSortedByCreated_at.indices, id: \.self) { i in
|
||||
let obj = workout.exercisesSortedByCreated_at[i]
|
||||
Text(obj.exercise.name ?? "")
|
||||
.onTapGesture { selectedIdx = i }
|
||||
}
|
||||
}
|
||||
|
||||
if let duration = bridgeModule.currentExercise?.duration {
|
||||
HStack {
|
||||
ProgressView(value: Float(bridgeModule.timeLeft), total: Float(duration))
|
||||
Text("\(bridgeModule.timeLeft)")
|
||||
}.padding(16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let duration = bridgeModule.currentExercise?.duration {
|
||||
HStack {
|
||||
ProgressView(value: Float(bridgeModule.timeLeft), total: Float(duration))
|
||||
Text("\(bridgeModule.timeLeft)")
|
||||
}.padding(16)
|
||||
.onAppear{
|
||||
bridgeModule.timerCompleted = {
|
||||
selectedIdx += 1
|
||||
}
|
||||
}
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
}
|
||||
.onAppear{
|
||||
bridgeModule.timerCompleted = {
|
||||
selectedIdx += 1
|
||||
}
|
||||
}
|
||||
.interactiveDismissDisabled()
|
||||
|
||||
}
|
||||
|
||||
func runItemAt(idx: Int) {
|
||||
if idx < viewModel.workout.exercises.count {
|
||||
let exercise = viewModel.workout.exercises[idx]
|
||||
bridgeModule.updateCurrent(exercise: exercise)
|
||||
bridgeModule.currentExerciseIdx = idx
|
||||
} else {
|
||||
workoutComplete()
|
||||
switch viewModel.status {
|
||||
case .showWorkout(let workout):
|
||||
if idx < workout.exercises.count {
|
||||
let exercise = workout.exercises[idx]
|
||||
bridgeModule.updateCurrent(exercise: exercise)
|
||||
bridgeModule.currentExerciseIdx = idx
|
||||
} else {
|
||||
workoutComplete()
|
||||
}
|
||||
default:
|
||||
fatalError("no workout!!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user