WIP
This commit is contained in:
@@ -83,6 +83,7 @@ class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
|||||||
class WorkoutViewModel: ObservableObject {
|
class WorkoutViewModel: ObservableObject {
|
||||||
@Published var superSets = [CreateWorkoutSuperSet]()
|
@Published var superSets = [CreateWorkoutSuperSet]()
|
||||||
@Published var title = String()
|
@Published var title = String()
|
||||||
|
@Published var description = String()
|
||||||
|
|
||||||
func addNewSuperset() {
|
func addNewSuperset() {
|
||||||
superSets.append(CreateWorkoutSuperSet())
|
superSets.append(CreateWorkoutSuperSet())
|
||||||
@@ -101,12 +102,17 @@ class WorkoutViewModel: ObservableObject {
|
|||||||
superSets.forEach({ superset in
|
superSets.forEach({ superset in
|
||||||
for _ in 0 ..< superset.numberOfRounds {
|
for _ in 0 ..< superset.numberOfRounds {
|
||||||
for exercise in superset.exercises {
|
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)
|
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
|
CreateWorkoutFetchable(postData: uploadBody).fetch(completion: { result in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
switch result {
|
switch result {
|
||||||
|
|||||||
@@ -16,7 +16,14 @@ struct CreateWorkoutMainView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
TextField("Title", text: $viewModel.title)
|
TextField("Title", text: $viewModel.title)
|
||||||
.padding()
|
.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() {
|
List() {
|
||||||
ForEach($viewModel.superSets, id: \.id) { superset in
|
ForEach($viewModel.superSets, id: \.id) { superset in
|
||||||
Section {
|
Section {
|
||||||
|
|||||||
Reference in New Issue
Block a user