Skip to content

Commit

Permalink
Merge branch 'master' of github.com:alexhillc/AXPhotoViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhillc committed Jun 28, 2017
2 parents 2eacb15 + 26e443b commit b42ea06
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# AXPhotoViewer
<p align="center">
<img src="http://i.imgur.com/Y3ovA03.gif" alt="Demo GIF #1"/>
<img src="http://i.imgur.com/CCs0TzM.gif" alt="Demo GIF #2"/>
</p>

AXPhotoViewer is an iOS photo viewer that is useful for viewing a very large (or very small!) amount of images and GIFs. This library supports contextual presentation and dismissal, interactive "flick-to-dismiss" behavior, and easily integrates with many third party async image downloading/caching libraries.

### How to use
While AXPhotoViewer has many configurable properties on each of its modules, it is easy to throw down some initialization code and get started:

```swift
let dataSource = PhotosDataSource(photos: self.photos, prefetchBehavior: .regular)
let pagingConfig = PagingConfig(navigationOrientation: .horizontal)
let dataSource = PhotosDataSource(photos: self.photos)
let pagingConfig = PagingConfig()
let transitionInfo = TransitionInfo(startingView: self.startingImageView) { [weak self] (photo, index) -> UIImageView? in
return self?.endingImageView
}
Expand All @@ -22,6 +28,48 @@ Installation can easily be done through Cocoapods:
```ruby
pod install 'AXPhotoViewer', '~> 1.0.0-beta.5'
```
or, if you prefer not to use Cocoapods, add the contents of the 'Source' directory to your project to get started.
If you prefer not to use Cocoapods, add the contents of the 'Source' directory to your project to get started.
NOTE: If you don't use Cocoapods, you must add `MobileCoreServices.framework` and `ImageIO.framework` to your project.

### Configuration
There are many configurable properties that can be set before presenting your `AXPhotosViewController`.

For example, in the `AXPhotoDataSource`, you may set up the data source with an initial page index, as well as being able to control the rate at which the library will download additional photos.

```swift
let photos = [photoFirst, photoSecond]
let initialPhotoIndex = 1
let dataSource = PhotosDataSource(photos: photos, initialPhotoIndex: initialPhotoIndex, prefetchBehavior: .aggressive)
```

In `AXPagingConfig`, you may set up the configuration with a different navigation orientation (horizontal vs vertical scrolling between pages), inter-photo spacing (the spacing, in points, between each photo), and as mentioned earlier, a custom loading view class that will be instantiated rather than the default `AXLoadingView`.

```swift
let pagingConfig = PagingConfig(navigationOrientation: .horizontal, interPhotoSpacing: 20, loadingViewClass: CustomLoadingView.self)
```

Lastly, but surely not least, is the `AXTransitionInfo` configuration. This can be used to customize all things related to the presentation and dismissal of your `AXPhotosViewController`, including the starting reference view, the ending reference view, the duration of the animations, and a flag to disable/enable interactive dismissals.

```swift
let transitionInfo = TransitionInfo(interactiveDismissalEnabled: false, startingView: self.startingImageView) { [weak self] (photo, index) -> UIImageView? in
// this closure can be used to adjust your UI before returning an `endingImageView`.
return self?.endingImageView
}
```

### Customization
As mentioned earlier in the `README.md`, there are many configurable properties on each of the modules of the photo viewer, and you can access those modules through the `AXPhotosViewController`. For instance, you may replace the default loading view, caption view, and/or overlay title view with your own. These views must be self sizing, and conform to the `AXLoadingViewProtocol`, `AXCaptionViewProtocol`, and `AXOverlayTitleView` protocol respectively.

```swift
let pagingConfig = PagingConfig(loadingViewClass: CustomLoadingView.self) // custom loading view class to be instantiated as necessary
```
```swift
...
photosViewController.overlayView.captionView = CustomCaptionView() // custom caption view
photosViewController.overlayView.titleView = CustomTitleView() // custom title view
```

The `AXPhotosViewController` and its modules are very extensible, so subclassing each is an easy feat to accomplish without breaking other areas of the library.

More info to come.
### Contributions
If you see something you would like changed, I'm open to ideas! Open a Github issue if you see something wrong, or fork the repo and open a pull request with your changes. I'd be happy to look them over!

0 comments on commit b42ea06

Please sign in to comment.