izakpavel /
SwiftUIPagingScrollView
implementation of generic paging scrollView in SwiftUI
Loading repository data…
kazec / repository
Generic implementation of Paul Heckel's diff algorithm written in Swift
Pure Swift generic collection diff algorithm implementation base on Paul Heckel's diff algorithm.
var oldString = "åƒåß©©©åßasfa"
let newString = "😉ååß©åßas🤩🤩fa"
OrderedDiffResult(context: DiffContext(from: oldString, to: newString)).apply(to: &oldString)
XCTAssert(oldString == newString)
Perform custom diff actions
You can conform to protocol DiffChangesApplier to perform custom actions alongside with the process of diffing.
For example, for updating one section in a UITableView by simply inserting and deleting rows, you can use:
struct TableViewSectionUpdater<T> : DiffChangesApplier {
typealias Index = Int
let tableView: UITableView
let sectionIndex: Int
let rowAnimation: UITableView.RowAnimation
func applyDeletion(at index: Int) {
tableView.deleteRows(at: [IndexPath(row: index, section: sectionIndex)], with: rowAnimation)
}
func applyInsertion(_ element: T, at index: Int) {
tableView.insertRows(at: [IndexPath(row: index, section: sectionIndex)], with: rowAnimation)
}
func applyUpdateOrMove(
_ oldElement: T,
at oldIndex: Int,
to newElement: T,
at newIndex: Int,
updated: Bool,
moved: Bool
) {
applyDeletion(at: oldIndex)
applyInsertion(newElement, at: newIndex)
}
}
And to use it:
let updater = TableViewSectionUpdater(...)
tableView.performBatchUpdates({
let updater = TableViewSectionUpdater<RowModel>(...)
updater.applyDiff(with: DiffContext(from: oldRowModels, to: newRowModels))
}, completion: nil)
Selected from shared topics, language and repository description—not editorial ratings.
izakpavel /
implementation of generic paging scrollView in SwiftUI
alfianlosari /
An example of Generic UITableViewController implementation
DreamingInBinary /
A Swift implementation of a generic datasource that you can use for table views.
lazytype /
Implementation of a generic 2-3 finger tree in Swift based on the Haskell implementation demonstrated in http://andrew.gibiansky.com/blog/haskell/finger-trees
tonystone /
An efficient and generic implementation of a balanced AVL Tree in native Swift.
Blackjacx /
Tired of implementing the data sources over and over again? Want to use a lightweight solution that does not mess up your view controllers? Then this is for you! The generic data source implementation for all your view controllers, that supports UITableView, UICollectionView and NSFetchedResultsController