WIP
This commit is contained in:
@@ -14,39 +14,41 @@ struct CreateExerciseActionsView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if workoutExercise.exercise.isReps {
|
||||
HStack {
|
||||
HStack {
|
||||
VStack {
|
||||
VStack {
|
||||
HStack {
|
||||
Text("Reps: ")
|
||||
Text("\(workoutExercise.reps)")
|
||||
}
|
||||
Stepper("", onIncrement: {
|
||||
workoutExercise.increaseReps()
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseReps()
|
||||
})
|
||||
.labelsHidden()
|
||||
Text("Reps: ")
|
||||
Text("\(workoutExercise.reps)")
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
Divider()
|
||||
VStack{
|
||||
HStack {
|
||||
Text("Weight: ")
|
||||
Text("\(workoutExercise.weight)")
|
||||
}
|
||||
Stepper("", onIncrement: {
|
||||
workoutExercise.increaseWeight()
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseWeight()
|
||||
})
|
||||
.labelsHidden()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
Stepper("", onIncrement: {
|
||||
workoutExercise.increaseReps()
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseReps()
|
||||
})
|
||||
.labelsHidden()
|
||||
}
|
||||
} else if workoutExercise.exercise.isDuration {
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Divider()
|
||||
|
||||
VStack{
|
||||
HStack {
|
||||
VStack {
|
||||
Text("Weight: ")
|
||||
Text("\(workoutExercise.weight)")
|
||||
}
|
||||
Stepper("", onIncrement: {
|
||||
workoutExercise.increaseWeight()
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseWeight()
|
||||
})
|
||||
.labelsHidden()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Divider()
|
||||
|
||||
VStack{
|
||||
VStack {
|
||||
Text("Duration: ")
|
||||
Text("\(workoutExercise.duration)")
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ class CreateWorkoutExercise: ObservableObject, Identifiable {
|
||||
|
||||
func increaseDuration() {
|
||||
self.duration += 15
|
||||
self.reps = 0
|
||||
}
|
||||
|
||||
func decreaseDuration() {
|
||||
@@ -58,7 +59,7 @@ class CreateWorkoutExercise: ObservableObject, Identifiable {
|
||||
class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
||||
let id = UUID()
|
||||
@Published var exercises = [CreateWorkoutExercise]()
|
||||
@Published var numberOfRounds = 1
|
||||
@Published var numberOfRounds = 0
|
||||
|
||||
func increaseNumberOfRounds() {
|
||||
self.numberOfRounds += 1
|
||||
@@ -66,8 +67,8 @@ class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
||||
|
||||
func decreaseNumberOfRounds() {
|
||||
self.numberOfRounds -= 1
|
||||
if self.numberOfRounds < 1 {
|
||||
self.numberOfRounds = 1
|
||||
if self.numberOfRounds < 0 {
|
||||
self.numberOfRounds = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +98,30 @@ class WorkoutViewModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func showRoundsError() {
|
||||
|
||||
}
|
||||
|
||||
func showNoDurationOrReps() {
|
||||
|
||||
}
|
||||
|
||||
func uploadWorkout() {
|
||||
var exercises = [[String: Any]]()
|
||||
superSets.forEach({ superset in
|
||||
if superset.numberOfRounds == 0 {
|
||||
showRoundsError()
|
||||
return
|
||||
}
|
||||
|
||||
for _ in 0 ..< superset.numberOfRounds {
|
||||
for exercise in superset.exercises {
|
||||
|
||||
if exercise.reps == 0 && exercise.duration == 0 {
|
||||
showNoDurationOrReps()
|
||||
return
|
||||
}
|
||||
|
||||
let item = ["id": exercise.exercise.id,
|
||||
"reps": exercise.reps,
|
||||
"weight": exercise.weight,
|
||||
|
||||
@@ -57,6 +57,7 @@ struct CreateWorkoutMainView: View {
|
||||
viewModel.objectWillChange.send()
|
||||
})
|
||||
Text("\(superset.wrappedValue.numberOfRounds)")
|
||||
.foregroundColor(superset.numberOfRounds.wrappedValue > 0 ? .black : .red)
|
||||
}
|
||||
|
||||
CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue,
|
||||
|
||||
Reference in New Issue
Block a user