2017-02-11 01:58:52 +00:00
|
|
|
/**
|
2018-11-01 17:56:41 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-02-11 01:58:52 +00:00
|
|
|
*
|
2018-05-01 21:33:50 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-02-11 01:58:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
|
|
|
|
|
|
#import <IGListKit/IGListCollectionViewLayout.h>
|
|
|
|
|
|
2017-03-17 19:26:08 +00:00
|
|
|
#import "IGListCollectionViewLayoutInternal.h"
|
2017-02-11 01:58:52 +00:00
|
|
|
#import "IGLayoutTestDataSource.h"
|
|
|
|
|
#import "IGLayoutTestItem.h"
|
|
|
|
|
#import "IGLayoutTestSection.h"
|
2017-04-20 21:35:26 +00:00
|
|
|
#import "IGListTestHelpers.h"
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
@interface IGListCollectionViewLayoutTests : XCTestCase
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) IGListCollectionViewLayout *layout;
|
|
|
|
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
|
|
|
|
@property (nonatomic, strong) IGLayoutTestDataSource *dataSource;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static const CGRect kTestFrame = (CGRect){{0, 0}, {100, 100}};
|
|
|
|
|
|
|
|
|
|
@implementation IGListCollectionViewLayoutTests
|
|
|
|
|
|
|
|
|
|
- (UICollectionViewCell *)cellForSection:(NSInteger)section item:(NSInteger)item {
|
2017-04-20 21:35:26 +00:00
|
|
|
return [self.collectionView cellForItemAtIndexPath:genIndexPath(section, item)];
|
2017-02-11 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UICollectionReusableView *)headerForSection:(NSInteger)section {
|
2017-04-20 21:35:26 +00:00
|
|
|
return [self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:genIndexPath(section, 0)];
|
2017-02-11 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
- (UICollectionReusableView *)footerForSection:(NSInteger)section {
|
|
|
|
|
return [self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionFooter atIndexPath:genIndexPath(section, 0)];
|
|
|
|
|
}
|
|
|
|
|
|
Show header when section item is empty
Summary:
Issue fixed: #1117
I adding a new constructor for making a `IGListCollectionViewLayout` instance that can always show sticky header although section data is empty.
It's working well and [this is demo project](https://github.com/marcuswu0814/IGListKit_ShowStickyHeaderWhenDataEmpty).
Bug I'm not sure is any good way to let this much more readability. Is there any good advice?
```objc
const CGRect headerBounds = (self.scrollDirection == UICollectionViewScrollDirectionVertical) ?
CGRectMake(insets.left,
(itemCount == 0) ? CGRectGetMaxY(rollingSectionBounds) : CGRectGetMinY(rollingSectionBounds) - headerSize.height,
paddedLengthInFixedDirection,
headerSize.height) :
CGRectMake((itemCount == 0) ? CGRectGetMaxX(rollingSectionBounds) : CGRectGetMinX(rollingSectionBounds) - headerSize.width,
insets.top,
headerSize.width,
paddedLengthInFixedDirection);
```
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/1129
Differential Revision: D7551628
Pulled By: rnystrom
fbshipit-source-id: a60b65a92efcea5175c86aaed1de02686ea6d20a
2018-04-09 15:28:05 +00:00
|
|
|
- (void)setUpWithStickyHeaders:(BOOL)sticky showHeaderWhenEmpty:(BOOL)showHeaderWhenEmpty {
|
|
|
|
|
self.layout = [[IGListCollectionViewLayout alloc] initWithStickyHeaders:YES topContentInset:0 stretchToEdge:NO];
|
|
|
|
|
self.layout.showHeaderWhenEmpty = showHeaderWhenEmpty;
|
|
|
|
|
[self setUpCollectionViewAndDataSource:kTestFrame];
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)setUpWithStickyHeaders:(BOOL)sticky topInset:(CGFloat)inset {
|
2017-03-17 19:26:10 +00:00
|
|
|
[self setUpWithStickyHeaders:sticky topInset:inset stretchToEdge:NO];
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
- (void)setUpWithStickyHeaders:(BOOL)sticky topInset:(CGFloat)inset testFrame:(CGRect)testFrame {
|
|
|
|
|
[self setUpWithStickyHeaders:sticky scrollDirection:UICollectionViewScrollDirectionVertical topInset:inset stretchToEdge:NO testFrame:testFrame];
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
- (void)setUpWithStickyHeaders:(BOOL)sticky topInset:(CGFloat)inset stretchToEdge:(BOOL)stretchToEdge {
|
2017-11-21 20:39:09 +00:00
|
|
|
[self setUpWithStickyHeaders:sticky scrollDirection:UICollectionViewScrollDirectionVertical topInset:inset stretchToEdge:stretchToEdge testFrame:kTestFrame];
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
- (void)setUpWithStickyHeaders:(BOOL)sticky scrollDirection:(UICollectionViewScrollDirection)scrollDirection topInset:(CGFloat)inset stretchToEdge:(BOOL)stretchToEdge testFrame:(CGRect)testFrame {
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
self.layout = [[IGListCollectionViewLayout alloc] initWithStickyHeaders:sticky scrollDirection:scrollDirection topContentInset:inset stretchToEdge:stretchToEdge];
|
Show header when section item is empty
Summary:
Issue fixed: #1117
I adding a new constructor for making a `IGListCollectionViewLayout` instance that can always show sticky header although section data is empty.
It's working well and [this is demo project](https://github.com/marcuswu0814/IGListKit_ShowStickyHeaderWhenDataEmpty).
Bug I'm not sure is any good way to let this much more readability. Is there any good advice?
```objc
const CGRect headerBounds = (self.scrollDirection == UICollectionViewScrollDirectionVertical) ?
CGRectMake(insets.left,
(itemCount == 0) ? CGRectGetMaxY(rollingSectionBounds) : CGRectGetMinY(rollingSectionBounds) - headerSize.height,
paddedLengthInFixedDirection,
headerSize.height) :
CGRectMake((itemCount == 0) ? CGRectGetMaxX(rollingSectionBounds) : CGRectGetMinX(rollingSectionBounds) - headerSize.width,
insets.top,
headerSize.width,
paddedLengthInFixedDirection);
```
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/1129
Differential Revision: D7551628
Pulled By: rnystrom
fbshipit-source-id: a60b65a92efcea5175c86aaed1de02686ea6d20a
2018-04-09 15:28:05 +00:00
|
|
|
[self setUpCollectionViewAndDataSource:testFrame];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setUpCollectionViewAndDataSource:(CGRect)testFrame {
|
2017-02-11 01:58:52 +00:00
|
|
|
self.dataSource = [IGLayoutTestDataSource new];
|
2017-11-21 20:39:09 +00:00
|
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:testFrame collectionViewLayout:self.layout];
|
2017-02-11 01:58:52 +00:00
|
|
|
self.collectionView.dataSource = self.dataSource;
|
|
|
|
|
self.collectionView.delegate = self.dataSource;
|
|
|
|
|
[self.dataSource configCollectionView:self.collectionView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)tearDown {
|
|
|
|
|
[super tearDown];
|
|
|
|
|
|
|
|
|
|
self.collectionView = nil;
|
|
|
|
|
self.layout = nil;
|
|
|
|
|
self.dataSource = nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)prepareWithData:(NSArray<IGLayoutTestSection *> *)data {
|
|
|
|
|
self.dataSource.sections = data;
|
|
|
|
|
[self.collectionView reloadData];
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenEmptyData_thatContentSizeZero {
|
|
|
|
|
[self setUpWithStickyHeaders:YES topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:nil];
|
|
|
|
|
|
|
|
|
|
// check so that nil messaging doesn't default size to 0
|
|
|
|
|
XCTAssertEqual(self.layout.collectionView, self.collectionView);
|
|
|
|
|
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, self.collectionView.contentSize));
|
|
|
|
|
}
|
|
|
|
|
|
Show header when section item is empty
Summary:
Issue fixed: #1117
I adding a new constructor for making a `IGListCollectionViewLayout` instance that can always show sticky header although section data is empty.
It's working well and [this is demo project](https://github.com/marcuswu0814/IGListKit_ShowStickyHeaderWhenDataEmpty).
Bug I'm not sure is any good way to let this much more readability. Is there any good advice?
```objc
const CGRect headerBounds = (self.scrollDirection == UICollectionViewScrollDirectionVertical) ?
CGRectMake(insets.left,
(itemCount == 0) ? CGRectGetMaxY(rollingSectionBounds) : CGRectGetMinY(rollingSectionBounds) - headerSize.height,
paddedLengthInFixedDirection,
headerSize.height) :
CGRectMake((itemCount == 0) ? CGRectGetMaxX(rollingSectionBounds) : CGRectGetMinX(rollingSectionBounds) - headerSize.width,
insets.top,
headerSize.width,
paddedLengthInFixedDirection);
```
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/1129
Differential Revision: D7551628
Pulled By: rnystrom
fbshipit-source-id: a60b65a92efcea5175c86aaed1de02686ea6d20a
2018-04-09 15:28:05 +00:00
|
|
|
- (void)test_whenSectionDataIsEmpty_thatStickyHeaderStillShow {
|
|
|
|
|
[self setUpWithStickyHeaders:YES showHeaderWhenEmpty:YES];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:nil],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:20
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:nil],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:30
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:nil]]];
|
|
|
|
|
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 0, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 10, 100, 20);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:2].frame, 0, 30, 100, 30);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenSectionDataIsEmpty_thatStickyHeaderShouldBeHidden {
|
|
|
|
|
[self setUpWithStickyHeaders:YES showHeaderWhenEmpty:NO];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}]
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:20
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:nil],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:20
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]]
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 0, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 0, 0, 0);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:2].frame, 0, 20, 100, 20);
|
|
|
|
|
}
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
- (void)test_whenLayingOutCellsVertically_withHeaderHeight_withLineSpacing_withInsets_thatFramesCorrect {
|
2017-02-11 01:58:52 +00:00
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
const CGFloat headerHeight = 10;
|
|
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 120);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 10, 10, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 10, 20, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 40, 85, 20);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 10, 75, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 85, 85, 30);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
- (void)test_whenLayingOutCellsVertically_withFooterHeight_withLineSpacing_withInsets_thatFramesCorrect {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 testFrame:CGRectMake(0, 0, 100, 150)];
|
|
|
|
|
|
|
|
|
|
const CGFloat footerHeight = 10;
|
|
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 120);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 10, 10, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 30, 85, 20);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:0].frame, 10, 50, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 75, 85, 30);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:1].frame, 10, 105, 85, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenLayingOutCellsVertically_withHeaderHeight_withFooterHeight_withLineSpacing_withInsets_thatFramesCorrect {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 testFrame:CGRectMake(0, 0, 100, 150)];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
const CGFloat headerHeight = 10;
|
2017-11-21 20:39:09 +00:00
|
|
|
const CGFloat footerHeight = 10;
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
2017-11-21 20:39:09 +00:00
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 140);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 10, 10, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 10, 20, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 40, 85, 20);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:0].frame, 10, 60, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 10, 85, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 95, 85, 30);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:1].frame, 10, 125, 85, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenLayingOutCellsHorizontally_withHeaderHeight_withLineSpacing_withInsets_thatFramesCorrect {
|
|
|
|
|
[self setUpWithStickyHeaders:NO scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:0 stretchToEdge:NO testFrame:kTestFrame];
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
const CGFloat headerHeight = 10;
|
|
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.width, 140);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 10, 10, 10, 85);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 20, 10, 45, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 20, 20, 45, 20);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 80, 10, 10, 85);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 90, 10, 45, 30);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 20:39:09 +00:00
|
|
|
- (void)test_whenLayingOutCellsHorizontally_withFooterHeight_withLineSpacing_withInsets_thatFramesCorrect {
|
|
|
|
|
[self setUpWithStickyHeaders:NO scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:0 stretchToEdge:NO testFrame:kTestFrame];
|
|
|
|
|
|
|
|
|
|
const CGFloat footerHeight = 10;
|
|
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:footerHeight
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {45, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.width, 75);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:0].frame, 60, 10, 10, 85);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 10, 10, 45, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 20, 45, 20);
|
|
|
|
|
IGAssertEqualFrame([self footerForSection:1].frame, 60, 10, 10, 85);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 55, 45, 30);
|
|
|
|
|
}
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)test_whenUsingStickyHeaders_withSimulatedScrolling_thatYPositionsAdjusted {
|
|
|
|
|
[self setUpWithStickyHeaders:YES topInset:10];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 20}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 30}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 30}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 30}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
// scroll header 0 halfway
|
|
|
|
|
self.collectionView.contentOffset = CGPointMake(0, 5);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 15, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 50, 100, 10);
|
|
|
|
|
|
|
|
|
|
// scroll header 0 off and 1 up
|
|
|
|
|
self.collectionView.contentOffset = CGPointMake(0, 45);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 40, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 55, 100, 10);
|
|
|
|
|
}
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
- (void)test_whenUsingStickyHeaders_withSimulatedHorizontalScrolling_thatXPositionsAdjusted {
|
2017-11-21 20:39:09 +00:00
|
|
|
[self setUpWithStickyHeaders:YES scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:10 stretchToEdge:NO testFrame:kTestFrame];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {20, 100}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {20, 100}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 100}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 100}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 100}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
|
|
|
|
|
// scroll header 0 halfway
|
|
|
|
|
self.collectionView.contentOffset = CGPointMake(5, 0);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 15, 0, 10, 100);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 50, 0, 10, 100);
|
|
|
|
|
|
|
|
|
|
// scroll header 0 off and 1 left
|
|
|
|
|
self.collectionView.contentOffset = CGPointMake(45, 0);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 40, 0, 10, 100);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 55, 0, 10, 100);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)test_whenAdjustingTopYInset_withVaryingHeaderHeights_thatYPositionsUpdated {
|
|
|
|
|
[self setUpWithStickyHeaders:YES topInset:10];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 30}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 40}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 50}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
// scroll header 0 off and 1 up
|
|
|
|
|
self.collectionView.contentOffset = CGPointMake(0, 35);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 30, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 45, 100, 10);
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
self.layout.stickyHeaderYOffset = -10;
|
2017-02-11 01:58:52 +00:00
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 30, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 40, 100, 10);
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
self.layout.stickyHeaderYOffset = 10;
|
2017-02-11 01:58:52 +00:00
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 30, 100, 10);
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 0, 55, 100, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenItemsSmallerThanContainerWidth_with0Insets_with0LineSpacing_with0Interitem_thatItemsFitSameRow {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 66);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 33, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:2].frame, 66, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 0, 33, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenItemsSmallerThanContainerWidth_withHalfPointItemSpacing_with0Insets_with0LineSpacing_thatItemsFitSameRow {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0.5
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
2017-03-17 19:26:08 +00:00
|
|
|
const CGRect rect = IGListRectIntegralScaled(CGRectMake(33.5, 0, 33, 33));
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
2017-02-11 01:58:52 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:2].frame, 67, 0, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
- (void)test_whenItemsLargerThanContainerHeight_withHorizontalScrolling_with5PointItemSpacing_with0Insets_with10PointLineSpacing_thatItemsBumpToNewColumn {
|
2017-11-21 20:39:09 +00:00
|
|
|
[self setUpWithStickyHeaders:NO scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:0 stretchToEdge:NO testFrame:kTestFrame];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:10
|
|
|
|
|
interitemSpacing:5
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.width, 76);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 0, 38, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:2].frame, 43, 0, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenSectionsSmallerThanContainerWidth_withVerticalScrolling_with0ItemSpacing_with0Insets_with0LineSpacing_thatSectionsFitSameRow {
|
2017-02-11 01:58:52 +00:00
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 33, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 66, 0, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
- (void)test_whenSectionsSmallerThanContainerHeight_withHorizontalScrolling_with0ItemSpacing_with0Insets_with0LineSpacing_thatSectionsFitSameColumn {
|
2017-11-21 20:39:09 +00:00
|
|
|
[self setUpWithStickyHeaders:NO scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:0 stretchToEdge:NO testFrame:kTestFrame];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.width, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 0, 33, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 0, 66, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)test_whenSectionsSmallerThanContainerWidth_withHalfPointSpacing_with0Insets_with0LineSpacing_thatSectionsFitSameRow {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0.5
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0.5
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0.5
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
2017-03-17 19:26:08 +00:00
|
|
|
const CGRect rect = IGListRectIntegralScaled(CGRectMake(33.5, 0, 33, 33));
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
2017-02-11 01:58:52 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 67, 0, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenSectionsSmallerThanContainerWidth_with0ItemSpacing_withMiddleItemHasInsets_with0LineSpacing_thatNextSectionSnapsBelow {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsMake(10, 10, 10, 10)
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {13, 50}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 103);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 43, 10, 13, 50);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 66, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:3 item:0].frame, 0, 70, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenSectionBustingRow_thatNewlineAppliesSectionInset {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsMake(10, 10, 5, 5)
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 50}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 98);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 43, 85, 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenSectionsSmallerThanWidth_withSectionHeader_thatHeaderCausesNewline {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 76);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 0, 43, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
- (void)test_whenSectionsSmallerThanHeight_withHorizontalScrolling_withSectionHeader_thatHeaderCausesNewline {
|
2017-11-21 20:39:09 +00:00
|
|
|
[self setUpWithStickyHeaders:NO scrollDirection:UICollectionViewScrollDirectionHorizontal topInset:0 stretchToEdge:NO testFrame:kTestFrame];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
Add horizontal scrolling support to IGListCollectionViewLayout
Summary:
Issue fixed: #752
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
This PR generalizes the layout logic in `IGListCollectionViewLayout.mm` to handle horizontally scrolling layouts, mainly by generalizing references to `width`, `height`, `x` and `y` to take scrolling direction into account. This changes the signature of `IGListCollectionViewLayout.init` as well as the names of a few properties, so it would be a breaking change.
I added a couple of unit tests specifically for horizontal layouts -- but held off from adding a horizontal version of *every* unit test for this class, as it would basically double the number of tests. But if you want that, just let me know and I'm happy to do it.
Also let me know if you want me to add a demo VC to the Examples project that uses this new horizontal flow layout -- I have some demo code handy (I used it for testing), but didn't want to clutter up the PR if you didn't want/need it.
Closes https://github.com/Instagram/IGListKit/pull/857
Reviewed By: ryanolsonk
Differential Revision: D5547266
Pulled By: rnystrom
fbshipit-source-id: 6094c45069fc265273d0f95c296fa78e47470384
2017-08-07 16:22:40 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.width, 76);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 43, 0, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)test_whenBatchItemUpdates_withHeaderHeight_withLineSpacing_withInsets_thatLayoutCorrectAfterUpdates {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
const CGFloat headerHeight = 10;
|
|
|
|
|
const CGFloat lineSpacing = 10;
|
|
|
|
|
const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 5, 5);
|
|
|
|
|
|
|
|
|
|
// making the view bigger so that we can check all cell frames
|
|
|
|
|
self.collectionView.frame = CGRectMake(0, 0, 100, 400);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 60}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 40}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
|
|
|
|
|
|
|
|
|
|
[self.collectionView performBatchUpdates:^{
|
|
|
|
|
self.dataSource.sections = @[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}], // reloaded
|
|
|
|
|
// deleted
|
|
|
|
|
]],
|
|
|
|
|
// moved from section 3 to 1
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 40}],
|
|
|
|
|
]],
|
|
|
|
|
// deleted section 2
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 30}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}], // inserted
|
|
|
|
|
]],
|
|
|
|
|
// inserted
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:insets
|
|
|
|
|
lineSpacing:lineSpacing
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:headerHeight
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {85, 20}],
|
|
|
|
|
]],
|
|
|
|
|
];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
[self.collectionView deleteSections:[NSIndexSet indexSetWithIndex:2]];
|
|
|
|
|
[self.collectionView insertSections:[NSIndexSet indexSetWithIndex:3]];
|
|
|
|
|
[self.collectionView moveSection:3 toSection:1];
|
2017-04-20 21:35:26 +00:00
|
|
|
[self.collectionView reloadItemsAtIndexPaths:@[genIndexPath(0, 0)]];
|
|
|
|
|
[self.collectionView deleteItemsAtIndexPaths:@[genIndexPath(0, 1)]];
|
|
|
|
|
[self.collectionView insertItemsAtIndexPaths:@[genIndexPath(2, 1)]];
|
2017-02-11 01:58:52 +00:00
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
[expectation fulfill];
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 260);
|
|
|
|
|
|
|
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 10, 10, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 10, 20, 85, 30);
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
IGAssertEqualFrame([self headerForSection:1].frame, 10, 65, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 10, 75, 85, 40);
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
IGAssertEqualFrame([self headerForSection:2].frame, 10, 130, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 10, 140, 85, 30);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:1].frame, 10, 180, 85, 10);
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
IGAssertEqualFrame([self headerForSection:3].frame, 10, 205, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:3 item:0].frame, 10, 215, 85, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:3 item:1].frame, 10, 235, 85, 20);
|
|
|
|
|
}];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
|
|
|
|
[self waitForExpectationsWithTimeout:30 handler:^(NSError * _Nullable error) {
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertNil(error);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenQueryingLayoutAttributes_withLotsOfCells_thatExactFramesFetched {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
NSMutableArray *items = [NSMutableArray new];
|
|
|
|
|
for (NSInteger i = 0; i < 1000; i++) {
|
2017-11-21 20:39:09 +00:00
|
|
|
[items addObject:[[IGLayoutTestItem alloc] initWithSize:(CGSize) {100, 20}]];
|
2017-02-11 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:items]
|
|
|
|
|
]];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
XCTAssertEqual([self.layout layoutAttributesForElementsInRect:CGRectMake(0, 500, 100, 100)].count, 5);
|
|
|
|
|
XCTAssertEqual([self.layout layoutAttributesForElementsInRect:CGRectMake(0, 0, 100, 1000)].count, 50);
|
|
|
|
|
XCTAssertEqual([self.layout layoutAttributesForElementsInRect:CGRectMake(0, 250, 100, 100)].count, 6);
|
|
|
|
|
XCTAssertEqual([self.layout layoutAttributesForElementsInRect:CGRectMake(0, 250, 100, 1)].count, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 15:11:44 +00:00
|
|
|
- (void)test_whenSecondItemDoesntIntersectRect_thatOtherAttributesExist {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
NSMutableArray *data = [NSMutableArray new];
|
|
|
|
|
for (NSInteger i = 0; i < 6; i++) {
|
|
|
|
|
[data addObject:[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
2017-11-21 20:39:09 +00:00
|
|
|
footerHeight:0
|
2017-04-21 15:11:44 +00:00
|
|
|
items:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {50, 100}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {50, 10}],
|
|
|
|
|
]]];
|
2017-04-21 15:11:44 +00:00
|
|
|
}
|
|
|
|
|
[self prepareWithData:data];
|
|
|
|
|
|
|
|
|
|
NSArray *attributes = [self.layout layoutAttributesForElementsInRect:CGRectMake(0, 50, 100, 100)];
|
|
|
|
|
NSArray *paths = [[attributes valueForKeyPath:@"indexPath"] sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
|
NSArray *expectation = @[
|
|
|
|
|
genIndexPath(0, 0),
|
|
|
|
|
genIndexPath(1, 0),
|
|
|
|
|
genIndexPath(1, 1),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// should include 2 of the 100-height items and one of the 10-height
|
|
|
|
|
XCTAssertEqualObjects(paths, expectation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenTwoConsecutiveItemsDontIntersectRect_thatOtherAttributesExist {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
NSMutableArray *data = [NSMutableArray new];
|
|
|
|
|
for (NSInteger i = 0; i < 6; i++) {
|
|
|
|
|
[data addObject:[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
2017-11-21 20:39:09 +00:00
|
|
|
footerHeight:0
|
2017-04-21 15:11:44 +00:00
|
|
|
items:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 100}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {30, 10}],
|
|
|
|
|
]]];
|
2017-04-21 15:11:44 +00:00
|
|
|
}
|
|
|
|
|
[self prepareWithData:data];
|
|
|
|
|
|
|
|
|
|
NSArray *attributes = [self.layout layoutAttributesForElementsInRect:CGRectMake(0, 50, 100, 100)];
|
|
|
|
|
NSArray *paths = [[attributes valueForKeyPath:@"indexPath"] sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
|
|
|
|
|
|
NSArray *expectation = @[
|
|
|
|
|
genIndexPath(0, 0),
|
|
|
|
|
genIndexPath(1, 0),
|
|
|
|
|
genIndexPath(1, 1),
|
|
|
|
|
genIndexPath(1, 2),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// should include 2 of the 100-height items and two of the 10-height
|
|
|
|
|
XCTAssertEqualObjects(paths, expectation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
- (void)test_whenChangingBoundsSize_withItemsThatNewlineAfterChange_thatLayoutShiftsItems {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {33, 33}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-02-11 01:58:52 +00:00
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 33, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 66, 0, 33, 33);
|
|
|
|
|
|
|
|
|
|
// can no longer fit 3 items in one section
|
|
|
|
|
self.collectionView.frame = CGRectMake(0, 0, 70, 100);
|
|
|
|
|
[self.collectionView layoutIfNeeded];
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 66);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 33, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 0, 33, 33, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenCollectionViewContentInset_withFullWidthItems_thatItemsPinchedIn {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
self.collectionView.contentInset = UIEdgeInsetsMake(0, 30, 0, 30);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:10
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {40, 10}],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {40, 20}],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 40);
|
2017-03-11 02:50:59 +00:00
|
|
|
IGAssertEqualFrame([self headerForSection:0].frame, 0, 0, 40, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 10, 40, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 0, 20, 40, 20);
|
2017-02-11 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
- (void)test_whenItemsAddedWidthSmallerThanWidth_DifferenceSmallerThanEpsilon {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 stretchToEdge:YES];
|
|
|
|
|
|
|
|
|
|
const CGSize size = CGSizeMake(33, 33);
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:size],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:size],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:size],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 33, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:2].frame, 66, 0, 34, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenItemsAddedWidthSmallerThanWidth_DifferenceBiggerThanEpsilon {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 stretchToEdge:YES];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(33, 33)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(65, 33)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 33, 33);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 33, 0, 65, 33);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenItemsAddedWithBiggerThanWidth_DifferenceSmallerThanEpsilon {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(50, 50)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(51, 50)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 50, 50);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 50, 0, 51, 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenItemsAddedWithBiggerThanWidth_DifferenceBiggerThanEpsilon {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(50, 50)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(52, 50)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-17 19:26:10 +00:00
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 50, 50);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 0, 50, 52, 50);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-05 00:08:00 +00:00
|
|
|
- (void)test_ {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
self.collectionView.frame = CGRectMake(0, 0, 414, 736);
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-05 00:08:00 +00:00
|
|
|
NSMutableArray *data = [NSMutableArray new];
|
|
|
|
|
for (NSInteger i = 0; i < 6; i++) {
|
|
|
|
|
[data addObject:[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsMake(1, 1, 1, 1)
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
2017-11-21 20:39:09 +00:00
|
|
|
footerHeight:0
|
2017-03-05 00:08:00 +00:00
|
|
|
items:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestItem alloc] initWithSize:(CGSize) {136, 136}],
|
|
|
|
|
]]];
|
2017-03-05 00:08:00 +00:00
|
|
|
}
|
|
|
|
|
[self prepareWithData:data];
|
2017-04-19 19:50:20 +00:00
|
|
|
|
2017-03-05 00:08:00 +00:00
|
|
|
XCTAssertEqual(self.collectionView.contentSize.height, 276);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 1, 1, 136, 136);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:1 item:0].frame, 139, 1, 136, 136);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:2 item:0].frame, 277, 1, 136, 136);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:3 item:0].frame, 1, 139, 136, 136);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:4 item:0].frame, 139, 139, 136, 136);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:5 item:0].frame, 277, 139, 136, 136);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-19 15:12:29 +00:00
|
|
|
- (void)test_whenQueryingAttributes_withSectionOOB_thatReturnsNil {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 stretchToEdge:YES];
|
2017-11-21 20:39:09 +00:00
|
|
|
|
2017-04-19 15:12:29 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(33, 33)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(65, 33)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-04-20 21:35:26 +00:00
|
|
|
XCTAssertNil([self.layout layoutAttributesForItemAtIndexPath:genIndexPath(4, 0)]);
|
2017-04-19 15:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)test_whenQueryingAttributes_withItemOOB_thatReturnsNil {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0 stretchToEdge:YES];
|
2017-11-21 20:39:09 +00:00
|
|
|
|
2017-04-19 15:12:29 +00:00
|
|
|
[self prepareWithData:@[
|
2017-11-21 20:39:09 +00:00
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(33, 33)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(65, 33)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
2017-04-20 21:35:26 +00:00
|
|
|
XCTAssertNil([self.layout layoutAttributesForItemAtIndexPath:genIndexPath(0, 4)]);
|
2017-04-19 15:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-15 17:19:20 +00:00
|
|
|
- (void)test_whenUpdatingSizes_thatLayoutUpdates {
|
|
|
|
|
[self setUpWithStickyHeaders:NO topInset:0];
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(10, 10)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(10, 10)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 10, 10);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 0, 10, 10);
|
|
|
|
|
|
|
|
|
|
[self prepareWithData:@[
|
|
|
|
|
[[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero
|
|
|
|
|
lineSpacing:0
|
|
|
|
|
interitemSpacing:0
|
|
|
|
|
headerHeight:0
|
|
|
|
|
footerHeight:0
|
|
|
|
|
items:@[
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(20, 20)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(20, 20)],
|
|
|
|
|
[[IGLayoutTestItem alloc] initWithSize:CGSizeMake(20, 20)],
|
|
|
|
|
]],
|
|
|
|
|
]];
|
|
|
|
|
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 20, 20);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:1].frame, 20, 0, 20, 20);
|
|
|
|
|
IGAssertEqualFrame([self cellForSection:0 item:2].frame, 40, 0, 20, 20);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-11 01:58:52 +00:00
|
|
|
@end
|