48 lines
1.2 KiB
Swift
48 lines
1.2 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 .exercise:
|
|
Text(workoutItem.name)
|
|
case .rest:
|
|
Text(workoutItem.name)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
List {
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(set: [
|
|
WorkoutItem(Exercise("Squat")),
|
|
WorkoutItem(Exercise("Squat")),
|
|
WorkoutItem(Exercise("Squat"))]))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(Exercise("Push-ups")))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(Exercise("Push-ups")))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(Exercise("Sprint", .distance)))
|
|
WorkoutListItem(Workout(name: "RR"), WorkoutItem(Exercise("Run", .time)))
|
|
}
|
|
}
|