{"id":24801566,"url":"https://github.com/futuredapp/cellkit","last_synced_at":"2025-10-29T04:14:47.658Z","repository":{"id":42443931,"uuid":"90044655","full_name":"futuredapp/CellKit","owner":"futuredapp","description":"Table View and Collection View data source wrapper","archived":false,"fork":false,"pushed_at":"2022-07-22T03:44:59.000Z","size":237,"stargazers_count":11,"open_issues_count":3,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-06-26T08:58:20.355Z","etag":null,"topics":["collectionview","datasource","ios","tableview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/futuredapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2017-05-02T14:47:14.000Z","updated_at":"2025-03-03T11:16:41.000Z","dependencies_parsed_at":"2022-08-25T11:21:05.342Z","dependency_job_id":null,"html_url":"https://github.com/futuredapp/CellKit","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/futuredapp/CellKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FCellKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FCellKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FCellKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FCellKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futuredapp","download_url":"https://codeload.github.com/futuredapp/CellKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FCellKit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263331780,"owners_count":23450157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collectionview","datasource","ios","tableview"],"created_at":"2025-01-30T04:29:17.860Z","updated_at":"2025-10-29T04:14:42.627Z","avatar_url":"https://github.com/futuredapp.png","language":"Swift","readme":"\u003cimg alt=\"CellKit icon\" src=\"Documentation/CellKit.svg\" align=\"right\"\u003e\n\n# CellKit\n\n![Cocoapods](https://img.shields.io/cocoapods/v/CellKit.svg)\n![Cocoapods platforms](https://img.shields.io/cocoapods/p/CellKit.svg)\n![License](https://img.shields.io/cocoapods/l/CellKit.svg)\n\nCellKit is a Swift package that streamlines the workflow with cells in UITableView and UICollectionView. No more registering cell classes or XIBs, no more dequeueing cells and setting its view models. CellKit handles this all.\n\n## Installation\n\n### Swift Package\n\nAdd following line to your swift package dependencies, or in Xcode, go to `File -\u003e Swift Packages -\u003e Add Package Dependency` and type in URL address of this repository.\n\n```swift\n.package(url: \"https://github.com/futuredapp/CellKit\", from: \"0.8.1\")\n```\n\nOptionally you can add `DiffableCellKit`.\n\n### CocoaPods\n\nAdd following line to your `Podfile` and then run `pod install`:\n\n```ruby\npod 'CellKit', '~\u003e 0.8'\n```\nOptionally you can add `DiffableCellKit` subspec:\n\n```ruby\npod 'CellKit', '~\u003e 0.8', subspecs: ['Diffable']\n```\n\n## Usage\nCellKit provides a data source and a section model which you fill with your cells, headers and footer models. All you're left to do is to define your cell view and your cell model with protocol conformance to CellConvertible and CellConfigurable and CellKit will handle the rest.\n\n### 1. Set a DataSource\n\nCellKit provides a `CellModelDataSource` and `GenericCellModelSection`, which define your `UITableView`/`UICollectionView` cell structure. You can always subclass `CellModelDataSource` and override its methods to suit your needs.  \nHere's an example of typical CellKit data source usage:\n\n```swift\nlet dataSource = CellModelDataSource([\n    GenericCellModelSection(arrayLiteral:\n        PrototypeCellViewModel(name: \"Prototype\")\n    ),\n    GenericCellModelSection(arrayLiteral:\n        CodeCellViewModel(name: \"Code\")\n    ),\n    GenericCellModelSection(arrayLiteral:\n        XIBCellViewModel(name: \"XIB\")\n    )\n])\n\ntableView.dataSource = dataSource\ncollectionView.dataSource = dataSource\n```\n\n### 2. Create your cell and CellModel\n\nCellKit support wide variety of cell declarations including `.xib` files , `UITableView` interface builder prototype cells and Cells written entirely in code.  \n*Please note that your `.xib` file, Cell subclass and Cell identifier have to to have the same name.* It is possible to not use the same identifier, but it is not recommended.  \nPro tip: You can use our [custom teplates](https://github.com/futuredapp/MVVM-C-Templates) to generate Cell with CellKit protocols in just a few clicks.\n\n### 3. Conform to CellKit protocols\n\nIn order for your cells and cell view models to work with CellKit, they have to conform to these protocols:\n\n#### CellConfigurable\n\nThis is a protocol for your *Cell*. This protocol provides a `configure(model:)` method which gets call when a tableview request a reusable cell and is used to distribute your model to your cells. \n\n```swift\nclass XIBCell: UITableViewCell {\n    @IBOutlet private weak var label: UILabel!\n}\n\nextension XIBCell: CellConfigurable {\n    func configure(with model: XIBCellViewModel) {\n        label.text = model.name\n    }\n}\n```\n\n#### CellModel\n\nProtocol for your cell model. Use this procotol to specify your cell configuration such as height, xib location, whether the cell is highlightable, etc.\n\n```swift\nstruct PrototypeCellViewModel {\n    let name: String\n}\n\nextension PrototypeCellViewModel: CellModel {\n    var usesNib: Bool { false }\n    var registersLazily: Bool { false }\n}\n```\n\nHere is a handy table of configurable properties and their default values in which you can provide your own values.\n| properties        | datatype | default                                                  | description                                                                 |\n|-------------------|----------|----------------------------------------------------------|-----------------------------------------------------------------------------|\n| registersLazily   | Bool     | true                                                     | Indicates whether DataSource should register a view to its presenting view. |\n| usesNib           | Bool     | true                                                     | Indicates whether cell is defined in .xib file                              |\n| nib               | UINib?   | xib with `cellClass` name. Or nil if `usesNib` is false. | An `UINib` reference of your .xib file containing you view                    |\n| cellClass         | AnyClass |                                                          | A class reference to views class.                                           |\n| reuseIdentifier   | String   |                                                          | a unique re-use identifier                                                  |\n| cellHeight        | Double   | 44.0                                                     | hight for cell                                                              |\n| highlighting      | Bool     | true                                                     | Indicates whether cell can be highlighted                                   |\n| separatorIsHidden | Bool     | false                                                    | Indicates whether should hide separator                                     |\n\n#### CellConvertible \n\nThis protocol extends CellModel with associated type and thus can provide a default `cellClass` and `reuseIdentifier` value based on type's name.    \nIt's espetially handy when you declare your cell in XIB, because all you need to do is to define its associated type and CellKit will provide the rest.    \nHere's an example:\n\n```swift\nclass XIBCell: UITableViewCell, CellConfigurable {\n    @IBOutlet private weak var label: UILabel!\n    \n    func configure(with model: XIBCellViewModel) {\n        label.text = \"\\(model.name)\"\n    }\n}\n\nstruct XIBCellViewModel: CellConvertible, CellModel {\n    let name: String\n    \n    // MARK: CellConvertible\n    typealias Cell = XIBCell\n}\n```\n\n## DiffableCellKit\n\nDiffableCellKit is an extension build on top of `CellKit` and `DifferenceKit` which captures your data source changes and automatically updates/removes/inserts your `UITableView`/`UICollectionView` cells.  \n\n### DifferentiableCellModelDataSource\n\n`DifferentiableCellModelDataSource` is built on top of the same foundation as `CellModelDataSource` with the difference (no pun intended), that it accepts `DifferentiableCellModelSection` and when you change the content of its `sections` property, the data source will issue an animated update to its `UITableView`/`UICollectionView`. \n`DifferentiableCellModelDataSource` is still an open class, so you can subclass it and override its methods and propertes to suit your needs.\n\n```swift\nlet datasource = DifferentiableCellModelDataSource(self.tableView, sections: [\n    DifferentiableCellModelSection(arrayLiteral:\n        PrototypeCellViewModel(domainIdentifier: 1, name: \"Prototype\")\n    ),\n    DifferentiableCellModelSection(arrayLiteral:\n        CodeCellViewModel(domainIdentifier: 2, name: \"Code\")\n    ),\n    DifferentiableCellModelSection(arrayLiteral:\n        XIBCellViewModel(domainIdentifier: 3, name: \"XIB\")\n    )\n])\n```\n\n### DifferentiableCellModel\n\nJust like `CellModel`, `DifferentiableCellModel` is a protocol for your cell model. `DifferentiableCellModel` provides one new `domainIdentifier` property  and a `hasEqualContent(with:)` method which provides enough information for `DiffableCellKit` to recognize changes and issue `UITableView`/`UICollectionView` update.  \nWhen your cell model conforms to `Equatable` protocol, `DiffableCellKit` provides an `Equatable` extension, so you don't have to implement `hasEqualContent(with:)` method.\nDifferentiableCellModel can still be combined with `CellConvertible` protocol.\n\n```swift\nclass XIBCell: UITableViewCell, CellConfigurable {\n    @IBOutlet private weak var label: UILabel!\n    \n    func configure(with model: XIBCellViewModel) {\n        label.text = \"\\(model.name)\"\n    }\n}\n\nstruct XIBCellViewModel: CellConvertible, DifferentiableCellModel, Equatable {\n    let name: String\n    \n    // MARK: DifferentiableCellModel\n    var domainIdentifier: Int\n    \n    // MARK: CellConvertible\n    typealias Cell = XIBCell\n}\n```\n\n## CellKit Examples\n\n### XIB cell\n\n```swift\nclass XIBCell: UITableViewCell, CellConfigurable {\n    @IBOutlet private weak var label: UILabel!\n    func configure(with model: XIBCellViewModel) {\n        label.text = \"\\(model.name)\"\n    }\n}\n\nstruct XIBCellViewModel: CellConvertible, CellModel {\n    let name: String\n    \n    // MARK: CellConvertible\n    typealias Cell = XIBCell\n}\n```\n\n### Storyboard prototype cell\n\n```swift\nclass PrototypeCell: UITableViewCell, CellConfigurable {\n    @IBOutlet private weak var label: UILabel!\n    \n    func configure(with model: PrototypeCellViewModel) {\n        label.text = \"\\(model.name)\"\n    }\n}\n\nstruct PrototypeCellViewModel: CellConvertible, CellModel {\n    let name: String\n    \n    // MARK: CellConvertible\n    typealias Cell = PrototypeCell\n    let usesNib: Bool = false\n    let registersLazily: Bool = false\n}\n```\n### Cell defined in code\n\n```swift\nclass CodeCell: UITableViewCell, CellConfigurable {\n    let label: UILabel = UILabel()\n    \n    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {\n        super.init(style: style, reuseIdentifier: reuseIdentifier)\n        addSubview(label)\n        label.translatesAutoresizingMaskIntoConstraints = false\n        NSLayoutConstraint.activate([\n            topAnchor.constraint(equalTo: label.topAnchor, constant: -16),\n            bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: 16),\n            leftAnchor.constraint(equalTo: label.leftAnchor, constant: -16),\n            heightAnchor.constraint(equalToConstant: 64)\n        ])\n    }\n    \n    func configure(with model: CodeCellViewModel) {\n        label.text = \"\\(model.name)\"\n    }\n}\n\nstruct CodeCellViewModel: CellConvertible, CellModel {\n    let name: String\n    \n    // MARK: CellConvertible\n    typealias Cell = CodeCell\n    let usesNib: Bool = false\n    let cellHeight: Double = 64\n}\n```\n\n## Contributors\n\nCurrent maintainer and main contributor is [Matěj Kašpar Jirásek](https://github.com/mkj-is), \u003cmatej.jirasek@futured.app\u003e.\n\nWe want to thank other contributors, namely:\n\n- [Matěj Kašpar Jirásek](https://github.com/mkj-is)\n- [Petr Zvoníček](https://github.com/zvonicek)\n- [Mikoláš Stuchlík](https://github.com/mikolasstuchlik)\n- [Michal Šrůtek](https://github.com/michalsrutek)\n- [Tomáš Babulák](https://github.com/tomasbabulak)\n- [Adam Salih](https://github.com/max9631)\n- [Michal Martinů](https://github.com/MichalMartinu)\n\n## License\n\nCellKit is available under the MIT license. See the [LICENSE](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturedapp%2Fcellkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturedapp%2Fcellkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturedapp%2Fcellkit/lists"}