May 23, 2017 at 08:20PM

#GraphQL.js

The #JavaScript reference implementation for #GraphQL, a query language for #APIs created by #Facebook.

See more complete documentation at http://graphql.org/ and http://ift.tt/2elMpzS.

Looking for help? Find resources from the community.

Getting Started

An overview of GraphQL in general is available in the README for the Specification for GraphQL. That overview describes a simple set of GraphQL examples that exist as tests in this repository. A good way to get started with this repository is to walk through that README and the corresponding tests in parallel.

Using GraphQL.js

Install GraphQL.js from npm

With yarn:

yarn add graphql
or alternatively using npm:

npm install –save graphql
GraphQL.js provides two important capabilities: building a type schema, and serving queries against that type schema.

First, build a GraphQL type schema which maps to your code base.

import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString
} from ‘graphql’;

var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: ‘RootQueryType’,
fields: {
hello: {
type: GraphQLString,
resolve() {
return ‘world’;
}
}
}
})
});
This defines a simple schema with one type and one field, that resolves to a fixed value. The resolve function can return a value, a promise, or an array of promises. A more complex example is included in the top level tests directory.

Then, serve the result of a query against that type schema.

var query = ‘{ hello }’;

graphql(schema, query).then(result => {

// Prints
// {
// data: { hello: “world” }
// }
console.log(result);

});
This runs a query fetching the one field defined. The graphql function will first ensure the query is syntactically and semantically valid before executing it, reporting errors otherwise.

var query = ‘{ boyhowdy }’;

graphql(schema, query).then(result => {

// Prints
// {
// errors: [
// { message: ‘Cannot query field boyhowdy on RootQueryType’,
// locations: [ { line: 1, column: 3 } ] }
// ]
// }
console.log(result);

});
Want to ride the bleeding edge?

The npm branch in this repository is automatically maintained to be the last commit to master to pass all tests, in the same form found on npm. It is recommend to use builds deployed npm for many reasons, but if you want to use the latest not-yet-released version of graphql-js, you can do so by depending directly on this branch:

npm install graphql@git://github.com/graphql/graphql-js.git#npm
Contributing

We actively welcome pull requests, learn how to contribute.

Changelog

Changes are tracked as Github releases.

License

GraphQL is BSD-licensed. We also provide an additional patent grant.
via http://ift.tt/2rNulor

May 23, 2017 at 08:20PM

#GraphQL.js

The #JavaScript reference implementation for #GraphQL, a query language for #APIs created by #Facebook.

See more complete documentation at http://graphql.org/ and http://ift.tt/2elMpzS.

Looking for help? Find resources from the community.

Getting Started

An overview of GraphQL in general is available in the README for the Specification for GraphQL. That overview describes a simple set of GraphQL examples that exist as tests in this repository. A good way to get started with this repository is to walk through that README and the corresponding tests in parallel.

Using GraphQL.js

Install GraphQL.js from npm

With yarn:

yarn add graphql
or alternatively using npm:

npm install –save graphql
GraphQL.js provides two important capabilities: building a type schema, and serving queries against that type schema.

First, build a GraphQL type schema which maps to your code base.

import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString
} from ‘graphql’;

var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: ‘RootQueryType’,
fields: {
hello: {
type: GraphQLString,
resolve() {
return ‘world’;
}
}
}
})
});
This defines a simple schema with one type and one field, that resolves to a fixed value. The resolve function can return a value, a promise, or an array of promises. A more complex example is included in the top level tests directory.

Then, serve the result of a query against that type schema.

var query = ‘{ hello }’;

graphql(schema, query).then(result => {

// Prints
// {
// data: { hello: “world” }
// }
console.log(result);

});
This runs a query fetching the one field defined. The graphql function will first ensure the query is syntactically and semantically valid before executing it, reporting errors otherwise.

var query = ‘{ boyhowdy }’;

graphql(schema, query).then(result => {

// Prints
// {
// errors: [
// { message: ‘Cannot query field boyhowdy on RootQueryType’,
// locations: [ { line: 1, column: 3 } ] }
// ]
// }
console.log(result);

});
Want to ride the bleeding edge?

The npm branch in this repository is automatically maintained to be the last commit to master to pass all tests, in the same form found on npm. It is recommend to use builds deployed npm for many reasons, but if you want to use the latest not-yet-released version of graphql-js, you can do so by depending directly on this branch:

npm install graphql@git://github.com/graphql/graphql-js.git#npm
Contributing

