All Projects → ra1028 → Diffabledatasources

ra1028 / Diffabledatasources

Licence: apache-2.0
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Diffabledatasources

Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+396.84%)
Mutual labels:  algorithm, diff, diffing, tableview, collectionview
Rxdatasources
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Stars: ✭ 2,784 (+363.23%)
Mutual labels:  datasource, diff, tableview, collectionview
Modelassistant
Elegant library to manage the interactions between view and model in Swift
Stars: ✭ 26 (-95.67%)
Mutual labels:  datasource, tableview, collectionview
Datasources
💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)
Stars: ✭ 553 (-7.99%)
Mutual labels:  datasource, diff, collectionview
Buffer
Swift μ-framework for efficient array diffs and datasource adapters.
Stars: ✭ 349 (-41.93%)
Mutual labels:  datasource, diffing, tableview
Micro
🏎Fast diffing and type safe SwiftUI style data source for UICollectionView
Stars: ✭ 77 (-87.19%)
Mutual labels:  diff, datasource
CollectionViewDiffableGameDB
Game DB iOS App using iOS 13 NSDiffableDataSourceSnapshot to filter, sort, and search with animations
Stars: ✭ 17 (-97.17%)
Mutual labels:  collectionview, diffing
SNAdapter
iOS swift tableview and collectionView Adapter
Stars: ✭ 35 (-94.18%)
Mutual labels:  tableview, collectionview
Shsegmentedcontroltableview
Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,上拉加载更多。现已加入swift豪华套餐,使用样例助你快速使用
Stars: ✭ 259 (-56.91%)
Mutual labels:  tableview, collectionview
Dtl
diff template library written by C++
Stars: ✭ 180 (-70.05%)
Mutual labels:  algorithm, diff
Ace Diff
A diff/merging wrapper for Ace Editor built on google-diff-match-patch
Stars: ✭ 257 (-57.24%)
Mutual labels:  diff, diffing
Containercontroller
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
Stars: ✭ 273 (-54.58%)
Mutual labels:  tableview, collectionview
SectionReactor
A ReactorKit extension for managing table view and collection view sections with RxDataSources
Stars: ✭ 45 (-92.51%)
Mutual labels:  tableview, collectionview
go-delta
go-delta - A Go package and utility to generate and apply binary delta updates.
Stars: ✭ 25 (-95.84%)
Mutual labels:  diff, diffing
Pageable
An easy way to Pagination or Infinite scrolling for TableView/CollectionView
Stars: ✭ 44 (-92.68%)
Mutual labels:  tableview, collectionview
Swiftlcs
Swift implementation of the longest common subsequence (LCS) algorithm.
Stars: ✭ 207 (-65.56%)
Mutual labels:  algorithm, diff
Multidiff
Binary data diffing for multiple objects or streams of data
Stars: ✭ 282 (-53.08%)
Mutual labels:  diff, diffing
Pgdiff
Compares the PostgreSQL schema between two databases and generates SQL statements that can be run manually against the second database to make their schemas match.
Stars: ✭ 333 (-44.59%)
Mutual labels:  diff, diffing
Dwifft
Swift Diff
Stars: ✭ 1,822 (+203.16%)
Mutual labels:  algorithm, diff
Textdistance
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Stars: ✭ 2,575 (+328.45%)
Mutual labels:  algorithm, diff

DiffableDataSources

💾 A library for backporting UITableView/UICollectionViewDiffableDataSource powered by DifferenceKit.

Swift5 Release CocoaPods Carthage Swift Package Manager Build Status Platform Lincense

Made with ❤️ by Ryo Aoyama


Introduction

Apple has announced a diffable data source at WWDC 2019.
It's a great API that easily updating our table view and collection view items using automatic diffing.
However, it's a little while before we can use it in a production service.
That because it requires the latest OS to use.
DiffableDataSources make it possible to introduce almost the same functionality from now on.

Uses a sophisticated open source DifferenceKit for the algorithm engine.
It's extremely fast and completely avoids synchronization bugs, exceptions, and crashes.



Difference from the Official

Spec

  • Supports iOS 9.0+ / macOS 10.11+ / tvOS 9.0+
  • Open sourced algorithm.
  • Duplicate sections or items are allowed.
  • Using performBatchUpdates for diffing updates.

Namings

DiffableDataSources have different class names to avoid conflicts with the official API.
Correspondence table is below.

Official Backported
NSDiffableDataSourceSnapshot DiffableDataSourceSnapshot
UITableViewDiffableDataSource TableViewDiffableDataSource
UICollectionViewDiffableDataSource CollectionViewDiffableDataSource
NSCollectionViewDiffableDataSource CocoaCollectionViewDiffableDataSource

Getting Started

Build Project

$ git clone https://github.com/ra1028/DiffableDataSources.git
$ cd DiffableDataSources/
$ make setup
$ open DiffableDataSources.xcworkspace

Basic Usage

First, define the type representing section.
It should conforms to Hashable for identifies from the all sections.
Type of enum can used conveniently befause it conforms Hashable by default.

enum Section {
    case main
}

Then, define the item type conforms to Hashable.

struct User: Hashable {
    var name: String
}

Create a data source object, it will be set to table view automatically.
You should dequeue the non nil cells via closure.

final class UsersViewController: UIViewController {
    let tableView: UITableView = ...

    lazy var dataSource = TableViewDiffableDataSource<Section, User>(tableView: tableView) { tableView, indexPath, user in
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = user.name
        return cell
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    }
}

Manages and updates the data sources intuitively by intermediating DiffableDataSourceSnapshot.
The UI isn't updated until you apply the edited snapshot object.
Update the UI with diffing animation automatically calculated by applying an edited snapshot.

let users = [
    User(name: "Steve Jobs"),
    User(name: "Stephen Wozniak"),
    User(name: "Tim Cook"),
    User(name: "Jonathan Ive")
]

let snapshot = DiffableDataSourceSnapshot<Section, User>()
snapshot.appendSections([.main])
snapshot.appendItems(users)

dataSource.apply(snapshot) {
    // completion
}

Check the documentation for more detailed API.

[See More Usage]


Requirements

  • Swift 5.0+
  • iOS 9.0+
  • macOS 10.11+
  • tvOS 9.0+

Installation

CocoaPods

Add the following to your Podfile:

pod 'DiffableDataSources'

Carthage

Add the following to your Cartfile:

github "ra1028/DiffableDataSources"

Swift Package Manager

Add the following to the dependencies of your Package.swift:

.package(url: "https://github.com/ra1028/DiffableDataSources.git", from: "x.x.x")

Contributing

Pull requests, bug reports and feature requests are welcome 🚀
Please see the CONTRIBUTING file for learn how to contribute to DiffableDataSources.


Relations

DifferenceKit

A fast and flexible O(n) difference algorithm framework for Swift collection.

Carbon

A declarative library for building component-based user interfaces in UITableView and UICollectionView.


License

DiffableDataSources is released under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].