49 lines
1.0 KiB
Swift
49 lines
1.0 KiB
Swift
//
|
|
// ExerciseListItem.swift
|
|
// WorkoutsPlus
|
|
//
|
|
// Created by Felix Förtsch on 02.09.24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ExerciseListItem: View {
|
|
var workout: Workout
|
|
@State var exercise: WorkoutItem
|
|
|
|
init(_ workout: Workout, _ exercise: WorkoutItem ) {
|
|
self.workout = workout
|
|
self.exercise = exercise
|
|
}
|
|
|
|
var body: some View {
|
|
Button(action: {
|
|
// workout.addExercise(from: exercise)
|
|
}) {
|
|
HStack {
|
|
Text(String(exercise.reps))
|
|
.font(.system(size: 14, weight: .bold))
|
|
.foregroundStyle(.white)
|
|
.frame(width: 20, height: 10)
|
|
.padding(8)
|
|
.background(Color.blue)
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
Text(exercise.name)
|
|
.foregroundStyle(.black)
|
|
Spacer()
|
|
Stepper(
|
|
value: $exercise.reps,
|
|
in: 0...100,
|
|
step: 1
|
|
) {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
List {
|
|
ExerciseListItem(Workout(name: "RR"), WorkoutItem(from: Exercise("Push-ups")))
|
|
}
|
|
}
|