We actively welcome pull requests, learn how to contribute.

Changelog

Changes are tracked as Github releases.

License

GraphQL is BSD-licensed. We also provide an additional patent grant.
via http://ift.tt/2qMgAIx

May 17, 2017 at 10:39PM

#Written in #Swift 3

#TLPhotoPicker #enables #application to #pick #images and #videos from #multiple smart #album in #iOS, similar to the current #facebook #app.

Demo 🙉

Facebook Picker TLPhotoPicker

Features

support smart album collection.
camera roll, selfies, panoramas, favorites, videos, custom users album
selected order index.
playback video and live photos.
just one. playback first video or live Photo in bounds of visible cell.
display video duration.
async phasset request and displayed cell.
scrolling performance is better than facebook in displaying video assets collection.
custom cell
Smart album collection LivePhotoCell VideoPhotoCell PhotoCell CustomCell(instagram)

Requirements

Swift 3.0
iOS 9.1 (live photos)
Installation

TLPhotoPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, ‘9.1’
pod “TLPhotoPicker”
Don’t forget the Privacy Description in info.plist.

Usage

use delegate & custom cell
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController()
viewController.delegate = self
var configure = TLPhotosPickerConfigure()
//configure.nibSet = (nibName: “CustomCell_Instagram”, bundle: Bundle.main) // If you want use your custom cell..
self.present(viewController, animated: true, completion: nil)
}
//TLPhotosPickerViewControllerDelegate
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
// use selected order, fullresolution image
self.selectedAssets = withTLPHAssets
}
func dismissPhotoPicker(withPHAssets: [PHAsset]) {
// if you want to used phasset.
}
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
// exceed max selection
}
}

//Custom Cell must subclass TLPhotoCollectionViewCell
class CustomCell_Instagram: TLPhotoCollectionViewCell {

}
use closure
convenience public init(withPHAssets: (([PHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
convenience public init(withTLPHAssets: (([TLPHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
open var didExceedMaximumNumberOfSelection: ((TLPhotosPickerViewController) -> Void)? = nil
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in // TLAssets
self?.selectedAssets = assets
}, didCancel: nil)
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
//exceed max selection
}
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
}
TLPHAsset
public struct TLPHAsset {
public enum AssetType {
case photo,video,livePhoto
}
// phasset
public var phAsset: PHAsset? = nil
// selected order index
public var selectedOrder: Int = 0
// asset type
public var type: AssetType
// get full resolution image
public var fullResolutionImage: UIImage?
// get original asset file name
public var originalFileName: String?
}
Customize

let viewController = TLPhotosPickerViewController()
var configure = TLPhotosPickerConfigure()
viewController.configure = configure

public struct TLPhotosPickerConfigure {
public var defaultCameraRollTitle = “Camera Roll”
public var tapHereToChange = “Tap here to change”
public var usedCameraButton = true
public var usedPrefetch = false
public var allowedLivePhotos = true
public var allowedVideo = true
public var numberOfColumn = 3
public var maxSelectedAssets: Int? = nil //default: inf
public var selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)
public var cameraBgColor = UIColor(red: 221/255, green: 223/255, blue: 226/255, alpha: 1)
public var cameraIcon = TLBundle.podBundleImage(named: “camera”)
public var videoIcon = TLBundle.podBundleImage(named: “video”)
public var placeholderIcon = TLBundle.podBundleImage(named: “insertPhotoMaterial”)
public var nibSet: (nibName: String, bundle:Bundle)? = nil // custom cell
public init() {
}
}
Author

wade.hawk, junhyi.park@gmail.com

License

TLPhotoPicker is available under the MIT license. See the LICENSE file for more info.
via http://ift.tt/2rskzs1

May 17, 2017 at 10:39PM

#Written in #Swift 3

#TLPhotoPicker #enables #application to #pick #images and #videos from #multiple smart #album in #iOS, similar to the current #facebook #app.

Demo 🙉

Facebook Picker TLPhotoPicker

Features

support smart album collection.
camera roll, selfies, panoramas, favorites, videos, custom users album
selected order index.
playback video and live photos.
just one. playback first video or live Photo in bounds of visible cell.
display video duration.
async phasset request and displayed cell.
scrolling performance is better than facebook in displaying video assets collection.
custom cell
Smart album collection LivePhotoCell VideoPhotoCell PhotoCell CustomCell(instagram)

Requirements

Swift 3.0
iOS 9.1 (live photos)
Installation

TLPhotoPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, ‘9.1’
pod “TLPhotoPicker”
Don’t forget the Privacy Description in info.plist.

Usage

use delegate & custom cell
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController()
viewController.delegate = self
var configure = TLPhotosPickerConfigure()
//configure.nibSet = (nibName: “CustomCell_Instagram”, bundle: Bundle.main) // If you want use your custom cell..
self.present(viewController, animated: true, completion: nil)
}
//TLPhotosPickerViewControllerDelegate
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
// use selected order, fullresolution image
self.selectedAssets = withTLPHAssets
}
func dismissPhotoPicker(withPHAssets: [PHAsset]) {
// if you want to used phasset.
}
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
// exceed max selection
}
}

