add ValueKeyboard as input for exercise values
This commit is contained in:
@@ -29,18 +29,7 @@ struct WorkoutDetail: View {
|
||||
header: Text("Exercises"),
|
||||
footer: Text("Drag and drop to re-arrange or swipe to delete exercises.")) {
|
||||
ForEach(workout.getWorkoutItems()) { workoutItem in
|
||||
switch workoutItem.workoutItemType {
|
||||
case .exerciseWithReps:
|
||||
ExerciseListItem(workout, workoutItem)
|
||||
case .exerciseWithDuration:
|
||||
ExerciseListItem(workout, workoutItem)
|
||||
case .set:
|
||||
SetListItem(workout, workoutItem)
|
||||
case .workout:
|
||||
Text(workoutItem.name)
|
||||
case .rest:
|
||||
Text(workoutItem.name)
|
||||
}
|
||||
WorkoutListItem(workout, workoutItem)
|
||||
}
|
||||
.onDelete(perform: deleteWorkoutItem)
|
||||
.onMove(perform: move)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user