44 lines
1010 B
Swift
44 lines
1010 B
Swift
//
|
|
// CreateWorkoutView.swift
|
|
// Werkout_ios
|
|
//
|
|
// Created by Trey Tartt on 6/15/23.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct CreateWorkoutView: View {
|
|
@State var exercises = [ExerciseExercise]()
|
|
@State private var showAddExercise = false
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Button("add", action: {
|
|
showAddExercise.toggle()
|
|
})
|
|
|
|
List() {
|
|
ForEach(exercises.indices, id: \.self) { i in
|
|
let obj = exercises[i]
|
|
Text(obj.name)
|
|
}
|
|
}
|
|
}
|
|
.sheet(isPresented: $showAddExercise) {
|
|
AddExerciseView(selectedWorkout: { exercise in
|
|
addNewExercise(exercise: exercise)
|
|
})
|
|
}
|
|
}
|
|
|
|
func addNewExercise(exercise: ExerciseExercise) {
|
|
exercises.append(exercise)
|
|
}
|
|
}
|
|
|
|
struct CreateWorkoutView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
CreateWorkoutView()
|
|
}
|
|
}
|