Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noppefoxwolf/mediaviewer
MediaViewer is customizable preview library
https://github.com/noppefoxwolf/mediaviewer
image-viewer ios swift
Last synced: 29 days ago
JSON representation
MediaViewer is customizable preview library
- Host: GitHub
- URL: https://github.com/noppefoxwolf/mediaviewer
- Owner: noppefoxwolf
- License: mit
- Created: 2023-10-30T07:39:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-01T13:01:58.000Z (10 months ago)
- Last Synced: 2024-05-02T05:46:05.895Z (7 months ago)
- Topics: image-viewer, ios, swift
- Language: Swift
- Homepage:
- Size: 3.6 MB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MediaViewer
![](https://github.com/noppefoxwolf/MediaViewer/blob/main/.github/example.gif)
## Features
- [x] No dependencies
- [x] Playback video
- [x] Morphing transition
- [x] Waiting for preview with thumbnail
- [x] Custom preview
- [x] Lazy load asset
- [x] Landscape## Installation
```swift
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.```swift
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`.```swift
let vc = PreviewController()
vc.delegate = self
vc.dataSource = self
present(vc, animated: true)
```### PreviewControllerDataSource
```swift
func numberOfPreviewItems(in controller: PreviewController) -> Int
func previewController(_ controller: PreviewController, previewItemAt index: Int) -> any PreviewItem
```### PreviewControllerDelegate
`PreviewControllerDelegate` supports animations on transitions.
```swift
func previewController(_ controller: PreviewController, transitionViewFor item: any PreviewItem) -> UIView?
```## Apps Using
If you use a MediaViewer, add your app via Pull Request.