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

Enable collection node interactive moves #735

Merged
merged 5 commits into from
Jan 9, 2018
Merged

Enable collection node interactive moves #735

merged 5 commits into from
Jan 9, 2018

Conversation

Adlai-Holler
Copy link
Member

@Adlai-Holler Adlai-Holler commented Jan 5, 2018

This patch enables interactive movement for collection node items and updates the ASCollectionView example to showcase it.

Caveats:

  • Item movement is disabled when using async collection layout. See the comment at the top of - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath for details.
  • When the item is dropped, a new node will be created for it, so it may flash while it's rendered. This is because our change set currently represents moves as delete/insert so the old node is discarded.

To use:

  • Have your data source implement collectionNode:moveItemAtIndexPath:toIndexPath:.
  • Optionally, implement collectionNode:canMoveItemWithNode:. As with UIKit, this defaults to YES as long as you implement the move method.
  • Use the normal UICollectionView interactive movement methods, such as beginInteractiveMovementForItemAtIndexPath:. We will need to bridge or intercept these at this time.

Copy link
Contributor

@maicki maicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// In iOS >= 11, this is made much easier by the UIDataSourceTranslating API. In previous versions of iOS our best bet
// would be to capture the invalidation contexts that are sent during interactive moves and make our own data source translator.
if ([self.collectionViewLayout isKindOfClass:[ASCollectionLayout class]]) {
return NO;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we print out some log here to let user know about it?

@nguyenhuy
Copy link
Member

#141.

bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
* Add support for interactive moves

* Enable drag & drop in collection view example

* Update changelog

* Change the gating logic to match UIKit

* Add a warning when we prevent interactive movement due to async layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants