- Notifications
You must be signed in to change notification settings - Fork0
Stop looking for NSOutlineViewDiffableDataSource, it’s here 👌
License
BeehiveInnovations/OutlineViewDiffableDataSource
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Here’s to the crazy ones…
At WWDC 2019 Apple introduced amazing APIs forUITableView
andUICollectionView
data management. For instance, the barely documentedUITableViewDiffableDataSource
can be used as a data source of a table view, and all modifications made to itsNSDiffableDataSourceSnapshot
are automatically applied by that table view.
Watch the official video“Advances in UI Data Sources” to get a better idea.
These diffable APIs were fantastic news for UIKit Developers. Unfortunately AppKit has got onlyNSCollectionViewDiffableDataSource
andNSTableViewDiffableDataSource
which means thatNSOutlineView
is out of luck. Let’s hope that Apple releasesNSOutlineViewDiffableDataSource
at WWDC21.
This Swift Package is my modest attempt to implement a diffable data source forNSOutlineView
with support for nested items. This is how it’s used:
letdataSource=OutlineViewDiffableDataSource(outlineView: outlineView)varsnapshot= dataSource.snapshot()snapshot.appendItems([folder1, folder2])snapshot.appendItems([file11, file12], into: folder1)snapshot.appendItems([file21, file22], into: folder2)dataSource.applySnapshot(initialSnapshot, animatingDifferences:false)
The accompanyingDiffableDataSourceSnapshot
API is heavily inspired by Cocoa’s ownNSDiffableDataSourceSnapshot
and includes many similar methods, but adopted for tree data structures:
// …mutatingfunc insertItems(_ newItems:[Item], beforeItem:Item)-> Boolmutatingfunc insertItems(_ newItems:[Item], afterItem:Item)-> Boolmutatingfunc deleteItems(_ existingItems:[Item])->Boolmutatingfunc deleteAllItems()mutatingfunc reloadItems(_ items:[Item])->Bool// …
Not sure how this ends, but theDiffableDataSourceSnapshot
is a value type. Just like its “official” counterpart, this struct can be built and applied from the background thread, as far as I know 😅
SPM: macOS 10.11
Demo: macOS 10.15
The Demo Mac app is a playground for breaking the library. The snapshot API is 100% covered by Tests, but I would much appreciate any help with QA.
If you download and play with the sample app, it’s already cool. But if you report or even fix one of the issues, you are just awesome. Here is a Roadmap, please join me if you can:
- Add a new section “Quick Start”
- Explain the protocol
OutlineViewItem
- Explain how to implement drag-n-drop in your app
- Add versioning because now it’s just a
master
branch - Add this project to theDave’s repository of Swift Packages
- Improve the Demo app, it’s too basic and doesn’t show all the features
- File a Radar requesting a real
NSOutlineViewDiffableDataSource
, why not - Make a profile picture from one of WWDC slides about diffable data sources
- Generate documentation usingSwift Doc
- Add badges like “Swift 5.2” and “CI Passing”
- Fill theCommunity Profile
- Add Showcase section if anyone uses this component
You can always find me as@VadimShpakovski in Twitter. If you publish apps in the App Store or in the Mac App Store, check out my native client for the App Store Connect:NativeConnect. Some people like it. Thanks in advance!
About
Stop looking for NSOutlineViewDiffableDataSource, it’s here 👌
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- Swift100.0%