Skip to content

Commit

Permalink
Merge pull request #127 from suzuki-0000/feature/clean
Browse files Browse the repository at this point in the history
Refactoring for swift3.0, clean code for massive view controller .  #125
  • Loading branch information
suzuki-0000 committed Aug 30, 2016
2 parents b4d911b + c113f68 commit 679a568
Show file tree
Hide file tree
Showing 23 changed files with 2,683 additions and 1,520 deletions.
160 changes: 160 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Change Log

## 2.1.x
Released on 2016-8

#### Add
- Add changelog

#### Fixed
- prepare for swift3.0.
- refactoring code for new implement.
- Parent View disappears when dismissed. #120
- Glitch when origin imageview is not correct size #108
- Problems with the "long" photo #116

#### Remove
- Statusbar handling.
- Some public property to internal for improving

## 2.0.x
Released on 2016-8

#### Added
- Migrate UIImage cache category to new SKCache

#### Fixed
- Make cached response data return optional
- Fixed issue when animatedFromView not has a superview but has superlayer
- Fixed when image downloaded then not show activityindicator
- Update for Swift2.3

---

## 1.9.x
Released on 2016-6

#### Added
- Delegate to notify when the user scroll to an index
- Single tap to dismiss

#### Fixed
- Fixed a bug where the activity indicator was only visible
- Fixed unit test and problems running when being bridged

---

## 1.8.x
Released on 2016-4

#### Added
- Using SKPhotoProtocol to enable usage from SKLocalPhoto
- SKLocalPhoto to support local photo from file

#### Fixed
- Bug when animation when tap.
- The indicator may not disappear when loading local image
- Event crash when closing before image has been loaded
- Fix crash on initialisation

---

## 1.7.x
Released on 2016-3

#### Added
- Enable ability to override statusBar style

#### Fixed
- Update for swift2.0
- Bug when zooming small image
- Prevent crash when closing before image has been loaded

---

## 1.6.x
Released on 2016-3

#### Fixed
- Change maxScale to 1.0 it works perfectly.
- Fixed the bug which was after the device rotation

---

## 1.5.x
Released on 2016-3

#### Added
- Delete Button

#### Fixed
- Change maxScale to 1.0 it works perfectly.
- Rew algorithm for maxScale.
- Changed UIActionSheet to UIAlertController with ActionSheet style

---

## 1.4.x
Released on 2016-2

#### Added
- Delegate add for actionbutton.
- DidShowPhotoAtIndex delegate goes to optional.

#### Fixed
- Zooming bug fixed.

---

## 1.3.x
Released on 2016-1

#### Added
- Added action functionality similar to IDMPhotoBrowser.
- Add extra caption for share

#### Fixed
- Bug fixed for mail crash


---

## 1.2.x
Released on 2015-10

#### Added
- SKPhotoProtocol is implemented.

#### Fixed
- Double tap bug fixed

---

## 1.1.x
Released on 2015-10-09.

#### Fixed
- some property make private.
- layout bug fixed when zoom.

## 1.0.0
Released on 2015-10-09.

#### Added
- Tests for upload and download with progress.
- Added by [Mattt Thompson](https://github.com/mattt).
- Test for question marks in url encoded query.
- Added by [Mattt Thompson](https://github.com/mattt).
- The `NSURLSessionConfiguration` headers to `cURL` representation.
- Added by [Matthias Ryne Cheow](https://github.com/rynecheow) in Pull Request
[#140](https://github.com/Alamofire/Alamofire/pull/140).
- Parameter encoding tests for key/value pairs containing spaces.
- Added by [Mattt Thompson](https://github.com/mattt).
- Percent character encoding for the `+` character.
- Added by [Niels van Hoorn](https://github.com/nvh) in Pull Request
[#167](https://github.com/Alamofire/Alamofire/pull/167).
- Escaping for quotes to support JSON in `cURL` commands.
- Added by [John Gibb](https://github.com/johngibb) in Pull Request
[#178](https://github.com/Alamofire/Alamofire/pull/178).
- The `request` method to the `Manager` bringing it more inline with the top-level methods.
- Added by Brian Smith.
85 changes: 44 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ SKPhotoBrowser
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift, based on [IDMPhotoBrowser](https://github.com/ideaismobile/IDMPhotoBrowser), [MWPhotoBrowser](https://github.com/mwaterfall/MWPhotoBrowser).

## features
- Can display one or more images by providing either `UIImage` objects, or string of URL array.
- Display one or more images by providing either `UIImage` objects, or string of URL array.
- Photos can be zoomed and panned, and optional captions can be displayed
- Minimalistic Facebook-like interface, swipe up/down to dismiss
- has simple ability to custom photobrowser. (hide/show statusbar, some toolbar for controls, swipe control)
- Handling and caching photos from web
- Landscape handling.
- Ability to custom control. (hide/ show toolbar for controls, / swipe control)
- Handling and caching photos from web
- Landscape handling
- Delete photo support(by offbye). By set displayDelete=true show a delete icon in statusbar, deleted indexes can be obtain from delegate func didDeleted

![sample](Screenshots/example02.gif)
Expand Down Expand Up @@ -42,43 +42,45 @@ github "suzuki-0000/SKPhotoBrowser"
Add the code directly into your project.

##Usage
See the code snippet below for an example of how to implement, or example project would be easy to understand.
See the code snippet below for an example of how to implement, or see the example project.

from UIImages:
```swift
// add SKPhoto Array from UIImage
// 1. create SKPhoto Array from UIImage
var images = [SKPhoto]()
let photo = SKPhoto.photoWithImage(UIImage())// add some UIImage
images.append(photo)

// create PhotoBrowser Instance, and present.
// 2. create PhotoBrowser Instance, and present from your viewController.
let browser = SKPhotoBrowser(photos: images)
browser.initializePageIndex(0)
browser.delegate = self
presentViewController(browser, animated: true, completion: {})
```

from web URLs:
from URLs:
```swift
// URL pattern snippet
// 1. create URL Array
var images = [SKPhoto]()
let photo = SKPhoto.photoWithImageURL("https://placehold.jp/150x150.png")
photo.shouldCachePhotoURLImage = false // you can use image cache by true(NSCache)
images.append(photo)

// create PhotoBrowser Instance, and present.
// 2. create PhotoBrowser Instance, and present.
let browser = SKPhotoBrowser(photos: images)
browser.initializePageIndex(0)
presentViewController(browser, animated: true, completion: {})
```

from local files:
```swift
// images from local files
// 1. create images from local files
var images = [SKLocalPhoto]()
let photo = SKLocalPhoto.photoWithImageURL("..some_local_path/150x150.png")
images.append(photo)

// create PhotoBrowser Instance, and present.
// 2. create PhotoBrowser Instance, and present.
let browser = SKPhotoBrowser(photos: images)
browser.initializePageIndex(0)
presentViewController(browser, animated: true, completion: {})
```

Expand All @@ -88,6 +90,7 @@ If you want to use zooming effect from an existing view, use another initializer
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let originImage = cell.exampleImageView.image // some image for baseImage

let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.initializePageIndex(indexPath.row)
presentViewController(browser, animated: true, completion: {})
Expand All @@ -97,40 +100,40 @@ func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath i
### Custom

#### Toolbar
You can customize the toolbar(back/forward, counter, some action) button.
- displayCounterLabel (default is true)
- displayBackAndForwardButton (default is true)
- displayAction (default is true)

If you dont want the toolbar at all, you can set displayToolbar = false (default is true)
You can customize Toolbar via SKPhotoBrowserOptions.

```swift
SKPhotoBrowserOptions.displayToolbar = false // all tool bar will be hidden
SKPhotoBrowserOptions.displayCounterLabel = false // counter label will be hidden
SKPhotoBrowserOptions.displayBackAndForwardButton = false // back / forward button will be hidden
SKPhotoBrowserOptions.displayAction = false // action button will be hidden
SKPhotoBrowserOptions.displayDeleteButton = true // delete button will be shown
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.displayToolbar = false // all tool bar will be hidden
browser.displayCounterLabel = false // counter label will be hidden
browser.displayBackAndForwardButton = false // back / forward button will be hidden
browser.displayAction = false // action button will be hidden
browser.displayDeleteButton = true // delete button will be shown
```

#### CustomButton Image
Close button is able to change image and frame.
``` swift
browser.displayCustomCloseButton = true // custom close button will be enable
browser.customCloseButtonImage = UIImage(named: "some.png")
browser.customCloseButtonShowFrame = CGRect()
browser.customCloseButtonHideFrame = CGRect()
#### Custom Cache From Web URL
You can use SKCacheable protocol if others are adaptable. (SKImageCacheable or SKRequestResponseCacheable)

```swift
e.g. SDWebImage

// 1. create custon cache. implement function for protocol
class CustomImageCache: SKImageCacheable { var cache: SDImageCache }

// 2. replace SKCache instance with custom cache
SKCache.sharedCache.imageCache = CustomImageCache()
```
Delete button is able to change image and frame.

#### CustomButton Image
Close, Delete buttons are able to change image and frame.
``` swift
browser.displayCustomDeleteButton = true // custom delete button will be enable
browser.customDeleteButtonImage = UIImage(named: "some.png")
browser.customDeleteButtonShowFrame = CGRect()
browser.customDeleteButtonHideFrame = CGRect()
browser.browser.updateCloseButton(UIImage())
browser.browser.updateUpdateButton(UIImage())
```

#### Delete
You can delete your photo for your own hanlding.
#### Delete Photo
You can delete your photo for your own handling. detect button tap from `removePhoto` delegate function.


#### Photo Captions
Photo captions can be displayed simply bottom of PhotoBrowser. by setting the `caption` property on specific photos:
Expand Down Expand Up @@ -182,9 +185,9 @@ func didDismissAtPageIndex(index: Int) {
- single tap handling, dismiss/noaction
- bounce animation when appearing/dismissing
``` swift
enableZoomBlackArea = true // default true
enableSingleTapDismiss = true // default false
bounceAnimation = true // default false
SKPhotoBrowserOptions.enableZoomBlackArea = true // default true
SKPhotoBrowserOptions.enableSingleTapDismiss = true // default false
SKPhotoBrowserOptions.bounceAnimation = true // default false
```

## Photos from
Expand Down
2 changes: 1 addition & 1 deletion SKPhotoBrowser.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SKPhotoBrowser"
s.version = "2.0.4"
s.version = "2.1.0"
s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0."
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
Loading

0 comments on commit 679a568

Please sign in to comment.