WIP
This commit is contained in:
@@ -83,6 +83,7 @@ class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
||||
class WorkoutViewModel: ObservableObject {
|
||||
@Published var superSets = [CreateWorkoutSuperSet]()
|
||||
@Published var title = String()
|
||||
@Published var description = String()
|
||||
|
||||
func addNewSuperset() {
|
||||
superSets.append(CreateWorkoutSuperSet())
|
||||
@@ -101,12 +102,17 @@ class WorkoutViewModel: ObservableObject {
|
||||
superSets.forEach({ superset in
|
||||
for _ in 0 ..< superset.numberOfRounds {
|
||||
for exercise in superset.exercises {
|
||||
let item = ["id": exercise.exercise.id, "reps": exercise.reps, "weight": exercise.weight, "duration": exercise.duration] as [String : Any]
|
||||
let item = ["id": exercise.exercise.id,
|
||||
"reps": exercise.reps,
|
||||
"weight": exercise.weight,
|
||||
"duration": exercise.duration] as [String : Any]
|
||||
exercises.append(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
let uploadBody = ["name": title, "description": "description", "exercise_data": exercises] as [String : Any]
|
||||
let uploadBody = ["name": title,
|
||||
"description": description,
|
||||
"exercise_data": exercises] as [String : Any]
|
||||
CreateWorkoutFetchable(postData: uploadBody).fetch(completion: { result in
|
||||
DispatchQueue.main.async {
|
||||
switch result {
|
||||
|
||||
@@ -16,7 +16,14 @@ struct CreateWorkoutMainView: View {
|
||||
VStack {
|
||||
TextField("Title", text: $viewModel.title)
|
||||
.padding()
|
||||
|
||||
|
||||
TextField("Description", text: $viewModel.description)
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.horizontal], 4)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2)))
|
||||
.cornerRadius(8)
|
||||
|
||||
List() {
|
||||
ForEach($viewModel.superSets, id: \.id) { superset in
|
||||
Section {
|
||||
|
||||
Reference in New Issue
Block a user