Contents

workoutPreview(_:isPresented:)

Presents a preview of the workout contents as a modal sheet

Declaration

nonisolated func workoutPreview(_ workout: WorkoutPlan, isPresented: Binding<Bool>) -> some View

Parameters

  • workout:

    The WorkoutContainer the preview displays

  • isPresented:

    A binding to a Boolean value that determines whether to present the preview

Discussion

struct WorkoutPreviewer: View {
    let workout: WorkoutPlan
    @State var presented: Bool = false
    var body: some View {
        Button {
            isPresented = true
        } label: {
            WorkoutContainerView(workout)
        }
        .workoutPreview(workout, isPresented: $presented)
    }
}

See Also

Accessing health data