Add shouldDeselectItemAtIndex to IGListSectionController

Summary: Add `shouldDeselectItemAtIndex:` to `IGListSectionController`. `shouldSelectItemAtIndex:` already exists, but its inverse does not.

Reviewed By: lorixx

Differential Revision: D34727371

fbshipit-source-id: ba4e0917380e1b3ff189dad7977ac5c1caa9b714
This commit is contained in:
Alan Wang 2022-03-09 10:13:06 -08:00 committed by Facebook GitHub Bot
parent b6d1a96c08
commit b22a10e47f
4 changed files with 21 additions and 2 deletions

View file

@ -60,10 +60,11 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
```
### Enhancements
- Added `shouldDeselectItemAtIndex:` to `IGListSectionController` . [bladeofky](https://github.com/bladeofky)
- Added `shouldSelectItemAtIndex:` to `IGListSectionController` . [dirtmelon](https://github.com/dirtmelon)
- Added [Mac Catalyst](https://developer.apple.com/mac-catalyst/) support. [Petro Rovenskyy](https://github.com/3a4oT/)
- Added [Mac Catalyst](https://developer.apple.com/mac-catalyst/) support. [Petro Rovenskyy](https://github.com/3a4oT/)
- Introduce `IGListSwiftKit`, with Swift refinements for `dequeueReusableCellOfClass` methods. [Koen Punt](https://github.com/koenpunt) [(#1388)](https://github.com/Instagram/IGListKit/pull/1388).
@ -85,7 +86,7 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
- Schedules an update block (`dispatch_async`) only when needed, instead of scheduling on every single call to `-performUpdateWithCollectionViewBlock`.
- Wraps each update in a `transaction` that can be easily cancelled.
- Uses methods instead of blocks to make the callstack easier to read in crash reports.
- Unblocks `IGListExperimentBackgroundDiffing`
- Unblocks `IGListExperimentBackgroundDiffing`
### Fixes

View file

@ -84,6 +84,15 @@ NS_SWIFT_NAME(ListSectionController)
*/
- (BOOL)shouldSelectItemAtIndex:(NSInteger)index;
/**
Asks the section controller if the cell at the specified index path should be deselected
@param index The index of cell to be deselected.
@note The default implementation returns YES. **Calling super is not required.**
*/
- (BOOL)shouldDeselectItemAtIndex:(NSInteger)index;
/**
Tells the section controller that the cell at the specified index path was selected.

View file

@ -89,6 +89,10 @@ void IGListSectionControllerPopThread(void) {
return YES;
}
- (BOOL)shouldDeselectItemAtIndex:(NSInteger)index {
return YES;
}
- (void)didSelectItemAtIndex:(NSInteger)index {}
- (void)didDeselectItemAtIndex:(NSInteger)index {}

View file

@ -127,6 +127,11 @@
return [sectionController shouldSelectItemAtIndex:indexPath.item];
}
- (BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
IGListSectionController * sectionController = [self sectionControllerForSection:indexPath.section];
return [sectionController shouldDeselectItemAtIndex:indexPath.item];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// forward this method to the delegate b/c this implementation will steal the message from the proxy
id<UICollectionViewDelegate> collectionViewDelegate = self.collectionViewDelegate;