This commit is contained in:
Trey t
2023-07-28 11:15:13 -05:00
parent 2dcd260887
commit 1997abeff6
13 changed files with 264 additions and 101 deletions

View File

@@ -17,8 +17,7 @@ struct ExternalWorkoutDetailView: View {
var body: some View {
ZStack {
if let workout = bridgeModule.currentExerciseInfo.workout,
let exercise = bridgeModule.currentExerciseInfo.currentExercise {
if let workout = bridgeModule.currentExerciseInfo.workout {
GeometryReader { metrics in
VStack {
HStack {
@@ -32,7 +31,7 @@ struct ExternalWorkoutDetailView: View {
VStack {
ExtExerciseList(workout: workout,
currentExercise: exercise)
allSupersetExecerciseIndex: bridgeModule.currentExerciseInfo.allSupersetExecerciseIndex)
if let currentExercisePositionString = bridgeModule.currentExercisePositionString {
Text(currentExercisePositionString)
@@ -153,63 +152,64 @@ struct TitleView: View {
struct ExtExerciseList: View {
var workout: Workout
var currentExercise: SupersetExercise
var allSupersetExecerciseIndex: Int
var body: some View {
if let supersets = workout.supersets {
ScrollViewReader { proxy in
List() {
ForEach(supersets.indices, id: \.self) { supersetIndex in
let superset = supersets[supersetIndex]
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)
if let allSupersetExecercise = workout.allSupersetExecercise {
ZStack {
ScrollViewReader { proxy in
List() {
ForEach(allSupersetExecercise.indices, id: \.self) { supersetExecerciseIdx in
let supersetExecercise = allSupersetExecercise[supersetExecerciseIdx]
HStack {
if supersetExecerciseIdx == allSupersetExecerciseIndex {
Image(systemName: "checkmark")
.foregroundColor(.green)
.font(Font.system(size: 55))
.minimumScaleFactor(0.01)
.lineLimit(3)
.padding()
Spacer()
.lineLimit(1)
.foregroundColor(.green)
}
.id(supersetExecercise.id)
}
}, header: {
HStack {
Text(superset.name ?? "--")
Text(supersetExecercise.exercise.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()
}
})
.id(supersetExecerciseIdx)
}
}
.onChange(of: allSupersetExecerciseIndex, perform: { newValue in
withAnimation {
proxy.scrollTo(allSupersetExecerciseIndex, anchor: .top)
}
})
}
VStack {
Text("\(allSupersetExecerciseIndex+1)/\(workout.allSupersetExecercise?.count ?? 0)")
.font(Font.system(size: 55))
.minimumScaleFactor(0.01)
.lineLimit(1)
.padding()
.bold()
.foregroundColor(.white)
.background(
Capsule()
.strokeBorder(Color.black, lineWidth: 0.8)
.background(Color(uiColor: UIColor(red: 148/255,
green: 0,
blue: 211/255,
alpha: 0.5)))
.clipped()
)
.clipShape(Capsule())
Spacer()
}
.onChange(of: currentExercise, perform: { newValue in
withAnimation {
print(newValue.id)
proxy.scrollTo(newValue.id, anchor: .top)
}
})
}
}
}