All Projects → shpakovski → OutlineViewDiffableDataSource

shpakovski / OutlineViewDiffableDataSource

Licence: BSD-3-Clause license
Stop looking for NSOutlineViewDiffableDataSource, it’s here 👌

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to OutlineViewDiffableDataSource

Subethaedit
General purpose plain text editor for macOS. Widely known for its live collaboration feature.
Stars: ✭ 1,183 (+1132.29%)
Mutual labels:  cocoa, macosx
LSPKit
Language Server Protocol (LSP) implementation for Cocoa ☕️
Stars: ✭ 33 (-65.62%)
Mutual labels:  cocoa, appkit
TextViewPlus
Collection of useful extensions when working with NSTextView
Stars: ✭ 28 (-70.83%)
Mutual labels:  cocoa, appkit
WebPKit
A framework that extends a variety of Cocoa APIs with capabilities for encoding and decoding WebP files for all of Apple's platforms.
Stars: ✭ 29 (-69.79%)
Mutual labels:  cocoa, appkit
react-native-macos
Fork of https://github.com/ptmt/react-native-macos with more features
Stars: ✭ 22 (-77.08%)
Mutual labels:  cocoa, appkit
XcoatOfPaint
Replace your Xcode icon with colorful variants
Stars: ✭ 131 (+36.46%)
Mutual labels:  cocoa, appkit
ProcessEnv
Capture the shell environment of a Foundation app
Stars: ✭ 16 (-83.33%)
Mutual labels:  cocoa, appkit
Stprivilegedtask
An NSTask-like wrapper around the macOS Security Framework's AEWP function to run shell commands with root privileges in Objective-C / Cocoa.
Stars: ✭ 335 (+248.96%)
Mutual labels:  cocoa, macosx
Twitterx
Keeping Twitter for macOS alive with code injection
Stars: ✭ 187 (+94.79%)
Mutual labels:  cocoa, macosx
Textmate
TextMate is a graphical text editor for macOS 10.12 or later
Stars: ✭ 13,729 (+14201.04%)
Mutual labels:  cocoa
hypseus-singe
Hypseus is a SDL2 version of Daphne and Singe. Laserdisc game emulation.
Stars: ✭ 86 (-10.42%)
Mutual labels:  macosx
Dd Plist
A java library providing support for ASCII, XML and binary property lists.
Stars: ✭ 201 (+109.38%)
Mutual labels:  cocoa
Cacao
Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
Stars: ✭ 205 (+113.54%)
Mutual labels:  cocoa
Hackintosh-OpenCore-EFI-Dell-Inspiron-5559
Hackintosh (OpenCore) Dell Inspiron 15 5559 i7 6500u | Tested on Bigsur, Catalina
Stars: ✭ 18 (-81.25%)
Mutual labels:  macosx
Pywebview
Build GUI for your Python program with JavaScript, HTML, and CSS
Stars: ✭ 2,649 (+2659.38%)
Mutual labels:  cocoa
dumbmutate
Simple mutation-testing
Stars: ✭ 32 (-66.67%)
Mutual labels:  macosx
Cocoatextfield
Apple TextField created according to the Material.IO guidelines of 2019. Featured at Medium.
Stars: ✭ 195 (+103.13%)
Mutual labels:  cocoa
Cocoa Rest Client
A free, native Apple macOS app for testing HTTP/REST endpoints
Stars: ✭ 2,257 (+2251.04%)
Mutual labels:  cocoa
Equinox
🌇 🌃 Create dynamic wallpapers for macOS.
Stars: ✭ 737 (+667.71%)
Mutual labels:  appkit
panthro
An implementation of XPath 3.0 in Objective-C/Cocoa
Stars: ✭ 45 (-53.12%)
Mutual labels:  cocoa

Here’s to the crazy ones…

Introduction

At WWDC 2019 Apple introduced amazing APIs for UITableView and UICollectionView data management. For instance, the barely documented UITableViewDiffableDataSource can be used as a data source of a table view, and all modifications made to its NSDiffableDataSourceSnapshot 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 only NSCollectionViewDiffableDataSource and NSTableViewDiffableDataSource which means that NSOutlineView is out of luck. Let’s hope that Apple releases NSOutlineViewDiffableDataSource at WWDC21.

OutlineViewDiffableDataSource

This Swift Package is my modest attempt to implement a diffable data source for NSOutlineView with support for nested items. This is how it’s used:

let dataSource = OutlineViewDiffableDataSource (outlineView: outlineView)
var snapshot = dataSource.snapshot()
snapshot.appendItems([folder1, folder2])
snapshot.appendItems([file11, file12], into: folder1)
snapshot.appendItems([file21, file22], into: folder2)
dataSource.applySnapshot(initialSnapshot, animatingDifferences: false)

The accompanying DiffableDataSourceSnapshot API is heavily inspired by Cocoa’s own NSDiffableDataSourceSnapshot and includes many similar methods, but adopted for tree data structures:

//
mutating func insertItems(_ newItems: [Item], beforeItem: Item) -> Bool
mutating func insertItems(_ newItems: [Item], afterItem: Item) -> Bool
mutating func deleteItems(_ existingItems: [Item]) -> Bool
mutating func deleteAllItems()
mutating func reloadItems(_ items: [Item]) -> Bool
//

Not sure how this ends, but the DiffableDataSourceSnapshot 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 😅

Demo App

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.

OutlineViewDiffableDataSource Demo

Help Wanted

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 the Dave’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 using Swift Doc
  • Add badges like “Swift 5.2” and “CI Passing”
  • Fill the Community Profile
  • Add Showcase section if anyone uses this component

Contact Information

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!

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].