50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
//
|
|
// WorkoutListItem.swift
|
|
// WorkoutsPlus
|
|
//
|
|
// Created by Felix Förtsch on 02.09.24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct WorkoutListItem: View {
|
|
var workout: Workout
|
|
@State var workoutItem: WorkoutItem
|
|
|
|
init(_ workout: Workout, _ workoutItem: WorkoutItem ) {
|
|
self.workout = workout
|
|
self.workoutItem = workoutItem
|
|
}
|
|
|
|
var body: some View {
|
|
Button(action: {
|
|
// workout.addExercise(from: exercise)
|
|
}) {
|
|
switch workoutItem.workoutItemType {
|
|
case .set:
|
|
SetListItem(workout: workout, set: $workoutItem)
|
|
case .exerciseWithReps:
|
|
Text(workoutItem.name)
|
|
case .exerciseWithDuration:
|
|
Text(workoutItem.name)
|
|
case .rest:
|
|
Text(workoutItem.name)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
List {
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(set: [
|
|
WorkoutItem(reps: 10, "Squat"),
|
|
WorkoutItem(reps: 10, "Squat"),
|
|
WorkoutItem(reps: 10, "Squat")]))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(exercise: Exercise("Push-ups", .reps)))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(exercise: Exercise("Push-ups", .reps)))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(exercise: Exercise("Sprint Interval", .duration)))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(exercise: Exercise("Run", .distance)))
|
|
}
|
|
}
|