Summary:
The collection view layout here should not be accessing the data source directly but instead asking the collection view for the number of sections and number of items. This is because the collection view holds an internal cache and if there is a discrepancy between when the collection view cache and the data source, preparing the layout will crash the app because we will send a layout down to the collection view with a items that might not exist in the collection view's cache but exist in the data source.
This diff adds an experiment to see the impact of fixing this check so that when we prepare layouts we don't ask the data source directly but ask the collection view instead. The collection view will then update it's cache and check the data source so it does not crash when we prepare a layout.
```
NSInternalInconsistencyException at __45-[UICollectionViewData validateLayoutInRect:]_block_invoke:
UICollectionView received layout attributes for a cell with an index path that does not exist:
<NSIndexPath: 0xc198a8c3ea391fbb> {length = 2, path = 4 - 0}
```
Reviewed By: lorixx
Differential Revision: D15830610
fbshipit-source-id: f3dae3e87c55b86c3b686309c1144ccfff1375bf
Summary:
Issue fixed: #1235
- [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)
Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1236
Reviewed By: lorixx
Differential Revision: D12839081
Pulled By: rnystrom
fbshipit-source-id: 3e9e1192f16912d560d76f3730a377f303708cd7
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:
Issue fixed: #1141
This is a set of minimum fixes for Xcode 9.3 rather than #1142. Much smaller diffs 😃
The changes here were done by Xcode's FixIt. See also https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265-SW5.
> Platform Dependencies
>
> OS X uses several data types—NSInteger, NSUInteger,CGFloat, and CFIndex—to provide a consistent means of representing values in 32- and 64-bit environments. In a 32-bit environment, NSInteger and NSUInteger are defined as int and unsigned int, respectively. In 64-bit environments, NSInteger and NSUInteger are defined as long and unsigned long, respectively. To avoid the need to use different printf-style type specifiers depending on the platform, you can use the specifiers shown in Table 3. Note that in some cases you may have to cast the value.
- [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/1143
Differential Revision: D7551617
Pulled By: rnystrom
fbshipit-source-id: b27ebe2b1a1c93ebfd1218dc38b7621fefee2e6b
Summary:
…instead of just allocating a vanilla UICollectionViewLayoutAttributes. I'm happy to add tests here, but don't really have much of an opinion either way on whether this should have an explicit test case or not.
Issue fixed: #1134
- [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/1135
Differential Revision: D7551624
Pulled By: rnystrom
fbshipit-source-id: 930218c40b0082912454bb98bd02e7daa8257a3e
Summary: Prefix all private methods with an underscore. A private method is defined as any method not exposed via an interface or protocol. This will improve the readability of the code and hopefully reduce bugs.
Reviewed By: rnystrom
Differential Revision: D7421346
fbshipit-source-id: 536472d57ea7fd8990fe50f3e950907ca57b8e6d
Summary:
if `stickyHeader` is true, the footer could be sticky to the top
Issue fixed: #1093
- [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/1094
Differential Revision: D7246636
Pulled By: rnystrom
fbshipit-source-id: 9b7da52ab46229606b530a378c01d799767e27f2
Summary:
project:
- fix file target membership issues in framework targets and test targets
- fix private/internal header imports, which shouldn't be `<IGListKit/` apparently
- fix static analyzer errors
travis:
- always install latest swiftlint
- ~~don't cache bundler, attempts to fix #1060~~
- remove markdown link check
swiftlint:
- make script non-failing if *any* version of swiftlint is installed
- warning if incorrect version is installed
- fail if not installed
- remove `scripts/generate_ci_yaml.rb`, we can just set the config file path directly
Closes https://github.com/Instagram/IGListKit/pull/1068
Differential Revision: D6885575
Pulled By: rnystrom
fbshipit-source-id: 51b7baa73feefcea71d870c1220d0382df484199
Summary:
The current animation is the collection default animation - fade in/out: demo: https://pxl.cl/bj8R
Based on our design, we want the Shelf to be push down: demo https://pxl.cl/bj9R
1. Created **IGListCollectionViewDelegate** which inherits **UICollectionViewDelegateFlowLayout**
2. **IGListAdapter ** conforms **UICollectionViewDelegateFlowLayout**
3. add **transitionDelegate** to IGListSectionController
4. **IGFeedSectionController** sets transitionDelegate as itself and handles IGListCollectionViewDelegate methods
Reviewed By: rnystrom
Differential Revision: D6785726
fbshipit-source-id: bdf19f84fef05264ca0e082c6a326a31494a20da
Summary:
* Clarify assert message by adding item width/height
* Before: Width of item 1 in section 2 must be less than container 375 accounting for section insets {0, 0, 0, 0}
* After: Width of item 1 in section 2 (415 pt) must be less than or equal to container (375 pt) accounting for section insets {0, 0, 0, 0}
Reviewed By: rnystrom
Differential Revision: D6711829
fbshipit-source-id: be99e83fd68cd345cb6a05acdde27c8252e59650
Summary:
adopt adjustedContentInset instead of contentInset on iOS 11
- [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/1020
Reviewed By: manicakes
Differential Revision: D6513703
Pulled By: rnystrom
fbshipit-source-id: 5d718f2cb30361959ca5ba8238746427223cb5fd
Summary: * IGListCollectionViewLayout can now keep track of the minimumInvalidatedSection given individual section updates.
Reviewed By: rnystrom
Differential Revision: D6545333
fbshipit-source-id: 64c9b5ff32339299b52059a4d990a42d9e6a1af5
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:
Floating point math loses precision and so comparing two floats that are likely to only differ in the mantissa, and even then by extremely small amounts, is tricky. Exact equality often fails in these cases and asserting on exact equality is probably not necessary.
Closes https://github.com/Instagram/IGListKit/pull/828
Differential Revision: D5310575
Pulled By: rnystrom
fbshipit-source-id: f942489fbe0b2bc5f215329caac8abbae577a830
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: 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:
Issue fixed: #
- [ ] 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)
Small changes
Closes https://github.com/Instagram/IGListKit/pull/565
Differential Revision: D4728939
Pulled By: rnystrom
fbshipit-source-id: 4f0c3455f55d4c267dffe5d7ebd37a96a648ec52
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