refactor WorkoutItemLibrarySheet, add Set sample data
This commit is contained in:
@@ -13,7 +13,7 @@ struct WorkoutDetail: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
|
||||
@State var workout: Workout
|
||||
@State private var isPresentingExerciseLibrary = false
|
||||
@State private var isPresentingWorkoutItemLibrarySheet = false
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
@@ -25,7 +25,9 @@ struct WorkoutDetail: View {
|
||||
.foregroundStyle(workout.workoutIconColorName.color)
|
||||
}
|
||||
}
|
||||
Section(header: Text("Exercises")) {
|
||||
Section(
|
||||
header: Text("Exercises"),
|
||||
footer: Text("Drag and drop to re-arrange or swipe to delete exercises.")) {
|
||||
ForEach(workout.workoutItems
|
||||
.sorted(by: { $0.position < $1.position})) { workoutItem in
|
||||
switch workoutItem.workoutItemType {
|
||||
@@ -40,25 +42,23 @@ struct WorkoutDetail: View {
|
||||
.onDelete(perform: deleteExerciseFromWorkout)
|
||||
.onMove(perform: move)
|
||||
.environment(\.editMode, .constant(.active)) // Always active drag mode
|
||||
AddItemButton(label: "Exercise", action: addWorkoutItemToWorkout)
|
||||
AddItemButton(label: "Exercise", action: presentWorkoutItemLibrarySheet)
|
||||
}
|
||||
}
|
||||
.navigationBarTitle("\(workout.name)")
|
||||
.toolbar {
|
||||
ToolbarItem() {
|
||||
EditButton()
|
||||
}
|
||||
// TODO: Add proper Sharing for workouts.
|
||||
ToolbarItem() { ShareLink(item: URL(filePath: "felixfoertsch.de")!) }
|
||||
ToolbarItem() { EditButton() }
|
||||
}
|
||||
.sheet(isPresented: $isPresentingExerciseLibrary) {
|
||||
AddWorkoutItemToWorkout(workout: workout)
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDragIndicator(.visible)
|
||||
.sheet(isPresented: $isPresentingWorkoutItemLibrarySheet) {
|
||||
WorkoutItemLibrarySheet(workout: workout)
|
||||
}
|
||||
}
|
||||
|
||||
private func addWorkoutItemToWorkout() {
|
||||
private func presentWorkoutItemLibrarySheet() {
|
||||
withAnimation {
|
||||
isPresentingExerciseLibrary = true
|
||||
isPresentingWorkoutItemLibrarySheet = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user