Skip to content
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

Closed
wants to merge 13 commits into from
Closed

macOS example app #337

wants to merge 13 commits into from

Conversation

insidegui
Copy link
Contributor

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 :)

iglistkitmac

@coveralls
Copy link

coveralls commented Dec 15, 2016

Coverage Status

Coverage remained the same at 97.952% when pulling 1829349 on insidegui:macsample into 9600c23 on Instagram:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.952% when pulling 1829349 on insidegui:macsample into 9600c23 on Instagram:master.

@jessesquires
Copy link
Contributor

@insidegui that gif looks awesome! 🎉

@rnystrom
Copy link
Contributor

Omg this is great!

@antons
Copy link
Contributor

antons commented Dec 17, 2016

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.

@antons
Copy link
Contributor

antons commented Dec 17, 2016

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:

<IGListIndexSetResult 0x600000073300; 0 inserts; 0 deletes; 0 updates; 2 moves>
▿ 2 elements
  - 0 : <IGListMoveIndex 0x6000000268c0; from: 1; to: 0;>
  - 1 : <IGListMoveIndex 0x60000002d720; from: 0; to: 1;>

Before:

▿ 201 elements
  - 0 : "Aaron"
  - 1 : "Abigail"
…

After:

▿ 201 elements
  - 0 : "Abigail"
  - 1 : "Aaron"
…

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.

@insidegui
Copy link
Contributor Author

@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 :)

@jessesquires
Copy link
Contributor

@antons Thanks! 😄 I would definitely like to see a PR if you have the time 👍

@jessesquires
Copy link
Contributor

@antons Let's also open a new issue for this 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants