• Stars
    star
    396
  • Rank 108,801 (Top 3 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

INSPhotoGallery is a modern looking photo gallery written in Swift for iOS.

Introduction

INSPhotoGallery was written by Michał Zaborowski for inspace.io

INSPhotoGallery

INSPhotoGallery is a modern looking photo gallery written in Swift for iOS. INSPhotoGallery can handle downloading of photos but in addition to that it allows you to make custom logic for downloading images, also it allows you to make custom overlay if you won't like current design. In addition it support interactive flick to dismiss, animated zooming presentation and many more. It was inspired by NYTPhotoViewer.

Simple Usage

lazy var photos: [INSPhotoViewable] = {
    return [
        INSPhoto(imageURL: NSURL(string: "http://inspace.io/assets/portfolio/thumb/13-3f15416ddd11d38619289335fafd498d.jpg"), thumbnailImage: UIImage(named: "thumbnailImage")!),
        INSPhoto(imageURL: NSURL(string: "http://inspace.io/assets/portfolio/thumb/13-3f15416ddd11d38619289335fafd498d.jpg"), thumbnailImage: UIImage(named: "thumbnailImage")!),
        INSPhoto(image: UIImage(named: "fullSizeImage")!, thumbnailImage: UIImage(named: "thumbnailImage")!),
    ]
}()
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    let cell = collectionView.cellForItemAtIndexPath(indexPath) as! ExampleCollectionViewCell
    let currentPhoto = photos[indexPath.row]
    let galleryPreview = INSPhotosViewController<INSPhoto>(photos: photos, initialPhoto: currentPhoto, referenceView: cell)

    galleryPreview.referenceViewForPhotoWhenDismissingHandler = { [weak self] photo in
        if let index = self?.photos.indexOf({$0 === photo}) {
            let indexPath = NSIndexPath(forItem: index, inSection: 0)
            return collectionView.cellForItemAtIndexPath(indexPath) as? ExampleCollectionViewCell
        }
        return nil
    }
    presentViewController(galleryPreview, animated: true, completion: nil)
}

Custom Photo Model

You are able to create your custom photo model which can be use instead default INSPhoto. Default implementation don't cache images. If you would like to use some caching mechanism or use some library for downloading images for example HanekeSwift use must implement INSPhotoViewable protocol.

@objc public protocol INSPhotoViewable: class {
    var image: UIImage? { get }
    var thumbnailImage: UIImage? { get }

    func loadImageWithCompletionHandler(completion: (image: UIImage?, error: NSError?) -> ())
    func loadThumbnailImageWithCompletionHandler(completion: (image: UIImage?, error: NSError?) -> ())

    var attributedTitle: NSAttributedString? { get }
}
class CustomPhotoModel: NSObject, INSPhotoViewable {
  var image: UIImage?
  var thumbnailImage: UIImage?

  var imageURL: NSURL?
  var thumbnailImageURL: NSURL?

  func loadImageWithCompletionHandler(completion: (image: UIImage?, error: NSError?) -> ()) {
        if let url = imageURL {
            Shared.imageCache.fetch(URL: url).onSuccess({ image in
                completion(image: image, error: nil)
            }).onFailure({ error in
                completion(image: nil, error: error)
            })
        } else {
            completion(image: nil, error: NSError(domain: "PhotoDomain", code: -1, userInfo: [ NSLocalizedDescriptionKey: "Couldn't load image"]))
        }
    }
}

CocoaPods

Add the following to your Podfile and run $ pod install.

pod 'INSPhotoGallery'

If you don't have CocoaPods installed, you can learn how to do so here.

Contact

inspace.io

Twitter

License

Copyright © 2016 Inspace Labs Sp z o. o. Spółka Komandytowa. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this library except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.```

More Repositories

1

MZFormSheetController

MZFormSheetController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup controller size and feel form sheet.
Objective-C
2,534
star
2

MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
Objective-C
974
star
3

INSPullToRefresh

A simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.
Objective-C
814
star
4

MZDayPicker

An iOS day picker to allow users to select date
Objective-C
620
star
5

WCAlertView

WCAlertView is deliverd from UIAlertView. It's support customization and blocks.
Objective-C
617
star
6

INSElectronicProgramGuideLayout

UICollectionViewLayout for displaying electronic program guide.
Objective-C
487
star
7

MZBookshelfCollectionViewLayout

Bookshelf like iBooks layout for UICollectionView.
Objective-C
122
star
8

INSOperationsKit

Objective-C adaptation of the sample code provided in the Advanced NSOperations session of WWDC 2015
Objective-C
112
star
9

MZAppearance

UIAppearance proxy for custom objects
Objective-C
106
star
10

MZSelectableLabel

A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.
Objective-C
102
star
11

UIAlertController-MZStyle

Category for UIAlertController customization
Objective-C
94
star
12

MZFayeClient

Faye Client for iOS. Supports subscription blocks.
Objective-C
84
star
13

INSPersistentContainer

Open Source, 100% API compatible replacement of NSPersistentContainer for iOS8+
Objective-C
65
star
14

SpotifyImporter

Spotify library importer into Apple Music
Objective-C
55
star
15

WCBeforeAfter

Objective-C BeforeAfter
Objective-C
52
star
16

INSNibLoading

A UIView/NSView category and a subclass for loading custom view from UINib (xib) files
Objective-C
26
star
17

AccessibilityIdentificable

Identifiers for UI testing: a reflection based approach
Swift
22
star
18

source-tree-custom-commands

A collection of SourceTree CustomActions.
Shell
20
star
19

RWMAmazonProductAdvertisingManager

AFNetworking Client for Amazon Product Advertising API
Objective-C
13
star
20

ContextWatcher

Example which shows how to observe changes on single NSManagedObject instance
Swift
13
star
21

RWMVimeoClient

AFNetworking Client for Vimeo Advanced API
Objective-C
12
star
22

CCTouchableSprite

Touchable CCSprite for cocos2d framework with Objective-C Blocks
Objective-C
7
star
23

xcode-themes

My Xcode themes
1
star