Skip to content

Commit

Permalink
Refine and add code coverage for trait collection in collection context
Browse files Browse the repository at this point in the history
Summary:
Now that the inconsistency exception is being wrapped up, I'm going to move forward with a public release some more. I'm going to go through and make sure everything is up-to-date in the GitHub repo.

This diff adds code coverage to the new trait collection exposure API in `IGListCollectionContext`. It also adds document-generating compatible commenting and positions it at a more appropriate ordering in the header.

Reviewed By: zats

Differential Revision: D51146049

fbshipit-source-id: 2d7ecc8fa042006ef4fd70451b9ab7ba6d0a66bb
  • Loading branch information
TimOliver authored and facebook-github-bot committed Nov 13, 2023
1 parent b7f3097 commit a4bae43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ - (CGSize)containerSize {
return self.collectionView.bounds.size;
}

- (UITraitCollection *_Nullable)traitCollection {
- (UITraitCollection *)traitCollection {
return self.collectionView.traitCollection;
}

Expand Down
7 changes: 5 additions & 2 deletions Source/IGListKit/IGListCollectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(ListCollectionContext)
@protocol IGListCollectionContext <NSObject>

@property (nonatomic, nullable, readonly) UITraitCollection *traitCollection;

/**
The size of the collection view. You can use this for sizing cells.
*/
Expand All @@ -53,6 +51,11 @@ NS_SWIFT_NAME(ListCollectionContext)
*/
@property (nonatomic, readonly) CGPoint containerContentOffset;

/**
The trait collection of the collection view.
*/
@property (nonatomic, nullable, readonly) UITraitCollection *traitCollection;

/**
The current scrolling traits of the underlying collection view.
*/
Expand Down
6 changes: 6 additions & 0 deletions Tests/IGListAdapterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,12 @@ - (void)test_whenSupplementarySourceReturnsNegativeSize_thatAdapterReturnsZero {
XCTAssertEqual(size.height, 0.0);
}

- (void)test_whenQueryingTraitCollection_thatMatchesCollectionView {
self.dataSource.objects = @[@2];
[self.adapter reloadDataWithCompletion:nil];
XCTAssertEqual(self.adapter.traitCollection, self.collectionView.traitCollection);
}

- (void)test_whenQueryingContainerInset_thatMatchesCollectionView {
self.dataSource.objects = @[@2];
[self.adapter reloadDataWithCompletion:nil];
Expand Down

0 comments on commit a4bae43

Please sign in to comment.