This commit is contained in:
Trey t
2023-08-09 10:13:13 -05:00
parent 173f39cc5f
commit 4824fbc0fe
16 changed files with 206 additions and 93 deletions

View File

@@ -24,49 +24,61 @@ struct CreateWorkoutMainView: View {
.padding()
.frame(height: 55)
.textFieldStyle(OvalTextFieldStyle())
List() {
ForEach($viewModel.superSets, id: \.id) { superset in
Section {
ForEach(superset.exercises, id: \.id) { exercise in
HStack {
VStack {
Text(exercise.wrappedValue.exercise.name)
.font(.title2)
.frame(maxWidth: .infinity)
if exercise.wrappedValue.exercise.side.count > 0 {
Text(exercise.wrappedValue.exercise.side)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .center)
ScrollViewReader { proxy in
List() {
ForEach($viewModel.superSets, id: \.id) { superset in
Section {
ForEach(superset.exercises, id: \.id) { exercise in
HStack {
VStack {
Text(exercise.wrappedValue.exercise.name)
.font(.title2)
.frame(maxWidth: .infinity)
if exercise.wrappedValue.exercise.side.count > 0 {
Text(exercise.wrappedValue.exercise.side)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .center)
}
CreateExerciseActionsView(workoutExercise: exercise.wrappedValue,
superset: superset.wrappedValue,
viewModel: viewModel)
}
CreateExerciseActionsView(workoutExercise: exercise.wrappedValue,
superset: superset.wrappedValue,
viewModel: viewModel)
}
}
HStack {
Stepper("Number of rounds", onIncrement: {
superset.wrappedValue.increaseNumberOfRounds()
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
}, onDecrement: {
superset.wrappedValue.decreaseNumberOfRounds()
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
})
Text("\(superset.wrappedValue.numberOfRounds)")
.foregroundColor(superset.numberOfRounds.wrappedValue > 0 ? .black : .red)
.bold()
}
CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue,
showAddExercise: $showAddExercise,
viewModel: viewModel,
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet)
}
HStack {
Stepper("Number of rounds", onIncrement: {
superset.wrappedValue.increaseNumberOfRounds()
viewModel.objectWillChange.send()
}, onDecrement: {
superset.wrappedValue.decreaseNumberOfRounds()
viewModel.objectWillChange.send()
})
Text("\(superset.wrappedValue.numberOfRounds)")
.foregroundColor(superset.numberOfRounds.wrappedValue > 0 ? .black : .red)
.bold()
}
CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue,
showAddExercise: $showAddExercise,
viewModel: viewModel,
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet)
}
Text("this is the bottom 🤷‍♂️")
.id(999)
.listRowSeparator(.hidden)
}
.listRowSeparator(.hidden)
.onChange(of: viewModel.randomValueForUpdatingValue, perform: { newValue in
withAnimation {
proxy.scrollTo(999, anchor: .bottom)
}
})
}
// .overlay(Group {
// if($viewModel.superSets.isEmpty) {
@@ -137,6 +149,7 @@ struct CreateWorkoutMainView: View {
}
}
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
selectedCreateWorkoutSuperSet = nil
})