Summary:
* Issue: Calling `[UICollectionView layoutAttributesForSupplementaryElementOfKind...]` with an indexPath that doesn't have a supplimentary view.
* Cause: `IGListCollectionViewLayout` always returns a non-nil `UICollectionViewLayoutAttributes` when calling `layoutAttributesForSupplementaryViewOfKind` which tells the `UICollectionView` that it's fair game to ask the dataSource for a supplementary view at the indexPath. But when it does, the section controller could return nil, which throws an expection.
In the Apple docs about `[UICollectionViewDataSource collectionView:viewForSupplementaryElementOfKind:atIndexPath:]`
> This method must always return a valid view object. If you do not want a supplementary view in a particular case, your layout object should not create the attributes for that view.
https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/1618037-collectionview?language=objc
* Fix: Just like `UICollectionViewFlowLayout`, if the supplementary view size is empty, lets return a nil attribute.
Reviewed By: Ziewvater
Differential Revision: D17326461
fbshipit-source-id: 507e98f43e951216cf2eafe2449f87df25439e11
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
Summary:
* Currently, we invalidate the entire layout whenever we make any updates, like inserting new rows at the bottom.
* This is one of the most common causes of frame drop on feed, so let's allow partial invalidation based on the minimum modified section.
* For example, if we delete section 10, move section 4, and insert section 12, we would re-calculate the layout starting at section 4.
* This gets us the majority of the performance gains and it's relatively simple. In the future, we can make further optimizations, like 1) index path level invalidation and 2) finding the smallest modified index path whose properties (ex: size) have actually changed.
Reviewed By: rnystrom
Differential Revision: D6510140
fbshipit-source-id: 6ff1766b400c5aa82abc29ae76ab96660c3bb106
Summary:
**Changes occurred only for the IGListCollectionViewLayout.**
**Specifically:**
1. Harnessed the hardcore to the fact that it is possible to use only headers.
2. Assertions removed
3. Caching for layout of attributes of footers
4. Implemented the location of the footers in any orientation scroll
Issue fixed: #898
I need this enhancement ASAP 🙏
**Example:**
Footers with user comments count

- [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)
- [x] I updated example project with implemented feature
Closes https://github.com/Instagram/IGListKit/pull/1017
Reviewed By: jeremycohen
Differential Revision: D6385893
Pulled By: rnystrom
fbshipit-source-id: 5f1bad5655d2df321f8c71496aa797ac8e3d226a
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
Summary:
Fixed situation when cells with small height don't intersect with the _Rect_ and stop the enumeration that cause empty spaces in _collectionView_.
Issue fixed: # [680](https://github.com/Instagram/IGListKit/issues/680)
- [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/684
Differential Revision: D4929315
Pulled By: rnystrom
fbshipit-source-id: 4437df21772697a9a6421d213f4fed7b8470371b
Summary:
Making it simpler to setup tests w/ default config and objects. Less LoC in tests, lower setup cost when creating new test suites.
Should I changelog?
Issue fixed: #183
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
Closes https://github.com/Instagram/IGListKit/pull/678
Differential Revision: D4921633
Pulled By: rnystrom
fbshipit-source-id: fb4d08acb6ed0ba885cf56ce147f70b304301ff1
Summary:
Simple find and replace for `waitForExpectationsWithTimeout:15` and `waitForExpectationsWithTimeout:16`
Issue fixed: #669
- [ ] All tests pass. Demo project builds and runs.
- [ ] I added tests, an experiment, or detailed why my change isn't tested.
- [ ] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [ ] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/670
Differential Revision: D4915711
Pulled By: rnystrom
fbshipit-source-id: 7afd990cd5d18844ec1da08c5335f7138feb0b87
Summary: There's a small crash showing up when requesting an index path that doesn't exist. It's totally valid that this could be requested from a product and not the infra. Should fail gracefully.
Differential Revision: D4911349
fbshipit-source-id: eee8891cf9400b3c3cd5539e839296f393f82354
Summary:
[IGListCollectionViewLayout]: handle float number fraction part for layout.
When width of item is a float number with non-zero fraction part.
After integer scaled, it might add up smaller or bigger than maxWidth.
Ex with 6 items with 13 padding on each side
1. iPhone 7, maxWidth = 349, scaledItemWidth = 58 -> 58 * 6 = 348, which is smaller than 349
-> this can cause issue where is extra one line at end
2. iPone 7 plus, maxWidth = 388, scaledItemWidth = 64.6667 -> 64.6667 * 6 = 388.0002, which is bigger than 388
-> this can cause issue where last item is mistakenly shifted to next row
To fix it, add epsilon = 1 to allow some error range
Also add stretchToEdge BOOL flag to handle case 1 to decide whether to strech the width of last item.
Reviewed By: ryanolsonk, jessesquires
Differential Revision: D4720156
fbshipit-source-id: 765f6b13b7d601394d65788c30ae69ac1b37c3f2
Summary: [IGListCollectionViewLayout]: fix a bug which caused double inset being applied when having non-zero left contentInset.
Reviewed By: jessesquires
Differential Revision: D4692870
fbshipit-source-id: 1a1a3ccf944a83fea3a706b83f54293346b35c5a
Summary:
Fixes internally reported issue where the layout was new lining a section that had proper width math. Also, when inset sections were all on the same line, the max height added inset for each section, causing the newline to be too low.
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
Closes https://github.com/Instagram/IGListKit/pull/522
Reviewed By: jessesquires
Differential Revision: D4655554
Pulled By: rnystrom
fbshipit-source-id: 5e759451e285ccd636ed59dcee0777ce590797ad
Summary:
Working on porting our collection view layout to IGListKit. I'm doing this because its a solid layout, and we just finished preparing it to work with inline sections. It is designed to work in tandem with IGListKit, so we're adding it.
This is still a WIP as I add more tests, but I'd love as much feedback as possible.
Aside from the glob of header documentation, this has the following features:
- Infinite sections that each have infinite items. Sections and items can fall inline. When they break the width of their container they will fall on the next row.
- Sections can have their own insets, line spacing, and interitem spacing.
- Sticky header support! When you use headers, it will always newline the section.
- Maximum width with a border decoration view
- Use this to pinch in your content on larger devices
Followup to #423
- [ ] ~~Move decoration view support to delegate~~ removed
- [x] Unit test changing [top y sticky inset](https://coveralls.io/builds/9977284/source?filen
Closes https://github.com/Instagram/IGListKit/pull/484
Differential Revision: D4547760
Pulled By: rnystrom
fbshipit-source-id: 879e2da16eb78bb6a90967e77d9ad0bbf7c69594
Summary:
Working on porting our collection view layout to IGListKit. I'm doing this because its a solid layout, and we just finished preparing it to work with inline sections. It is designed to work in tandem with IGListKit, so we're adding it.
This is still a WIP as I add more tests, but I'd love as much feedback as possible.
Aside from the glob of header documentation, this has the following features:
- Infinite sections that each have infinite items. Sections and items can fall inline. When they break the width of their container they will fall on the next row.
- Sections can have their own insets, line spacing, and interitem spacing.
- Sticky header support! When you use headers, it will always newline the section.
- Maximum width with a border decoration view
- Use this to pinch in your content on larger devices
Followup to #423
- [ ] ~~Move decoration view support to delegate~~ removed
- [x] Unit test changing [top y sticky inset](https://coveralls.io/builds/9977284/source?filen
Closes https://github.com/Instagram/IGListKit/pull/450
Reviewed By: jessesquires
Differential Revision: D4521797
Pulled By: rnystrom
fbshipit-source-id: 20b36ae573d38ca3125a6f3d5faec181c290ab94