diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ae82420..c41adfeb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Source/IGListKit/IGListSectionController.h b/Source/IGListKit/IGListSectionController.h index b7e5ec50c..3041e3030 100644 --- a/Source/IGListKit/IGListSectionController.h +++ b/Source/IGListKit/IGListSectionController.h @@ -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. diff --git a/Source/IGListKit/IGListSectionController.m b/Source/IGListKit/IGListSectionController.m index c60cc1329..0aff1a353 100644 --- a/Source/IGListKit/IGListSectionController.m +++ b/Source/IGListKit/IGListSectionController.m @@ -89,6 +89,10 @@ - (BOOL)shouldSelectItemAtIndex:(NSInteger)index { return YES; } +- (BOOL)shouldDeselectItemAtIndex:(NSInteger)index { + return YES; +} + - (void)didSelectItemAtIndex:(NSInteger)index {} - (void)didDeselectItemAtIndex:(NSInteger)index {} diff --git a/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m b/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m index c710e9613..de82d449b 100644 --- a/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m +++ b/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m @@ -127,6 +127,11 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde 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 collectionViewDelegate = self.collectionViewDelegate;