Latest 1.0
Homepage https://github.com/riteshhgupta/RGListKit
License MIT
Platforms ios 9.0, requires ARC
Authors

RGListKit is a Protocol & MVVM based framework for populating UITableView & UICollectionView. It takes care of batch-reload as well which is powered by Dwifft.

Features

  • No need to call reloadData()
  • No need to manage indexPaths to performBatchUpdates(_:, completion:)
  • It works with multiple sections as well
  • No need to use different apis to populate UITableView & UICollectionView
  • ListableView, a protocol which unifies UITableView & UICollectionView
  • ListManager takes care of populating a ListableView
  • [sections] is all you need to set which acts like a datasource to populate a ListableView
  • ItemModel, a protocol which unifies UITableViewCell & UICollectionViewCell
  • Every cell is populated/configured via an ItemModel which is based on MVVM pattern
  • Decoupled diffing algorithm, powered by Dwifft
  • Extendible API
  • Written completely in Swift

Installation

Cocoapods

To integrate RGListKit into your Xcode project using CocoaPods, specify it in your Podfile:

  pod 'RGListKit', :git => 'https://github.com/riteshhgupta/RGListKit.git'

Example

UITableView

...
        let tableView = UITableView()
        let cellModels: [ItemModel] = [...]
        let sectionModel = SectionModel(id: "section-one-id", cells: cellModels)

        listManager = ListManager(listView: tableView)
        listManager.sections = [sectionModel]
...

UICollectionView

...
        let collectionView = UICollectionView()
        let cellModels: [ItemModel] = [...]
        let sectionModel = SectionModel(id: "section-one-id", cells: cellModels)

        listManager = ListManager(listView: collectionView)
        listManager.sections = [sectionModel]
...

Internal Architecture

  • As you can see the api for populating UITableView or UICollectionView is identical, one of the benefits of using RGListKit.
  • ItemModel defines a cell or even a header/footer-view for both UITableViewCell & UICollectionViewCell
  • ListManager has a property sections which when set triggers the view update
  • All the updates are by default batch-update but you can turn it off by setting shouldPerformBatchUpdate = false
  • You don’t have to worry about indexPaths anymore, it uses diffing of old & new array of sections which calculates & performs the update for you.
  • It doesn’t intefere at all with custom views, like custom table cell or custom layout for collection view. RGListKit only takes care of your datasource and not the UI appearance. So you are free to use any custom layouts as required along with RGListKit.
  • Since RGListKit consumes both delegate & datasource so you can simply extend ListManager to handle any custom use cases like didSelect when required. All the methods will be available under ListManager e.g.
// UICollectionView

extension ListManager {
    public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    }
}
// UITableView

extension ListManager {
    public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    }
}
  • There are couple of examples in the project itself which you can checkout or create an issue or ping me if anything comes up 👍

Contributing

Contributions are welcome and encouraged! Open an issue or submit a pull request 🚀

Licence

RGListKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "RGListKit",
    "version": "1.0",
    "summary": "RGListKit - the missing gap between UITableView & UICollectionView!",
    "authors": {
        "Ritesh Gupta": "[email protected]"
    },
    "license": "MIT",
    "homepage": "https://github.com/riteshhgupta/RGListKit",
    "source": {
        "git": "https://github.com/riteshhgupta/RGListKit.git",
        "tag": "1.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": [
        "Source/DiffKit/*.{swift}",
        "Source/ListKit/Core/*.{swift}",
        "Source/ListKit/Extension/*.{swift}",
        "Source/ListKit/UIKit/*.{swift}"
    ],
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This