0002-Added-a-delegate-method-to-remove-item-from-folder.patch 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From fa0aabe932016b67a37b82b04dd21e2b4bdfad12 Mon Sep 17 00:00:00 2001
  2. From: Carola Nitz <nitz.carola@googlemail.com>
  3. Date: Mon, 24 Mar 2014 22:12:53 +0100
  4. Subject: [PATCH] Added a delegate method to remove item from folder
  5. ---
  6. .../LXReorderableCollectionViewFlowLayout.h | 1 +
  7. .../LXReorderableCollectionViewFlowLayout.m | 8 +++++++-
  8. 2 files changed, 8 insertions(+), 1 deletion(-)
  9. diff --git a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h
  10. index 76617f4..45c3843 100755
  11. --- a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h
  12. +++ b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h
  13. @@ -24,6 +24,7 @@
  14. - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath;
  15. - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath didMoveToIndexPath:(NSIndexPath *)toIndexPath;
  16. +- (void)collectionView:(UICollectionView *)collectionView removeItemFromFolderAtIndexPathIfNeeded:(NSIndexPath *)indexPath;
  17. - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath;
  18. - (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath canMoveToIndexPath:(NSIndexPath *)toIndexPath;
  19. diff --git a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m
  20. index e1289b2..abf5a98 100755
  21. --- a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m
  22. +++ b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m
  23. @@ -240,6 +240,7 @@ static NSString * const kLXCollectionViewKeyPath = @"collectionView";
  24. translation = CGPointMake(0.0f, distance);
  25. } break;
  26. case LXScrollingDirectionLeft: {
  27. + [self.dataSource collectionView:self.collectionView removeItemFromFolderAtIndexPathIfNeeded:_selectedItemIndexPath];
  28. distance = -distance;
  29. CGFloat minX = 0.0f - contentInset.left;
  30. @@ -250,6 +251,7 @@ static NSString * const kLXCollectionViewKeyPath = @"collectionView";
  31. translation = CGPointMake(distance, 0.0f);
  32. } break;
  33. case LXScrollingDirectionRight: {
  34. + [self.dataSource collectionView:self.collectionView removeItemFromFolderAtIndexPathIfNeeded:_selectedItemIndexPath];
  35. CGFloat maxX = MAX(contentSize.width, frameSize.width) - frameSize.width + contentInset.right;
  36. if ((contentOffset.x + distance) >= maxX) {
  37. @@ -384,7 +386,11 @@ static NSString * const kLXCollectionViewKeyPath = @"collectionView";
  38. CGPoint viewCenter = self.currentView.center = LXS_CGPointAdd(self.currentViewCenter, self.panTranslationInCollectionView);
  39. [self invalidateLayoutIfNecessary];
  40. -
  41. + //TODO: start a timer to not immediately trigger the remove from folder
  42. + if (self.currentView.center.x < 0 || self.currentView.center.x > self.collectionView.frame.size.width) {
  43. + [self.dataSource collectionView:self.collectionView removeItemFromFolderAtIndexPathIfNeeded:_selectedItemIndexPath];
  44. + [self.currentView removeFromSuperview];
  45. + }
  46. switch (self.scrollDirection) {
  47. case UICollectionViewScrollDirectionVertical: {
  48. if (viewCenter.y < (CGRectGetMinY(self.collectionView.bounds) + self.scrollingTriggerEdgeInsets.top)) {
  49. --
  50. 1.8.5.2 (Apple Git-48)