-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS example app #337
macOS example app #337
Conversation
1 similar comment
@insidegui that gif looks awesome! 🎉 |
Omg this is great! |
We’re using IGListKit with NSTableView, and I must mention an important point about moves. While UITableView expects to be told where each row was and where it is now, NSTableView requires moves to be reported incrementally. If moves are reported as they are now, multiple moves will often result in an inconsistent internal state and crashes. As far as I can see, NSCollectionView uses the newer behavior found in UITableView and UICollectionView. I’ve added an option for reporting incremental moves to our internal copy of IGListDiff. Besides NSTableView, it’s useful for replaying changes on collections. @jessesquires and @rnystrom, let me know if you’d like me to submit a pull request with it. |
To give a concrete example, try replacing implementation of UsersViewController.shuffle() with: var usersModified = users
let second = users[1]
usersModified.remove(at: 1)
usersModified.insert(second, at: 0)
users = usersModified This produces a diff with:
Before:
After:
Since NSTableView applies moves incrementally, it moves row at index 1 to 0, then moves row at index 0 (the row it just moved from index 1 in previous step) to 1. As a result, there’s no visible change, and the visible state does not match the data source. |
@antons I didn't know that, thanks for reporting. I think a pull request would be really helpful, but let's see what @jessesquires and @rnystrom think about it :) |
@antons Thanks! 😄 I would definitely like to see a PR if you have the time 👍 |
@antons Let's also open a new issue for this 😊 |
Related issue: #333
I've made a very simple macOS example app. It's just a list of names which can be searched, shuffled or deleted.
I think this is a good starting point for anyone who wants to use this on macOS projects :)