-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Interactive Reordering #976
Changes from 2 commits
fc5659b
345385d
8f7fb5a
a3c61c0
d9bf7fc
54e0b07
d3bedfc
2c8a42d
f6dce23
893a8be
9f355f1
3a70048
5b20441
42188c0
16e35b3
6e74899
fd7d721
50b81a4
ee69e66
4ce6401
7aaf51e
400a0bc
1ecb145
85d8849
f63cb30
35b1c4e
e0b3773
1d808f0
fad162a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,15 +63,6 @@ NS_SWIFT_NAME(ListAdapterDataSource) | |
|
||
@optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just noting: we can keep this for after this merges, let's be sure to open a new issue to track this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jverdi could we move this to just be a new delegate on
|
||
|
||
/** | ||
Asks the datasource whether a list object should be movable as the result of interactive reordering. | ||
|
||
@param listAdapter The list adapter sending this information. | ||
@param sectionIndex The index of the section proposed to be moved. | ||
@param index The index of the object proposed to be moved. | ||
*/ | ||
- (BOOL)listAdapter:(IGListAdapter *)listAdapter canMoveObjectInSection:(NSInteger)sectionIndex atIndex:(NSInteger)index; | ||
|
||
/** | ||
Notifies the datasource that a list object should move as the result of interactive reordering. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,18 +59,9 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView | |
} | ||
|
||
- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath { | ||
id <IGListAdapterDataSource> dataSource = self.dataSource; | ||
IGAssert(dataSource != nil, @"Found a nil dataSource when requesting canMoveItemAtIndexPath for interactive reordering"); | ||
|
||
const NSInteger sectionIndex = indexPath.section; | ||
const NSInteger itemIndex = indexPath.item; | ||
|
||
// for ease of implementation, first we check with the listAdapter | ||
if ([dataSource respondsToSelector:@selector(listAdapter:canMoveObjectInSection:atIndex:)]) { | ||
return [dataSource listAdapter:self canMoveObjectInSection:sectionIndex atIndex:itemIndex]; | ||
} | ||
|
||
// then we fall back to the sectionController method | ||
IGListSectionController *sectionController = [self sectionControllerForSection:sectionIndex]; | ||
return [sectionController canMoveItemAtIndex:itemIndex]; | ||
} | ||
|
@@ -79,7 +70,7 @@ - (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(N | |
const NSInteger sourceItemIndex = sourceIndexPath.item; | ||
const NSInteger destinationItemIndex = destinationIndexPath.item; | ||
const NSInteger sourceSectionIndex = sourceIndexPath.section; | ||
const NSInteger destinationSectionIndex = destinationIndexPath.section; | ||
NSInteger destinationSectionIndex = destinationIndexPath.section; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
|
||
IGListSectionController *sourceSectionController = [self sectionControllerForSection:sourceSectionIndex]; | ||
IGListSectionController *destinationSectionController = [self sectionControllerForSection:destinationSectionIndex]; | ||
|
@@ -104,7 +95,7 @@ - (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(N | |
} else if (destinationItemIndex == 1 && destinationSectionIndex < sourceSectionIndex) { | ||
// the "item" representing our section was dropped | ||
// into the end of a destination section rather than the beginning | ||
// so it really belongs one section before the section where it landed | ||
// so it really belongs one section after the section where it landed | ||
destinationSectionIndex += 1; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove