RGListKit is a Protocol & MVVM based framework to easily populate a UITableView or UICollectionView via single api.
RGListKit is a Protocol & MVVM based framework for populating UITableView
& UICollectionView
. It takes care of batch-reload as well which is powered by Dwifft.
reloadData()
performBatchUpdates(_:, completion:)
ListableView
, a protocol which unifies UITableView & UICollectionViewListManager
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 & UICollectionViewCellItemModel
which is based on MVVM patternTo integrate RGListKit into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'RGListKit', :git => 'https://github.com/riteshhgupta/RGListKit.git', :branch => 'swift3'
pod 'RGListKit', :git => 'https://github.com/riteshhgupta/RGListKit.git'
pod 'RGListKit/ReactiveSwift', :git => 'https://github.com/riteshhgupta/RGListKit.git', :branch => 'swift4'
...
let tableView = UITableView()
let cellModels: [ItemModel] = [...]
let sectionModel = SectionModel(id: "section-one-id", cells: cellModels)
listManager = ListManager(listView: tableView)
listManager.sections = [sectionModel]
...
...
let collectionView = UICollectionView()
let cellModels: [ItemModel] = [...]
let sectionModel = SectionModel(id: "section-one-id", cells: cellModels)
listManager = ListManager(listView: collectionView)
listManager.sections = [sectionModel]
...
ItemModel
defines a cell or even a header/footer-view for both UITableViewCell & UICollectionViewCellListManager
has a property sections
which when set triggers the view updateshouldPerformBatchUpdate = false
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 {
}
}
List of online sources which have mentioned RGListKit,
Contributions are welcome and encouraged! Open an issue or submit a pull request 🚀
RGListKit is available under the MIT license. See the LICENSE file for more info.