Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimpiax/FlexibleCollectionViewController
Generic collection view controller with external data processing
https://github.com/dimpiax/FlexibleCollectionViewController
collectionview flexible indexpath swift-3
Last synced: 3 months ago
JSON representation
Generic collection view controller with external data processing
- Host: GitHub
- URL: https://github.com/dimpiax/FlexibleCollectionViewController
- Owner: dimpiax
- License: mit
- Created: 2016-05-31T09:31:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-19T18:54:08.000Z (almost 8 years ago)
- Last Synced: 2024-08-05T13:56:18.107Z (3 months ago)
- Topics: collectionview, flexible, indexpath, swift-3
- Language: Swift
- Homepage:
- Size: 58.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - FlexibleCollectionViewController - Swift library of generic collection view controller with external data processing of functionality, like determine cell's reuseIdentifier related to indexPath, configuration of requested cell for display and cell selection handler etc (UI / Table View / Collection View)
- awesome-ios-star - FlexibleCollectionViewController - Swift library of generic collection view controller with external data processing of functionality, like determine cell's reuseIdentifier related to indexPath, configuration of requested cell for display and cell selection handler etc (UI / Table View / Collection View)
README
# FlexibleCollectionViewController
[![Language](https://img.shields.io/badge/swift-3.0-fec42e.svg)](https://swift.org/blog/swift-3-0-released/)
[![Version](https://img.shields.io/cocoapods/v/FlexibleCollectionViewController.svg?style=flat)](http://cocoapods.org/pods/FlexibleCollectionViewController)
[![License](https://img.shields.io/cocoapods/l/FlexibleCollectionViewController.svg?style=flat)](http://cocoapods.org/pods/FlexibleCollectionViewController)
[![Platform](https://img.shields.io/cocoapods/p/FlexibleCollectionViewController.svg?style=flat)](http://cocoapods.org/pods/FlexibleCollectionViewController)Swift library of generic collection view controller with external data processing of functionality,
like determine cell's `reuseIdentifier` related to `indexPath`,
configuration of requested cell for display and cell selection handler etc## Example
Initialisation with configuration
```swift
_flexibleCollectionVC = FlexibleCollectionViewController(collectionViewLayout: CustomFlowLayout(), configuration: CollectionConfiguration(userInteractionEnabled: true, showsHorizontalScrollIndicator: false, isScrollEnabled: true, multipleTouchEnabled: false, backgroundColor: .clear))
```Cell and supplementary view registering
```swift
_flexibleCollectionVC.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "UICollectionViewCell")
_flexibleCollectionVC.registerSupplementaryView(UIHeaderImageCollectionView.self, kind: .header, reuseIdentifier: UIHeaderImageCollectionView.reuseIdentifier)
```Requesting indentifier of cell for specific indexPath
```swift
_flexibleCollectionVC.requestCellIdentifier = { value in
return "UICollectionViewCell"
}
```Requesting indentifier of supplementary view for specific indexPath
```swift
_flexibleCollectionVC.requestSupplementaryIdentifier = { value in
return UIHeaderImageCollectionView.reuseIdentifier
}
```Configuration of input cell with related data to indexPath
```swift
_flexibleCollectionVC.configureCell = { (cell: UICollectionViewCell, data: CollectionImageCellData?, indexPath: IndexPath) in
guard let data = data else {
return false
}cell.backgroundColor = data.color
return true
}
```Configuration of supplementary view with related kind and data to indexPath
```swift
_flexibleCollectionVC.configureSupplementary = { (view: UICollectionReusableView, kind: SupplementaryKind, data: CollectionImageCellData?, indexPath: IndexPath) in
if let view = view as? UIHeaderImageCollectionView, let data = data {
view.text = data.categoryreturn true
}return false
}
```Process cell selection to related indexPath
```swift
_flexibleCollectionVC.cellDidSelect = { value in
return (deselect: true, animate: true)
}
```Estimate cell size
```swift
_flexibleCollectionVC.estimateCellSize = { value in
guard let layout = value.1 as? UICollectionViewFlowLayout else {
return nil
}let col: CGFloat = 3
let width = value.0.bounds.width-(layout.sectionInset.left+layout.sectionInset.right)
let side = round(width/col)-layout.minimumInteritemSpacing
return CGSize(width: side, height: side)
}
```Put predefined cells in generated order related to ListGenerator
```swift
_flexibleCollectionVC.setData(getData())
```## Requirements
Swift 3 or above
## Installation
FlexibleCollectionViewController is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "FlexibleCollectionViewController"
```## Author
Pilipenko Dima, [email protected]
## License
FlexibleCollectionViewController is available under the MIT license. See the LICENSE file for more info.