Preview(_:as:using:widget:contentStates:)
Preview a widget with an activity configuration, using the specified attributes and content states.
Declaration
@freestanding(declaration) macro Preview<Widget, Attributes>(_ name: String? = nil, as viewKind: ActivityPreviewViewKind, using attributes: Attributes, widget: @escaping () -> Widget, @PreviewActivityBuilder<Attributes> contentStates: @escaping @MainActor () async -> [Attributes.ContentState]) where Widget : Widget, Attributes : ActivityAttributesParameters
- name:
An optional display name for the preview that appears in the preview canvas.
- viewKind:
The kind of widget view to display.
- attributes:
The attributes with which to configure the widget.
- widget:
A closure producing the widget to be previewed.
- contentStates:
A closure building the content states to be previewed.
Mentioned in
Overview
Provide the preview with sample data and use it to step through the specified content states and test out the transitions between them.