Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
Add shouldDeselectItemAtIndex to IGListSectionController
Browse files Browse the repository at this point in the history
Summary: Add `shouldDeselectItemAtIndex:` to `IGListSectionController`. `shouldSelectItemAtIndex:` already exists, but its inverse does not.

Reviewed By: lorixx

Differential Revision: D34727371

fbshipit-source-id: ba4e0917380e1b3ff189dad7977ac5c1caa9b714
  • Loading branch information
Alan Wang authored and facebook-github-bot committed Mar 9, 2022
1 parent b6d1a96 commit b22a10e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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

Expand Down
9 changes: 9 additions & 0 deletions Source/IGListKit/IGListSectionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/IGListSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ - (BOOL)shouldSelectItemAtIndex:(NSInteger)index {
return YES;
}

- (BOOL)shouldDeselectItemAtIndex:(NSInteger)index {
return YES;
}

- (void)didSelectItemAtIndex:(NSInteger)index {}

- (void)didDeselectItemAtIndex:(NSInteger)index {}
Expand Down
5 changes: 5 additions & 0 deletions Source/IGListKit/Internal/IGListAdapter+UICollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<UICollectionViewDelegate> collectionViewDelegate = self.collectionViewDelegate;
Expand Down

0 comments on commit b22a10e

Please sign in to comment.