- No dependencies
- Playback video
- Morphing transition
- Waiting for preview with thumbnail
- Custom preview
- Lazy load asset
- Landscape
dependencies: [
.package(url: "https://github.com/noppefoxwolf/MediaViewer", from: "x.x.x")
],
The PreviewItem
is a protocol that provides the behavior necessary for previewing.
UIImage
and AVPlayer
have built-in implementations.
It can also be customized.
extension String: PreviewItem {
func makeViewController() async -> UIViewController {
UIHostingController(rootView: Text(self))
}
func makeThumbnailViewController() -> UIViewController? {
nil
}
}
PreviewItem
are displayed using PreviewController
.
PreviewController
uses a PreviewControllerDataSource
to retrieve PreviewItem
.
let vc = PreviewController()
vc.delegate = self
vc.dataSource = self
present(vc, animated: true)
func numberOfPreviewItems(in controller: PreviewController) -> Int
func previewController(_ controller: PreviewController, previewItemAt index: Int) -> any PreviewItem
PreviewControllerDelegate
supports animations on transitions.
func previewController(_ controller: PreviewController, transitionViewFor item: any PreviewItem) -> UIView?
If you use a MediaViewer, add your app via Pull Request.