Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASCollectionView] Add/Fix Support for Interactive Movement #2117

Closed
ay8s opened this issue Aug 22, 2016 · 3 comments
Closed

[ASCollectionView] Add/Fix Support for Interactive Movement #2117

ay8s opened this issue Aug 22, 2016 · 3 comments

Comments

@ay8s
Copy link
Contributor

ay8s commented Aug 22, 2016

I've been exploring ways to enable reordering within ASCollectionView. I was trying out the Interactive Movement option introduced in iOS 9.0. It looks like most of the logic works except iOS isn't able to show the cell when a cell is actually picked up to move causing the rest of the logic and flow to fail.

Example Project: https://cl.ly/3n3C330N1Y10
Simply added the required methods to ASCollectionView Example.

When it works the cell should be "picked up" and move with the gesture location to the new location before collectionView:moveItemAtIndexPath:toIndexPath: is called with the final indexPaths.

The whole flow should look like... https://cl.ly/1R1v1c3c2f3D

Would be amazing if this could function with ASCollectionView and ASCellNodes.

@Adlai-Holler
Copy link
Contributor

@ay8s I'd love to get this up and running. We've got a ton of work for ASDK 2 that we're aiming to make ready for release, but here's the info I gathered on a deep-dive into getting collection view reordering working with ASDK (work is on the AHCollectionReordering branch):

  • In updateInteractiveMovementPosition collection view calls -moveItemAtIndexPath:toIndexPath: on itself if the pending target index path has changed.
  • It's a special kind of move, where the data source counts are required not to change (since the data source shouldn't know about it). So we'll have to fake the numberOfItemsInSection: return value during interactive moves, to pretend we don't know about the pending move.
  • At the same time, we DO need the data controller to move the node after each move update or else the range controller will make mistakes in assigning interface states to each node.
  • We need to update the range controller after each such move. This is easily accomplished by adding -setNeedsUpdate after calling [super moveItem:] if this is an interactive move.
  • Just before endInteractiveMove we need to put the node back where it was and reset our fake data source counts, so that when we get the real collectionView:moveItemAtIndexPath:toIndexPath: call, we do the update like normal.
  • We'll probably need to add two ivars: sourceInteractiveMoveIndexPath and pendingInteractiveMoveIndexPath. We can use these to fake our data source item counts after each interactive move update, and to move the dragged node around to follow the cell.
  • All of the above would work assuming they don't edit the collection view during interactive movement. I'm not sure how well UICollectionView handles this case, even.

@harryworld
Copy link

@ay8s We are trying out an implementation for your suggested interaction. Would love to gather your feedbacks if you are still on this. PR #2868

@garrettmoon
Copy link
Contributor

This issue was moved to TextureGroup/Texture#141

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

No branches or pull requests

4 participants