//Custom Cell must subclass TLPhotoCollectionViewCell
class CustomCell_Instagram: TLPhotoCollectionViewCell {

}
use closure
convenience public init(withPHAssets: (([PHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
convenience public init(withTLPHAssets: (([TLPHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
open var didExceedMaximumNumberOfSelection: ((TLPhotosPickerViewController) -> Void)? = nil
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in // TLAssets
self?.selectedAssets = assets
}, didCancel: nil)
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
//exceed max selection
}
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
}
TLPHAsset
public struct TLPHAsset {
public enum AssetType {
case photo,video,livePhoto
}
// phasset
public var phAsset: PHAsset? = nil
// selected order index
public var selectedOrder: Int = 0
// asset type
public var type: AssetType
// get full resolution image
public var fullResolutionImage: UIImage?
// get original asset file name
public var originalFileName: String?
}
Customize

let viewController = TLPhotosPickerViewController()
var configure = TLPhotosPickerConfigure()
viewController.configure = configure

public struct TLPhotosPickerConfigure {
public var defaultCameraRollTitle = “Camera Roll”
public var tapHereToChange = “Tap here to change”
public var usedCameraButton = true
public var usedPrefetch = false
public var allowedLivePhotos = true
public var allowedVideo = true
public var numberOfColumn = 3
public var maxSelectedAssets: Int? = nil //default: inf
public var selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)
public var cameraBgColor = UIColor(red: 221/255, green: 223/255, blue: 226/255, alpha: 1)
public var cameraIcon = TLBundle.podBundleImage(named: “camera”)
public var videoIcon = TLBundle.podBundleImage(named: “video”)
public var placeholderIcon = TLBundle.podBundleImage(named: “insertPhotoMaterial”)
public var nibSet: (nibName: String, bundle:Bundle)? = nil // custom cell
public init() {
}
}
Author

wade.hawk, junhyi.park@gmail.com

License

TLPhotoPicker is available under the MIT license. See the LICENSE file for more info.
via http://ift.tt/2qtWp2b

May 17, 2017 at 10:39PM

#Written in #Swift 3

#TLPhotoPicker #enables #application to #pick #images and #videos from #multiple smart #album in #iOS, similar to the current #facebook #app.

Demo 🙉

Facebook Picker TLPhotoPicker

Features

support smart album collection.
camera roll, selfies, panoramas, favorites, videos, custom users album
selected order index.
playback video and live photos.
just one. playback first video or live Photo in bounds of visible cell.
display video duration.
async phasset request and displayed cell.
scrolling performance is better than facebook in displaying video assets collection.
custom cell
Smart album collection LivePhotoCell VideoPhotoCell PhotoCell CustomCell(instagram)

Requirements

Swift 3.0
iOS 9.1 (live photos)
Installation

TLPhotoPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, ‘9.1’
pod “TLPhotoPicker”
Don’t forget the Privacy Description in info.plist.

Usage

use delegate & custom cell
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController()
viewController.delegate = self
var configure = TLPhotosPickerConfigure()
//configure.nibSet = (nibName: “CustomCell_Instagram”, bundle: Bundle.main) // If you want use your custom cell..
self.present(viewController, animated: true, completion: nil)
}
//TLPhotosPickerViewControllerDelegate
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
// use selected order, fullresolution image
self.selectedAssets = withTLPHAssets
}
func dismissPhotoPicker(withPHAssets: [PHAsset]) {
// if you want to used phasset.
}
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
// exceed max selection
}
}

