add WorkoutIconSelector, change the way adding ExerciseTemplate works to in-List
This commit is contained in:
@@ -38,7 +38,7 @@ struct WorkoutDetail: View {
|
||||
|
||||
.navigationBarTitle("Edit \(workout.name)")
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
ToolbarItem() {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ struct WorkoutDetail: View {
|
||||
|
||||
struct ExerciseListItem: View {
|
||||
var workout: Workout
|
||||
var exercise: Exercise
|
||||
@State var exercise: Exercise
|
||||
|
||||
init(_ workout: Workout, _ exercise: Exercise ) {
|
||||
self.workout = workout
|
||||
@@ -92,18 +92,30 @@ struct ExerciseListItem: View {
|
||||
|
||||
var body: some View {
|
||||
Button(action: {
|
||||
// workout.addExercise(from: exercise)
|
||||
// workout.addExercise(from: exercise)
|
||||
}) {
|
||||
HStack {
|
||||
|
||||
// TextField("Enter Reps", text: $exercise.reps)
|
||||
// .keyboardType(.numberPad) // Set the keyboard to number pad
|
||||
// .padding()
|
||||
// .frame(width: 100, height: 50)
|
||||
// .background(Color(.systemGray6))
|
||||
// .cornerRadius(8)
|
||||
// .multilineTextAlignment(.center) // Center the text
|
||||
// .overlay(
|
||||
// RoundedRectangle(cornerRadius: 8)
|
||||
// .stroke(Color.gray, lineWidth: 1)
|
||||
// )
|
||||
Text(String(workout.exercises.filter { $0 == exercise }.count))
|
||||
.font(.system(size: 14, weight: .bold))
|
||||
.foregroundColor(.white)
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 20, height: 10)
|
||||
.padding(8)
|
||||
.background(Color.blue)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
Text(exercise.name)
|
||||
.foregroundColor(.black)
|
||||
.foregroundStyle(.black)
|
||||
Spacer()
|
||||
Image(systemName: "info.circle")
|
||||
}
|
||||
@@ -114,6 +126,6 @@ struct ExerciseListItem: View {
|
||||
#Preview {
|
||||
NavigationStack {
|
||||
WorkoutDetail(workout: Workout.sampleData.first!)
|
||||
.modelContainer(SampleData.shared.modelContainer)
|
||||
.modelContainer(SampleData.shared.modelContainer)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user