Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 1.77 KB

README.md

File metadata and controls

76 lines (55 loc) · 1.77 KB

MediaViewer

Features

  • No dependencies
  • Playback video
  • Morphing transition
  • Waiting for preview with thumbnail
  • Custom preview
  • Lazy load asset
  • Landscape

Installation

dependencies: [
    .package(url: "https://github.com/noppefoxwolf/MediaViewer", from: "x.x.x")
],

Usage

PreviewItem

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
    }
}

PreviewController

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)

PreviewControllerDataSource

func numberOfPreviewItems(in controller: PreviewController) -> Int
func previewController(_ controller: PreviewController, previewItemAt index: Int) -> any PreviewItem

PreviewControllerDelegate

PreviewControllerDelegate supports animations on transitions.

func previewController(_ controller: PreviewController, transitionViewFor item: any PreviewItem) -> UIView?

Apps Using

If you use a MediaViewer, add your app via Pull Request.