//Custom Cell must subclass TLPhotoCollectionViewCell
class CustomCell_Instagram: TLPhotoCollectionViewCell {

}
use closure
convenience public init(withPHAssets: (([PHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
convenience public init(withTLPHAssets: (([TLPHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
open var didExceedMaximumNumberOfSelection: ((TLPhotosPickerViewController) -> Void)? = nil
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in // TLAssets
self?.selectedAssets = assets
}, didCancel: nil)
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
//exceed max selection
}
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
}
TLPHAsset
public struct TLPHAsset {
public enum AssetType {
case photo,video,livePhoto
}
// phasset
public var phAsset: PHAsset? = nil
// selected order index
public var selectedOrder: Int = 0
// asset type
public var type: AssetType
// get full resolution image
public var fullResolutionImage: UIImage?
// get original asset file name
public var originalFileName: String?
}
Customize

let viewController = TLPhotosPickerViewController()
var configure = TLPhotosPickerConfigure()
viewController.configure = configure

public struct TLPhotosPickerConfigure {
public var defaultCameraRollTitle = “Camera Roll”
public var tapHereToChange = “Tap here to change”
public var usedCameraButton = true
public var usedPrefetch = false
public var allowedLivePhotos = true
public var allowedVideo = true
public var numberOfColumn = 3
public var maxSelectedAssets: Int? = nil //default: inf
public var selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)
public var cameraBgColor = UIColor(red: 221/255, green: 223/255, blue: 226/255, alpha: 1)
public var cameraIcon = TLBundle.podBundleImage(named: “camera”)
public var videoIcon = TLBundle.podBundleImage(named: “video”)
public var placeholderIcon = TLBundle.podBundleImage(named: “insertPhotoMaterial”)
public var nibSet: (nibName: String, bundle:Bundle)? = nil // custom cell
public init() {
}
}
Author

wade.hawk, junhyi.park@gmail.com

License

TLPhotoPicker is available under the MIT license. See the LICENSE file for more info.
via http://ift.tt/2qu1KGG

May 17, 2017 at 10:39PM

#Written in #Swift 3

#TLPhotoPicker #enables #application to #pick #images and #videos from #multiple smart #album in #iOS, similar to the current #facebook #app.

Demo 🙉

Facebook Picker TLPhotoPicker

Features

support smart album collection.
camera roll, selfies, panoramas, favorites, videos, custom users album
selected order index.
playback video and live photos.
just one. playback first video or live Photo in bounds of visible cell.
display video duration.
async phasset request and displayed cell.
scrolling performance is better than facebook in displaying video assets collection.
custom cell
Smart album collection LivePhotoCell VideoPhotoCell PhotoCell CustomCell(instagram)

Requirements

Swift 3.0
iOS 9.1 (live photos)
Installation

TLPhotoPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, ‘9.1’
pod “TLPhotoPicker”
Don’t forget the Privacy Description in info.plist.

Usage

use delegate & custom cell
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController()
viewController.delegate = self
var configure = TLPhotosPickerConfigure()
//configure.nibSet = (nibName: “CustomCell_Instagram”, bundle: Bundle.main) // If you want use your custom cell..
self.present(viewController, animated: true, completion: nil)
}
//TLPhotosPickerViewControllerDelegate
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
// use selected order, fullresolution image
self.selectedAssets = withTLPHAssets
}
func dismissPhotoPicker(withPHAssets: [PHAsset]) {
// if you want to used phasset.
}
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
// exceed max selection
}
}

