Commit graph

15 commits

Author SHA1 Message Date
Aaron Pang
78cca5bc43 Add experiment to have the collection view layout check the collection view instead of the collection view layout [2/2]
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
2019-06-14 16:23:46 -07:00
Jordan Smith
46a124ddfe Define IGListCollectionViewLayoutCompatible to allow custom layouts to interact with IGListCollectionView
Summary: This change allows arbitrary layouts to be used in tandem with IGListCollectionView and recieve udpated section indices, by conforming to to conform IGListCollectionViewLayoutCompatible.

Reviewed By: maxoll

Differential Revision: D13671204

fbshipit-source-id: e030f413aefff71754731d1259037077ffb73959
2019-01-17 07:53:23 -08:00
Ryan Nystrom
8d8a632b67 Update MIT license language (#1272)
Summary:
Updating license language to meet FB open source standards.
Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1272

Differential Revision: D12844366

Pulled By: rnystrom

fbshipit-source-id: 27ae49ae00d963c5c012c79c5738365c232a5773
2018-11-01 10:58:46 -07:00
Ryan Nystrom
000bc36919 Relicense to MIT
Summary: Relicensing IGListKit under MIT

Reviewed By: calimarkus

Differential Revision: D7764125

fbshipit-source-id: 6c773195ef3184202725fe7f08de754f979cb83f
2018-05-01 14:50:56 -07:00
Marcus Wu
e49c94b25d 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 08:37:18 -07:00
Maxime Ollivier
f0b947cd1f expose didModifySection on IGListCollectionViewLayout
Summary: * IGListCollectionViewLayout can now keep track of the minimumInvalidatedSection given individual section updates.

Reviewed By: rnystrom

Differential Revision: D6545333

fbshipit-source-id: 64c9b5ff32339299b52059a4d990a42d9e6a1af5
2017-12-15 09:33:39 -08:00
Peter Edmonston
9e312275c3 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 09:33:30 -07:00
Robert Payne
40625f8ff9 Swift name annotations
Summary:
This adds `NS_SWIFT_NAME` annotations to all public API's to provide cleaner integration into Swift:

- Removes the need to prefix classes in Swift code, instead rely on Swift module name spacing
- Adds more argument labels to C function API's like `IGListDiff([], [], .equality)` => `ListDiff(oldArray: [], newArray: [], option: .equality)`

While this is a large API change it should be as easy as:

- Find and replace `(IGList)([^K])` to `List$2` in Xcode with a scope set to Swift
- Build and follow compiler's auto fix corrections for C API's or any missed renames

I have not updated the documentation to reflect this yet, I am totally willing to do so but before I sink that amount of time into it I wanted to see if the Instagram team is even open to this change!

- [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)
- [ ] I have updated the documentation
Closes https://github.com/Instagram/IGListKit/pull/593

Reviewed By: jessesquires

Differential Revision: D5028039

Pulled By: rnystrom

fbshipit-source-id: b473d874a1f9574e56b2ebaabd5b73d1b57d4bab
2017-05-09 14:31:28 -07:00
Bas Broek
edc38c77fe Remove @param alignment from header docs #trivial
Summary:
Issue fixed: #655

- [x] 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.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)

I've also addressed a few cases where there was no empty line between the `param`s and `return`.
Closes https://github.com/Instagram/IGListKit/pull/665

Differential Revision: D4906215

Pulled By: jessesquires

fbshipit-source-id: 5693c85eb548644b0b0e2571eea8ff4d9f706b12
2017-04-18 09:46:18 -07:00
Andrew Monshizadeh
9735d611e8 Nitpicky comment fixes
Summary:
Mainly this addresses clarity of a few comments, line breaks at weird places, and style differences within a single file.

Just comments and including JetBrains `.idea` config folder in the `gitignore`.

- [X] All tests pass. Demo project builds and runs.
- [X] I added tests, an experiment, or detailed why my change isn't tested.
- [N/A] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [N/A] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/600

Differential Revision: D4810628

Pulled By: jessesquires

fbshipit-source-id: fce445c0253f592a43045ae098e440d41c166993
2017-03-31 13:01:40 -07:00
Shiyi Zhao
24308a9881 handle float number fraction part for layout.
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
2017-03-17 12:33:34 -07:00
Yifan Peng
982ded0908 remove subclass restriction on IGListCollectionViewLayout
Summary: remove subclass restriction on IGListCollectionViewLayout, so IGListCollectionViewLayout can be subclassed to support customized layout behavior.

Reviewed By: rnystrom

Differential Revision: D4700759

fbshipit-source-id: 1a22d1b981251ae60028724ae220e49d2d37c190
2017-03-14 10:16:28 -07:00
Ryan Nystrom
e2c2d3dcec Vertical UICollectionViewLayout supporting inline sections (take 2)
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
2017-02-10 18:01:22 -08:00
Ryan Nystrom
80ad941369 Revert D4521797: [IGListKit][PR] Vertical UICollectionViewLayout supporting inline sections
Summary: This reverts commit 20b36ae573d38ca3125a6f3d5faec181c290ab94

Differential Revision: D4521797

fbshipit-source-id: 447de6cf2b30de9c2109dffb266326aceceec7fc
2017-02-10 11:33:07 -08:00
Ryan Nystrom
727833409f Vertical UICollectionViewLayout supporting inline sections
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
2017-02-10 08:30:33 -08:00