Preview(_:as:widget:timelineProvider:)
Preview a widget with a static configuration, using the specified timeline provider.
Declaration
@freestanding(declaration) macro Preview<Widget, Provider>(_ name: String? = nil, as family: WidgetFamily, widget: @escaping () -> Widget, timelineProvider: @escaping () -> Provider) where Widget : Widget, Provider : TimelineProviderParameters
- name:
An optional display name for the preview that appears in the Xcode preview canvas.
- family:
The widget family to display.
- widget:
A closure producing the widget to be previewed.
- timelineProvider:
A closure producing the timeline provider that generates the preview’s timeline.
Mentioned in
Overview
Provide the preview with sample data and use it to step through the timeline while ignoring the dates of the entries, and test out the transitions between them.