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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 047b5156fa009bc8e45a9f5de8bb9c54d24188cb Mon Sep 17 00:00:00 2001
  2. From: Carola Nitz <nitz.carola@googlemail.com>
  3. Date: Sat, 15 Mar 2014 22:08:32 +0100
  4. Subject: [PATCH] Added a delegate method to remove item from folder
  5. ---
  6. .../LXReorderableCollectionViewFlowLayout.h | 1 +
  7. .../LXReorderableCollectionViewFlowLayout.m | 7 ++++++-
  8. 2 files changed, 7 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..5a6d3e7 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,10 @@ 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. + }
  45. switch (self.scrollDirection) {
  46. case UICollectionViewScrollDirectionVertical: {
  47. if (viewCenter.y < (CGRectGetMinY(self.collectionView.bounds) + self.scrollingTriggerEdgeInsets.top)) {
  48. --
  49. 1.8.5.2 (Apple Git-48)