View

public extension View
  • Registers the view as the transition source of the item with the given id. Apply it to the displayed media rather than its cell, so the transition matches the media’s frame.

    Declaration

    Swift

    @MainActor
    func pagedMediaSource<ID>(id: ID) -> some View where ID : Hashable
  • Presents a PagedMediaViewController whenever selection points to one of the items.

    Declaration

    Swift

    @MainActor
    func pagedMediaViewer<Item: Identifiable>(
        selection: Binding<Item.ID?>,
        items: [Item],
        recenter: Binding<Item.ID?>? = nil,
        presentationViewInsets: UIEdgeInsets = .zero,
        configure: ((PagedMediaViewController) -> Void)? = nil,
        onIndexChange: ((Int) -> Void)? = nil,
        transitionImage: ((Item) -> UIImage?)? = nil,
        onWillDismiss: ((Item, PagedMediaItem) -> Void)? = nil,
        onDidDismiss: ((Item) -> Void)? = nil,
        mediaItem: @escaping (Item) -> PagedMediaItem
    ) -> some View

    Parameters

    selection

    Item to present. Set back to nil once the viewer dismisses.

    items

    Items to page through, in the order they are displayed.

    recenter

    Optional scrollPosition(id:) binding, updated while paging so sources in a lazy container stay laid out for the dismissal.

    presentationViewInsets

    Insets on the viewer’s presentation frame. Defaults to .zero.

    configure

    Customization of the viewer, e.g. its header and footer containers.

    onIndexChange

    Called after the transition to a new item is completed.

    transitionImage

    Optional image for the item’s transition. Defaults to a snapshot of the source, which is blank for video layers.

    onWillDismiss

    Called just before the dismissal transition ends. Perfect time to sync the source with the media item.

    onDidDismiss

    Called after the dismissal transition ends.

    mediaItem

    Provides the media item view for the given item.