//Custom Cell must subclass TLPhotoCollectionViewCell
class CustomCell_Instagram: TLPhotoCollectionViewCell {

}
use closure
convenience public init(withPHAssets: (([PHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
convenience public init(withTLPHAssets: (([TLPHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
open var didExceedMaximumNumberOfSelection: ((TLPhotosPickerViewController) -> Void)? = nil
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in // TLAssets
self?.selectedAssets = assets
}, didCancel: nil)
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
//exceed max selection
}
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
}
TLPHAsset
public struct TLPHAsset {
public enum AssetType {
case photo,video,livePhoto
}
// phasset
public var phAsset: PHAsset? = nil
// selected order index
public var selectedOrder: Int = 0
// asset type
public var type: AssetType
// get full resolution image
public var fullResolutionImage: UIImage?
// get original asset file name
public var originalFileName: String?
}
Customize

let viewController = TLPhotosPickerViewController()
var configure = TLPhotosPickerConfigure()
viewController.configure = configure

public struct TLPhotosPickerConfigure {
public var defaultCameraRollTitle = “Camera Roll”
public var tapHereToChange = “Tap here to change”
public var usedCameraButton = true
public var usedPrefetch = false
public var allowedLivePhotos = true
public var allowedVideo = true
public var numberOfColumn = 3
public var maxSelectedAssets: Int? = nil //default: inf
public var selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)
public var cameraBgColor = UIColor(red: 221/255, green: 223/255, blue: 226/255, alpha: 1)
public var cameraIcon = TLBundle.podBundleImage(named: “camera”)
public var videoIcon = TLBundle.podBundleImage(named: “video”)
public var placeholderIcon = TLBundle.podBundleImage(named: “insertPhotoMaterial”)
public var nibSet: (nibName: String, bundle:Bundle)? = nil // custom cell
public init() {
}
}
Author

wade.hawk, junhyi.park@gmail.com

License

TLPhotoPicker is available under the MIT license. See the LICENSE file for more info.
via http://ift.tt/2qT9dQI

May 17, 2017 at 10:39PM

#Written in #Swift 3

#TLPhotoPicker #enables #application to #pick #images and #videos from #multiple smart #album in #iOS, similar to the current #facebook #app.

Demo 🙉

Facebook Picker TLPhotoPicker

Features

support smart album collection.
camera roll, selfies, panoramas, favorites, videos, custom users album
selected order index.
playback video and live photos.
just one. playback first video or live Photo in bounds of visible cell.
display video duration.
async phasset request and displayed cell.
scrolling performance is better than facebook in displaying video assets collection.
custom cell
Smart album collection LivePhotoCell VideoPhotoCell PhotoCell CustomCell(instagram)

Requirements

Swift 3.0
iOS 9.1 (live photos)
Installation

TLPhotoPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, ‘9.1’
pod “TLPhotoPicker”
Don’t forget the Privacy Description in info.plist.

Usage

use delegate & custom cell
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController()
viewController.delegate = self
var configure = TLPhotosPickerConfigure()
//configure.nibSet = (nibName: “CustomCell_Instagram”, bundle: Bundle.main) // If you want use your custom cell..
self.present(viewController, animated: true, completion: nil)
}
//TLPhotosPickerViewControllerDelegate
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
// use selected order, fullresolution image
self.selectedAssets = withTLPHAssets
}
func dismissPhotoPicker(withPHAssets: [PHAsset]) {
// if you want to used phasset.
}
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
// exceed max selection
}
}

//Custom Cell must subclass TLPhotoCollectionViewCell
class CustomCell_Instagram: TLPhotoCollectionViewCell {

}
use closure
convenience public init(withPHAssets: (([PHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
convenience public init(withTLPHAssets: (([TLPHAsset]) -> Void)? = nil, didCancel: ((Void) -> Void)? = nil)
open var didExceedMaximumNumberOfSelection: ((TLPhotosPickerViewController) -> Void)? = nil
class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in // TLAssets
self?.selectedAssets = assets
}, didCancel: nil)
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
//exceed max selection
}
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
}
TLPHAsset
public struct TLPHAsset {
public enum AssetType {
case photo,video,livePhoto
}
// phasset
public var phAsset: PHAsset? = nil
// selected order index
public var selectedOrder: Int = 0
// asset type
public var type: AssetType
// get full resolution image
public var fullResolutionImage: UIImage?
// get original asset file name
public var originalFileName: String?
}
Customize

let viewController = TLPhotosPickerViewController()
var configure = TLPhotosPickerConfigure()
viewController.configure = configure

public struct TLPhotosPickerConfigure {
public var defaultCameraRollTitle = “Camera Roll”
public var tapHereToChange = “Tap here to change”
public var usedCameraButton = true
public var usedPrefetch = false
public var allowedLivePhotos = true
public var allowedVideo = true
public var numberOfColumn = 3
public var maxSelectedAssets: Int? = nil //default: inf
public var selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)
public var cameraBgColor = UIColor(red: 221/255, green: 223/255, blue: 226/255, alpha: 1)
public var cameraIcon = TLBundle.podBundleImage(named: “camera”)
public var videoIcon = TLBundle.podBundleImage(named: “video”)
public var placeholderIcon = TLBundle.podBundleImage(named: “insertPhotoMaterial”)
public var nibSet: (nibName: String, bundle:Bundle)? = nil // custom cell
public init() {
}
}
Author

wade.hawk, junhyi.park@gmail.com

License

TLPhotoPicker is available under the MIT license. See the LICENSE file for more info.
via http://ift.tt/2qsTl5X