{"id":30719826,"url":"https://github.com/dankinsoid/cellsreloadable","last_synced_at":"2025-09-03T10:42:19.712Z","repository":{"id":197614383,"uuid":"698973607","full_name":"dankinsoid/CellsReloadable","owner":"dankinsoid","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-01T07:30:08.000Z","size":198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T19:02:49.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dankinsoid.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-01T14:52:03.000Z","updated_at":"2024-09-12T20:06:41.000Z","dependencies_parsed_at":"2023-10-01T19:05:42.677Z","dependency_job_id":"a290e952-6287-40b4-9587-2e2f7ae16dc7","html_url":"https://github.com/dankinsoid/CellsReloadable","commit_stats":null,"previous_names":["dankinsoid/cellsreloadable"],"tags_count":14,"template":false,"template_full_name":"dankinsoid/iOSLibraryTemplate","purl":"pkg:github/dankinsoid/CellsReloadable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FCellsReloadable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FCellsReloadable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FCellsReloadable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FCellsReloadable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dankinsoid","download_url":"https://codeload.github.com/dankinsoid/CellsReloadable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FCellsReloadable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273431361,"owners_count":25104491,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-03T10:42:18.759Z","updated_at":"2025-09-03T10:42:19.685Z","avatar_url":"https://github.com/dankinsoid.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CellsReloadable\n\nCellsReloadable provides a streamlined approach to managing table, collection, and stack views in iOS. By eliminating the need for subclassing `UITableViewCell` or `UICollectionViewCell`, the library facilitates a more straightforward process for reloading views. With CellsReloadable, developers can directly use `UIView` or SwiftUI `View` instances, leading to a more modular and efficient UI implementation.\n\n## Some code examples\n- Reload with data and `UIView` cells:\n```swift\nreloader.reload(with: myData) { _ in\n    MyCustomUIView()\n} render: { view, data in\n    view.render(with: data)\n}\n```\n- Reload with props and `RenderableView`:\n```swift\nreloader.reload(with: myData) {\n    MyCustomRenderableView()\n}\n```\n- Reload with cells builder:\n```swift\nreloader.reload {\n  MyCustomUIView.Cell(with: props)\n  if someCondition {\n    MyCustomSwiftUIView()\n  }\n  MyCustomStaticUIView.Cell()\n}\n```\n```swift\nreloader.reload(with: myData) { data in\n    MyCustomSwiftUIView(data)\n}\n```\n```swift\nreloader.reload(with: myData) { item in\n  switch item.type {\n  case let .swiftUICell(props):\n    SomeSwiftUIView(props)\n      .asViewCell(id: props.id)\n\n  case let .uiKitUICell(props):\n    MyCustomUIView.Cell(with: props)\n      .height(72)\n  }\n}\n```\n```swift\nreloader.reload {\n  for i in 0..\u003c10 {\n    UILabel.Cell(id: i) {\n      $0.text = \"Item \\(i)\"\n    }\n    .height(50)\n  }\n}\n```\n- Reload with sections builder:\n```swift\nreloader.reload {\n  CellsSection(data: myData) {\n    MyCustomRenderableView()\n  }\n  .cellsWith(\\.height, 72)\n\n  CellsSection(data: myData) {\n    SomeSwiftUIView($0)\n  }\n  .header {\n    Text(\"Header\").padding()\n  }\n}\n```\n\n## Description\n\nThis library provides reloadable functionality for `UITableView`, `UIStackView`, and `UICollectionView`.\n\nIt introduces several types:\n\n- **`ViewCell`**: An identifiable struct to represent a cell within a view.\n\n- **`UIView.Cell` typealias**: A helper typealias to create `ViewCell` inline.\n- [**`UITableViewReloader`**](#UITableViewReloader): A class to bypass the traditional datasource methods when working with a `UITableView`.\n- [**`UICollectionViewReloader`**](#UICollectionViewReloader): A class to bypass the traditional datasource methods when working with a `UICollectionView`.\n- **`ViewCellsReloadable`**: A protocol to mark a view as having reloadable cells. Implemented by `UITableViewReloader`, `UIStackView`, and `UICollectionViewReloader`.\n- [**`ViewCellConvertible`**](#ViewCellConvertible): An Identifiable struct to represent a cell within a view.\n- **`ViewCellsBuilder`**: An enum to assist in building cells.\n- **`CellsSectionsReloadable`**: A protocol for views that have reloadable sections. Implemented by `UITableViewReloader`, `UICollectionViewReloader` and `UIStackView`.\n- **`CellsSection`**: An identifiable struct to represent a section of cells.\n- [**`CellsSectionConvertable`**](#CellsSectionConvertable): A protocol to convert custom structs into `CellsSection` structures.\n- **`CellsSectionsBuilder`**: An enum to aid in building sections of cells.\n- [**`RenderableView`**](#RenderableView): A convenince protocol to denote views that are capable of rendering content dynamically.\n\nThese elements come together to provide powerful reloading capabilities to your views. These capabilities are provided through several `reload` functions which take in a closure to generate cells, along with optional parameters to define cell creation, reloading, sizing and identification.\n\nHere are some of the functionalities provided:\n\n- `reload { }`: Reloads the cells in a reloadable view using a closure that creates an array of `ViewCell`, `UIView`, `View`  or`CellsSection`.\n- `reload(with data:id:create:render:completion:)`: Reloads the cells in a reloadable view using data, a function to generate unique identifiers, closures for creating and reloading cells, and a closure for sizing cells. `completion` and `id` are optional. `id` parameter is needed only if you want to animate the reload. `render` parameter can be missied if it's a SwiftUI `View` or `RenderableView` view and the `data` is a collection of its `Props`.\n\nThese `reload` functions use a variety of parameters to control the reloading of the cells in the view. By utilizing these functions, you can easily manage the cells within your views and ensure they are always up-to-date.\n\nIt's recommend to specify an `id` for sections and cells or use `Identifiable` items for correct animations. For SwiftUI views there is a `asViewCell(id:)` method.\n\n## UITableViewReloader\n\n`UITableViewReloader` is a class that eliminates the need to work with the traditional datasource. It allows you to directly deal with the data and the cell that should be displayed. With this feature, you don't have to subclass `UITableViewCell`. Instead, you can directly use `UIView` instances and make your codebase simpler and cleaner.\n\nHere’s an example:\n\n```swift\nlazy var tableSource = UITableViewReloader(tableView)\nlet tableView = UITableView()\n\ntableSource.reload(with: myData) { _ in\n    MyCustomView()\n} render: { view, data in\n    view.render(with: data)\n}\n```\n\n## UICollectionViewReloader\n\nSimilar to `UITableViewReloader`, `UICollectionViewReloader` is an extension that allows you to bypass the traditional datasource and delegate methods when working with a `UICollectionView`. You don't have to subclass `UICollectionViewCell`. You can directly use `UIView` instances and simply bind them to the data you want to display.\n\nHere’s an example:\n\n```swift\nlazy var collectionSource = UICollectionViewReloader(collectionView)\nlet collectionView = UICollectionView()\n\ncollectionSource.reload(with: myData) { _ in\n    MyCustomView()\n} render: { view, data in\n    view.configure(with: data)\n}\n```\n\n## ViewCell\n\n`ViewCell` is a structure that acts as a representation of a cell within a view. The main purpose of `ViewCell` is to provide an abstraction layer over traditional cells, allowing you to work directly with `UIView` instances rather than dealing with the overhead of subclassing specific cell classes.\n\n### ViewCell.Values:\n\nA dynamic container that lets you add custom stored properties to the struct. This can be beneficial for adding extra functionalities like custom layouts, behaviors, or even metadata associated with the cell.\\\nExample of extending `ViewCell.Values`:\n```swift\nextension ViewCell.Values {\n  \n  var style: CellStyle {\n    self[\\.style] ?? .default\n  }\n}\n```\nExample of setting the style:\n```swift\nViewCell {\n  SomeCell()\n}\n.with(\\.style, .warning)\n```\n\n## CellsSection\n\n`CellsSection` is a structure designed to represent a section of cells within views that support sectioned layouts, like `UITableView` and `UICollectionView`. \n\n### CellsSection.Values:\nSimilar to the `ViewCell.Values`, this dynamic container allows you to add custom stored properties to the struct. This could be particularly useful when you want to introduce properties such as headers, footers, or specific layouts for a given section.\n\n## RenderableView\n\nThe `RenderableView` protocol is used to denote views that are capable of rendering content dynamically.\\\nViews conforming to this protocol should implement a method to render their content based on the supplied data.\n\n## ViewCellConvertible\n\nThe `ViewCellConvertible` protocol can be adopted by custom structs to provide a mechanism to convert them into `ViewCell` structures. This aids in integrating custom structs directly into reloadable views without the need for `ViewCell` wrapping.\nExample:\n```swift\nextension MyView.Props: ViewCellConvertible {\n\n  public var asViewCell: ViewCell {\n    ViewCell(props: self) {\n      MyView()\n    }\n    .height(70)\n    .willReuse(MyView.self) {\n      $0.prepareForReuse()\n    }\n  }\n}\n```\n```swift\nreloader.reload {\n  MyView.Props(.first)\n  MyView.Props(.second)\n}\n```\n```swift\nreloader.reload(with: collectionOfProps)\n```\n\n## CellsSectionConvertible\n\nSimilar to the `ViewCellConvertible` protocol, the `CellsSectionConvertible` protocol allows custom structs representations to be converted directly into `CellsSection` structures. This can be extremely handy when you have predefined section models that you want to integrate seamlessly into your reloadable views.\n\n## Installation\n\n1. [Swift Package Manager](https://github.com/apple/swift-package-manager)\n\nCreate a `Package.swift` file.\n```swift\n// swift-tools-version:5.7\nimport PackageDescription\n\nlet package = Package(\n  name: \"SomeProject\",\n  dependencies: [\n    .package(url: \"https://github.com/dankinsoid/CellsReloadable.git\", from: \"1.1.1\")\n  ],\n  targets: [\n    .target(name: \"SomeProject\", dependencies: [\"CellsReloadable\"])\n  ]\n)\n```\n```ruby\n$ swift build\n```\n\n## Author\n\ndankinsoid, voidilov@gmail.com\n\n## License\n\nCellsReloadable is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankinsoid%2Fcellsreloadable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdankinsoid%2Fcellsreloadable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankinsoid%2Fcellsreloadable/lists"}