-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/readme #86
Merged
Merged
Feature/readme #86
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github "hyperoslo/Hue" "9588169ba4201e8a1038a3d2c1750843bf90d7e0" | ||
github "hyperoslo/Hue" "f82ffc7dd55d093d3acc6ce5b3d36ca259091fdd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,160 @@ | ||
# Lightbox | ||
|
||
[![CI Status](http://img.shields.io/travis/hyperoslo/Lightbox.svg?style=flat)](https://travis-ci.org/hyperoslo/Lightbox) | ||
[![Version](https://img.shields.io/cocoapods/v/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) | ||
[![CI Status](http://img.shields.io/travis/hyperoslo/Lightbox.svg?style=flat)](https://travis-ci.org/hyperoslo/Lightbox) | ||
[![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/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) | ||
[![Platform](https://img.shields.io/cocoapods/p/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) | ||
![Swift](https://img.shields.io/badge/%20in-swift%203.0-orange.svg) | ||
|
||
**Lightbox** is a convenient and easy to use image viewer for your iOS app, | ||
packed with all the features you expect: | ||
|
||
- [x] Paginated image slideshow. | ||
- [x] Video support. | ||
- [x] Double-tap to zoom. | ||
- [x] Image caption. | ||
- [x] Dynamic background. | ||
- [x] Interactive transition animations. | ||
- [x] Powerful configuration. | ||
- [x] Demo project. | ||
|
||
## Table of Contents | ||
|
||
* [Usage](#usage) | ||
* [Controller](#controller) | ||
* [Delegates](#delegates) | ||
* [Image loading](#image-loading) | ||
* [Video](#video) | ||
* [Configuration](#configuration) | ||
* [Installation](#installation) | ||
* [Author](#author) | ||
* [Contributing](#contributing) | ||
* [License](#license) | ||
|
||
## Usage | ||
|
||
### Controller | ||
|
||
To start your slideshow just instantiate `LightboxController`, set needed | ||
delegates and present it: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😱 |
||
|
||
```swift | ||
|
||
// Create an array of images. | ||
let images = [ | ||
LightboxImage(imageURL: URL(string: "https://cdn.arstechnica.net/2011/10/05/iphone4s_sample_apple-4e8c706-intro.jpg")!), | ||
LightboxImage( | ||
image: UIImage(named: "photo1")!, | ||
text: "This is an example of a remote image loaded from URL" | ||
), | ||
LightboxImage( | ||
image: UIImage(named: "photo2")!, | ||
text: "", | ||
videoURL: URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") | ||
), | ||
LightboxImage( | ||
image: UIImage(named: "photo3")!, | ||
text: "This is an example of a local image." | ||
) | ||
] | ||
|
||
// Create an instance of LightboxController. | ||
let controller = LightboxController(images: images) | ||
|
||
// Set delegates. | ||
controller.pageDelegate = self | ||
controller.dismissalDelegate = self | ||
|
||
// Use dynamic background. | ||
controller.dynamicBackground = true | ||
|
||
// Present your controller. | ||
present(controller, animated: true, completion: nil) | ||
``` | ||
|
||
### Delegates | ||
|
||
Use `LightboxControllerPageDelegate` if you want to be notified about page | ||
navigation changes. | ||
|
||
```swift | ||
extension ViewController: LightboxControllerPageDelegate { | ||
|
||
func lightboxController(_ controller: LightboxController, didMoveToPage page: Int) { | ||
print(page) | ||
} | ||
} | ||
``` | ||
|
||
Use `LightboxControllerDismissalDelegate` to be notified when controller is | ||
about to be dismissed. Please note that `LightboxController` dismisses itself | ||
if it was presented initially. | ||
|
||
```swift | ||
<API> | ||
extension ViewController: LightboxControllerDismissalDelegate: class { | ||
|
||
func lightboxControllerWillDismiss(_ controller: LightboxController) { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
### Image loading | ||
|
||
By default images are loaded using `sendAsynchronousRequest` method of | ||
`NSURLConnection`. But it's easy to change this behavior using **Lightbox** | ||
configuration. | ||
|
||
```swift | ||
LightboxConfig.loadImage = { | ||
imageView, URL, completion in | ||
// Custom image loading | ||
} | ||
``` | ||
|
||
### Video | ||
|
||
**Lightbox** has video support out of the box. Configure video by using `videoURL`: | ||
|
||
```swift | ||
LightboxImage( | ||
image: UIImage(named: "photo2")!, | ||
text: "", | ||
videoURL: NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") | ||
) | ||
``` | ||
|
||
Override video handling if needed: | ||
|
||
```swift | ||
LightboxConfig.handleVideo = { from, videoURL in | ||
// Custom video handling | ||
let videoController = AVPlayerViewController() | ||
videoController.player = AVPlayer(url: videoURL) | ||
|
||
from.present(videoController, animated: true) { | ||
videoController.player?.play() | ||
} | ||
} | ||
``` | ||
|
||
### Configuration | ||
|
||
Configure text, colors, fonts of UI elements by overriding the static | ||
variables in the **Lightbox** [configuration](https://github.com/hyperoslo/Lightbox/blob/master/Source/LightboxConfig.swift) struct. As an example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change:
To:
Just remove |
||
|
||
```swift | ||
LightboxConfig.CloseButton.image = UIImage(named: ImageList.Lightbox.closeButton) | ||
LightboxConfig.CloseButton.textAttributes = TextAttributes.Lightbox.closeButton | ||
LightboxConfig.CloseButton.text = "Finish" | ||
|
||
LightboxConfig.DeleteButton.image = UIImage(named: ImageList.Lightbox.deleteButton) | ||
LightboxConfig.DeleteButton.textAttributes = TextAttributes.Lightbox.deleteButton | ||
LightboxConfig.DeleteButton.text = "Delete" | ||
|
||
LightboxConfig.InfoLabel.ellipsisText = "ShowMore" | ||
``` | ||
|
||
## Installation | ||
|
@@ -20,10 +166,27 @@ it, simply add the following line to your Podfile: | |
pod 'Lightbox' | ||
``` | ||
|
||
In order to quickly try the demo project of a **Lightbox** just run | ||
`pod try Lightbox` in your terminal. | ||
|
||
**Lightbox** is also available through [Carthage](https://github.com/Carthage/Carthage). | ||
To install just write into your Cartfile: | ||
|
||
```ruby | ||
github "hyperoslo/Lightbox" | ||
``` | ||
|
||
To install **Lightbox** manually just download and drop `Sources` and | ||
`Images` folders in your project. | ||
|
||
## Author | ||
|
||
Hyper Interaktiv AS, ios@hyper.no | ||
|
||
## Contributing | ||
|
||
We would love you to contribute to **Lightbox**, check the [CONTRIBUTING](https://github.com/hyperoslo/Lightbox/blob/master/CONTRIBUTING.md) file for more info. | ||
|
||
## License | ||
|
||
**Lightbox** is available under the MIT license. See the LICENSE file for more info. | ||
**Lightbox** is available under the MIT license. See the [LICENSE](https://github.com/hyperoslo/Lightbox/blob/master/LICENSE.md) file for more info. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we describe what
Dynamic background
is? Or is that clear enough in itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you write a few words about it so I will add? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't go into detail on anything else so we can just leave it 😁