Skip to content
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

Added object to single section selection delegate callback #397

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@

The changelog for `IGListKit`. Also see the [releases](https://github.com/instagram/IGListKit/releases) on GitHub.

3.0.0 (**upcoming release**)
-----

This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit/milestone/3).

### Breaking Changes

- Updated `didSelect` delegate call in `IGListSingleSectionControllerDelegate` to include object. [Sherlouk](https://github.com/Sherlouk) [(#397)](https://github.com/Instagram/IGListKit/pull/397)

```objc
// OLD
- (void)didSelectSingleSectionController:(IGListSingleSectionController *)sectionController;

// NEW
- (void)didSelectSectionController:(IGListSingleSectionController *)sectionController
withObject:(id)object;
```

2.2.0
-----

This release closes the [2.2.0 milestone](https://github.com/Instagram/IGListKit/milestone/4).

### Enhancements

### Fixes

- Fix bug where emptyView's hidden status is not updated after the number of items is changed with `insertInSectionController:atIndexes:` or related methods. [Peter Edmonston](https://github.com/edmonston) [(#395)](https://github.com/Instagram/IGListKit/pull/395)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ final class SingleSectionStoryboardViewController: UIViewController, IGListAdapt
return sectionController
}

func emptyView(for listAdapter: IGListAdapter) -> UIView? {
return nil
}
func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }

// MARK: - IGListSingleSectionControllerDelegate

func didSelect(_ sectionController: IGListSingleSectionController) {
func didSelect(_ sectionController: IGListSingleSectionController, with object: Any) {
let section = adapter.section(for: sectionController) + 1
let alert = UIAlertController(title: "Section \(section) was selected \u{1F389}", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: .default, handler: nil))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ final class SingleSectionViewController: UIViewController, IGListAdapterDataSour

// MARK: - IGListSingleSectionControllerDelegate

func didSelect(_ sectionController: IGListSingleSectionController) {
func didSelect(_ sectionController: IGListSingleSectionController, with object: Any) {
let section = adapter.section(for: sectionController) + 1
let alert = UIAlertController(title: "Section \(section) was selected \u{1F389}", message: nil, preferredStyle: .alert)
let alert = UIAlertController(title: "Section \(section) was selected \u{1F389}",
message: "Cell Object: " + String(describing: object),
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
Expand Down
4 changes: 3 additions & 1 deletion Source/IGListSingleSectionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ typedef CGSize (^IGListSingleSectionCellSizeBlock)(id item, id<IGListCollectionC
Tells the delegate that the section controller was selected.

@param sectionController The section controller that was selected.
@param object The model for the given section.
*/
- (void)didSelectSingleSectionController:(IGListSingleSectionController *)sectionController;
- (void)didSelectSectionController:(IGListSingleSectionController *)sectionController
withObject:(id)object;

@end

Expand Down
2 changes: 1 addition & 1 deletion Source/IGListSingleSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (void)didUpdateToObject:(id)object {
}

- (void)didSelectItemAtIndex:(NSInteger)index {
[self.selectionDelegate didSelectSingleSectionController:self];
[self.selectionDelegate didSelectSectionController:self withObject:self.item];
}

@end
2 changes: 1 addition & 1 deletion Tests/IGListSingleSectionControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ - (void)test_whenSelected_thatDelegateReceivesEvent {
IGListSingleSectionController *section = [self.adapter sectionControllerForObject:self.dataSource.objects.firstObject];
id mockDelegate = [OCMockObject mockForProtocol:@protocol(IGListSingleSectionControllerDelegate)];
section.selectionDelegate = mockDelegate;
[[mockDelegate expect] didSelectSingleSectionController:section];
[[mockDelegate expect] didSelectSectionController:section withObject:self.dataSource.objects.firstObject];
[self.adapter collectionView:self.collectionView didSelectItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
[mockDelegate verify];
}
Expand Down