Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hyperoslo/Gallery
📹 Your next favorite image and video picker
https://github.com/hyperoslo/Gallery
imagepicker ios swift video
Last synced: 3 months ago
JSON representation
📹 Your next favorite image and video picker
- Host: GitHub
- URL: https://github.com/hyperoslo/Gallery
- Owner: hyperoslo
- License: other
- Created: 2016-08-25T14:39:28.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-14T08:16:15.000Z (over 3 years ago)
- Last Synced: 2024-08-05T22:02:11.767Z (3 months ago)
- Topics: imagepicker, ios, swift, video
- Language: Swift
- Homepage:
- Size: 6.63 MB
- Stars: 1,420
- Watchers: 40
- Forks: 275
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-ios - Gallery - Your next favorite image and video picker. (Media / Image)
- awesome-ios-star - Gallery - Your next favorite image and video picker. (Media / Image)
README
[![Version](https://img.shields.io/cocoapods/v/Gallery.svg?style=flat)](http://cocoadocs.org/docsets/Gallery)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/Gallery.svg?style=flat)](http://cocoadocs.org/docsets/Gallery)
[![Platform](https://img.shields.io/cocoapods/p/Gallery.svg?style=flat)](http://cocoadocs.org/docsets/Gallery)
![Swift](https://img.shields.io/badge/%20in-swift%205.0-orange.svg)## Description
We all love image pickers, don't we? You may already know of [ImagePicker](https://github.com/hyperoslo/ImagePicker), the all in one solution for capturing pictures and selecting images. Well, it has a sibling too, called `Gallery`. Based on the same engine that powers ImagePicker, Gallery has a clearer flow based on albums and focuses on the use case of selecting video. If this suits your need, give it a try 😉
`Gallery` has 3 tabs with easy navigation through swipe gesture
- Images: select albums and images. Handle selection with hightlighted numbers so your users don't forget the order
- Camera: your photographer skill goes here
- Videos: display all videos and select. For now the use case is to select one video at a timeAnd, it has zero dependencies 😎
## Usage
### Presenting
`GalleryController` is the main entry point, just instantiate and give it the delegate
```swift
let gallery = GalleryController()
gallery.delegate = self
present(gallery, animated: true, completion: nil)
```The content controller is not loaded until the users navigate to, which offers a much faster experience.
### Delegate
The `GalleryControllerDelegate` requires you to implement some delegate methods in order to interact with the picker
```swift
func galleryController(_ controller: GalleryController, didSelectImages images: [Image])
func galleryController(_ controller: GalleryController, didSelectVideo video: Video)
func galleryController(_ controller: GalleryController, requestLightbox images: [Image])
func galleryControllerDidCancel(_ controller: GalleryController)
```The lightbox delegate method is your chance to display selected images. If you're looking for a nice solution, here is the [Lightbox](https://github.com/hyperoslo/Lightbox) that we use and love
### Resolving
The delegate methods give you `Image` and `Video`, which are just wrappers around `PHAsset`. To get the actual asset informations, we offer many convenient methods. See [example](https://github.com/hyperoslo/Gallery/blob/master/Example/GalleryDemo/GalleryDemo/Sources/ViewController.swift)
`Image`
- Use instance method `resolve` to get the actual UIImage
- Use static method `Image.resolve` to resolve a list of images`Video`
- Use instance method `fetchDuration`, `fetchPlayerItem`, `fetchAVAsset`, `fetchThumbnail` to get more information about the selected video.
### Permission
`Gallery` handles permissions for you. It checks and askes for photo and camera usage permissions at first launch. As of iOS 10, we need to explicitly declare usage descriptions in plist files
```xml
NSCameraUsageDescription
This app requires access to camera
NSPhotoLibraryUsageDescription
This app requires access to photo library
```### Configuration
There are lots of customization points in `Config` structs. For example
```swift
Config.Permission.image = UIImage(named: ImageList.Gallery.cameraIcon)
Config.Font.Text.bold = UIFont(name: FontList.OpenSans.bold, size: 14)!
Config.Camera.recordLocation = true
Config.tabsToShow = [.imageTab, .cameraTab]
```### Video Editor
`Gallery` cares more about video with its editing functionalities. We have `VideoEditor` and `AdvancedVideoEditor` to trim, resize, scale and define quality of the selected video
```swift
func galleryController(_ controller: GalleryController, didSelectVideo video: Video) {
controller.dismiss(animated: true, completion: nil)let editor = VideoEditor()
editor.edit(video: video) { (editedVideo: Video?, tempPath: URL?) in
DispatchQueue.main.async {
if let tempPath = tempPath {
let controller = AVPlayerViewController()
controller.player = AVPlayer(url: tempPath)self.present(controller, animated: true, completion: nil)
}
}
}
}
```With the `Video` object, you can `fetchPlayerItem`, `fetchAVAsset` and `fetchThumbnail` as well
And, of course, you have the ability to customize it
```swift
Config.VideoEditor.maximumDuration = 30
Config.VideoEditor.savesEditedVideoToLibrary = true
```## Installation
**Gallery** is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'Gallery'
```**Gallery** is also available through [Carthage](https://github.com/Carthage/Carthage).
To install just write into your Cartfile:```ruby
github "hyperoslo/Gallery"
```**Gallery** can also be installed manually. Just download and drop `Sources` folders in your project.
## Author
Hyper Interaktiv AS, [email protected]
## Contributing
We would love you to contribute to **Gallery**, check the [CONTRIBUTING](https://github.com/hyperoslo/Gallery/blob/master/CONTRIBUTING.md) file for more info.
## License
**Gallery** is available under the MIT license. See the [LICENSE](https://github.com/hyperoslo/Gallery/blob/master/LICENSE.md) file for more info.