Summary:
The content inset of a collection view can change at any time (as it does with our refresh control) and isn't a good measure of the container size. I don't want to totally remove that API though, so I changed the default behavior, added an insets API, and also added the functionality of the original in a new API.
This makes sizes much more deterministic.
Reviewed By: jessesquires
Differential Revision: D4800758
fbshipit-source-id: 85ce843b5b1c297cea2e2ea705fa255617cbe356
Summary:
If a negative height/width comes down, cap it to `0.0`.
Issue fixed: #566
Also fixes t16455632 internally.
- [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.
Closes https://github.com/Instagram/IGListKit/pull/583
Differential Revision: D4797520
Pulled By: jessesquires
fbshipit-source-id: 3eeec5244a445bb451460286b4f006ca0d9c67d1
Summary:
We constantly have random bugs pop up when mutations are made outside of a batch update. This change restricts the mutation API to a batch context object (which is just an `IGListAdapter`) so they can only be done **inside an update block**.
- Fixed open source project
- Confirmed open source examples build
- Updated all of Instagram.app to use this API
- Changelog breaking changes entry
Fixes#392
Reviewed By: jessesquires
Differential Revision: D4754129
fbshipit-source-id: 11d32a0fac3e50c9edbb01e92a8a0c7b8a43cf2d
Summary:
Add API for #315. Not sure if this is what you want rnystrom though 🤔. Will add tests after you confirm.
- [x] All tests pass. Demo project builds and runs.
- [x] 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)
Closes https://github.com/Instagram/IGListKit/pull/456
Reviewed By: jessesquires
Differential Revision: D4697190
Pulled By: rnystrom
fbshipit-source-id: f8513cf2fa33441eb40f486954136553d19dda0c
Summary:
Add IGListCollectionContext API to get visible indexes:
`- (NSArray<NSIndexPath *> *)visiblePathsForSectionController:(IGListSectionController<IGListSectionType> *) sectionController`
Issue fixed: #465
- [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/507
Differential Revision: D4621418
Pulled By: jessesquires
fbshipit-source-id: 4b55500c83ca1b911c418e5857756bb076fc80e4
Summary:
This becomes an issue pretty easily in embedded `IGListAdapter` environments (lists in lists). IGListKit creates a single `IGListSectionController` instance per object, but cells are reused within `IGListCollectionView`. If you assign `adapter.collectionView = cell.collectionView` (like we recommend in our [example](https://github.com/Instagram/IGListKit/blob/master/Examples/Examples-iOS/IGListKitExamples/SectionControllers/HorizontalSectionController.swift#L40)), then you can have many adapters with a weak ref to the **same collection view**.
Obviously when updates happen across all embedded lists, adapters could potentially update the same collection view and apply a corrupted batch update.
I proposed using `<objc/runtime.h>` and using associated objects, but since `OBJC_ASSOCIATION_ASSIGN` is not zerod-on-release reference (its just `unsafe_unretained`) I'd have to make a weak wrapped object, which is overkill.
Instead I think a global weak:weak map is fine. We d
Closes https://github.com/Instagram/IGListKit/pull/517
Differential Revision: D4623300
Pulled By: rnystrom
fbshipit-source-id: 53d2dd158923c431e793b0c8e28997e9bbf55b8b
Summary:
Adding a new layout-invalidation API, telling the layout object to query and rebuild the layout for all items in the section controller. This works with `UICollectionViewFlowLayout` and should work with other custom layouts (including our own).
Issue fixed: #360, #459
- [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.
Closes https://github.com/Instagram/IGListKit/pull/499
Reviewed By: jessesquires
Differential Revision: D4590274
Pulled By: rnystrom
fbshipit-source-id: f87235be4e6c024bf979b831a8938be68895e011
Summary:
Removing the assert and handling `nil` section controllers. This wont effect Swift code which demands a non-optional section controller, but Objective-C is more nuanced. There is evidence that some callers do not have a default state and are returning `nil`.
Unfortunately this will [OOB here](https://github.com/Instagram/IGListKit/blob/master/Source/Internal/IGListSectionMap.m#L63) if using the original `objects` array provided by the data source. Instead we prune the array, only allowing in objects that have a matching section controller.
Fixes t15773862 internally.
- [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.
Closes https://github.com/Instagram/IGListKit/pull/488
Reviewed By: dshahidehpour
Differential Revision: D4553886
Pulled By: rnystrom
fbshipit-source-id: a473a99b5eb513e4b610019dba0394a014193fc4
Summary:
This was a little bit of an invasive change with the display handler, but I think that this is the right call. When sending display events for objects, we should account for the supplementary view as part of the section controller. This is especially useful for headers and footers.
Note that this wont effect the working range API at all.
Fixes#300
Closes https://github.com/Instagram/IGListKit/pull/470
Differential Revision: D4551338
Pulled By: rnystrom
fbshipit-source-id: dda6fbf18bcfc2c941d80ee2314a543d1ab83843
Summary: This diff isn't correct, and the Instagram cut happens today. Pulling back so I have time to test the correct change more throughly.
Reviewed By: rnystrom
Differential Revision: D4550149
fbshipit-source-id: 2e882caeb9ef999b7fd57562740b352ea8edfa5f
Summary:
Adding an API to do item-level (cell) moves on the collection view. This complicates things a little bit because of all the issues that moving sections have while in batch updates (e.g. simultaneous animation UICV bugs). Thankfully we use pretty strict types so the compiler does most of the work for us.
Closes#145
- [x] Tests build and pass
- [x] Add `IGListBatchUpdateData` tests to check moves during
- [x] ~~Moving within a reloaded section (no op)~~ can't reload sections
- [x] Moving within a deleted section (no op)
- [x] Moving within a moved section (convert section ops to delete+insert)
- [x] Moving an index path that is also reloaded (convert to delete+insert path)
- [x] Add move unit tests to `IGListAdapterUpdater`
- [x] Add move unit tests to `IGListReloadDataUpdater` (mostly for code coverage...)
- [x] Add move unit tests to `IGListStackedSectionController`
- [x] Add `CHANGELOG.md` entry for 3.0.0
- [x] Test moving without batch
Closes https://github.com/Instagram/IGListKit/pull/418
Reviewed By: jessesquires
Differential Revision: D4521732
Pulled By: rnystrom
fbshipit-source-id: 99a46d1cbb0cc1f857a62ff6ca257aff6e8b7f25
Summary:
Before the diff, you can lookup the object for a given section, and then lookup the section controller for that object, but this seems like a pretty valuable/common operation.
Closes https://github.com/Instagram/IGListKit/pull/477
Differential Revision: D4537479
Pulled By: rnystrom
fbshipit-source-id: ad47a243f0bb0fc72a362863dff2f00b0b640fab
Summary:
1. The "Empty View" and CV background view are different things. People can now differentiate.
2. The Empty View isn't created until it is needed.
3. The Empty View moves with Refresh Controls.

- [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/462
Reviewed By: rnystrom
Differential Revision: D4502591
Pulled By: dshahidehpour
fbshipit-source-id: b72b444c1197c90c385c7414f0662299070a86d1
Summary: Fix bug where scroll position would be incorrect in call to `-[IGListAdapter scrollToObject:supplementaryKinds:scrollDirection:scrollPosition:animated:` with scrollDirection/scrollPosition of UICollectionViewScrollDirectionVertical/UICollectionViewScrollPositionCenteredVertically or UICollectionViewScrollDirectionHorizontal/UICollectionViewScrollPositionCenteredHorizontally and with a collection view with nonzero contentInset.
Reviewed By: jessesquires
Differential Revision: D4475043
fbshipit-source-id: 4714ab0ed02e52e2d7f333624cc17858058ee57f
Summary:
- Added `-[IGListAdapter visibleCellsForObject:]` API
1. Get all visible cells
2. Get the section for the object
3. Filter cells where indexPath.section of cell is equal to the object
4. Return
- [x] All tests pass. Demo project builds and runs.
- [x] I added test(s), 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)
-------------
Purely additive, can go in 2.2.0 release? Hold off on changelog until agreed.
Wanting to learn some more ObjC so gave this a shot, would appreciate some nit picking/feedback
Closes#437
Closes https://github.com/Instagram/IGListKit/pull/442
Differential Revision: D4450259
Pulled By: jessesquires
fbshipit-source-id: 521583c669fc1160212a7c46a50d62d951cafa2e
Summary:
- [x] All tests pass. Demo project builds and runs.
No breaking changes that I am aware of.
Closes https://github.com/Instagram/IGListKit/pull/440
Differential Revision: D4448496
Pulled By: rnystrom
fbshipit-source-id: 9ad9bc3734b605ceab25bf6cdf993568aa6561c1
Summary:
Modified `IGListAdapter` to update the `hidden` status of the `emptyView` after any item-level changes (`insertInSectionController:atIndexes:` and related methods) based on whether the item count is zero.
Closes#378
- [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/395
Differential Revision: D4400155
Pulled By: jessesquires
fbshipit-source-id: 6c3422297d86947e7e2878ba1b9227ff2a2a18b4
Summary:
I have fixed the typo in the code `previuossectionMap` -> `previousSectionMap`. I don't think this change requires to be tested as it appears to be an internal class. Because of this it's not a breaking change so I don't think it needs to be reflected in CHANGELOG.md either.
Closes#385
- [X] All tests pass. Demo project builds and runs.
- [X] 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)
Closes https://github.com/Instagram/IGListKit/pull/386
Differential Revision: D4390915
Pulled By: rnystrom
fbshipit-source-id: 1b745daaa913361ad211318ea1e216a03fe6f741
Summary:
Hey IGListKit folks! Would you be willing to expose this, so that other objects that are given a list adapter can inspect its updater configuration?
- [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/379
Reviewed By: jessesquires
Differential Revision: D4379016
Pulled By: rnystrom
fbshipit-source-id: 4056457181fea31f71b1e928b60aec46160cc585
Summary: Saw some crashes come in from out-of-sync objects and section controllers. After some digging I found that the nil-datasource assert was firing (not very frequently). Mostly happening on other VCs, probably from hitting the back button and an update arriving.
Reviewed By: jessesquires
Differential Revision: D4347862
fbshipit-source-id: 38c1a4816f5c109de41297309745ac2d5e348e93
Summary:
Adds a new test and fixes an item animation collision that `UICollectionView` throws on. Basically we cannot collide reloads with insert+delete.
The example in the test is trivial, but real-world situations do appear b/c of the coalescence of `IGListAdapterUpdater`. It can queue reloads and deletes/inserts at the same index paths while waiting.
- [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 have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/325
Differential Revision: D4322005
Pulled By: rnystrom
fbshipit-source-id: 2247163c13c0873a74ac485efff2d882ca6568f9
Summary:
- Add scrolling method on IGListCollectionContext so that section controllers can scroll to themselves.
- Update CHANGELOG.
- Other misc fixes.
- Closes#267 on GitHub.
Reviewed By: rnystrom
Differential Revision: D4261144
fbshipit-source-id: 9eed833cfff06107607bba01a0beee1d871497b6
Summary:
Even with the assert, we will add `NSNotFound` to the set which will crash. Instead, skip adding the value in case a consumer is using a reference to an object that doesn't exist anymore.
Also, should be using `continue` if a section controller isn't returned by the data source.
Reviewed By: jessesquires
Differential Revision: D4226771
fbshipit-source-id: ed6df0992fdef611dd8fae64f4716e296df11f9a
Summary:
I was able to build a unit test that reproduces the issue. We can avoid the crash by simply returning `nil` when accessing a cell while working range events are being vended.
There is definitely something weird going on here though. When debugging `cellForItemAtIndexPath:` I found:
```
(lldb) po indexPath
<NSIndexPath: 0xc000000000000516> {length = 2, path = 5 - 0}
(lldb) po [[self collectionView] numberOfSections]
11
```
So in theory we should be fine, right? But when I continue I get
```
*** Assertion failure in -[UICollectionViewData numberOfItemsBeforeSection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.5.2/UICollectionViewData.m:611
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items before section 5 when there are only 3 sections in the collection view'
```
There _were_ 3 sections in the UICV before the update, but the data source and structure powering
Closes https://github.com/Instagram/IGListKit/pull/216
Differential Revision: D4204625
Pulled By: rnystrom
fbshipit-source-id: 455ed199dfc115077e4294e2843016a50e179015
Summary:
Swapped NSUInteger to NSInteger in public headers. Fixed a test in IGListSectionMapTests.m to pass with NSInteger. For issue #200!
- [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 have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/205
Differential Revision: D4191521
Pulled By: rnystrom
fbshipit-source-id: 3f15c5ee3f8ed2d382de2602912a2e998bfbcbba
Summary: Adding this API to make querying visible objects a little easier. Fixes#164.
Reviewed By: dshahidehpour
Differential Revision: D4138472
fbshipit-source-id: 0136c39e17c72941b85284b7f3b5494b1ddabf68
Summary:
Saw this pop up in coverage reports. We don't log or assert `NSIndexPath` at all so this doesn't really seem necessary.
- [x] All tests pass. Demo project builds and runs.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/165
Differential Revision: D4138474
Pulled By: rnystrom
fbshipit-source-id: ad8375e47d1584f594d3df29f07a1d5d1a53f3c5
Summary:
Continuing the work on #90. I don't believe I can push directly to that PR since the origin is `master` of a repo I don't have access to.
https://help.github.com/articles/checking-out-pull-requests-locally/
I went ahead and added another supplementary view test copying the old one we had.
cc jessesquires in case there's something else I can do here. I believe this will still give rawlinxx credit?
Closes https://github.com/Instagram/IGListKit/pull/162
Differential Revision: D4137364
Pulled By: rnystrom
fbshipit-source-id: d8418ac5728fd6d9570fa1d1568f4343f5c4112b
Summary:
Miss this in the previous PR #92. Will add unit test soon.
Closes https://github.com/Instagram/IGListKit/pull/123
Differential Revision: D4101594
Pulled By: rnystrom
fbshipit-source-id: 820030358532b0878f6d9e9092834266c9260a38
Summary:
This commit changes some assertion texts. No behavior is changed; no assertions are added (just reworded). Some of them were short or contained no real meaningful informations, where the error probably is.
Ref: #113
- [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 have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/122
Differential Revision: D4090470
Pulled By: rnystrom
fbshipit-source-id: 96f492a1efd258ec3424ce334802229fdbdee191
Summary:
I started working on adding support for dequeuing cells created from nibs (issue #1). Additionally I extended `IGListSingleSectionController` so that it can be used with nibs too. I don't know if you had this also in mind.
- [x] I'm currently thinking about the best way to test these changes.
- [x] I was not able to update the documentation (issue #55).
- [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 have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/56
Reviewed By: dshahidehpour
Differential Revision: D4023746
Pulled By: rnystrom
fbshipit-source-id: 6a8b4cfb4dba38ea6e9870a9a4506288ee155cfe
Summary: Product needs show that section controllers need some sort of awarenes when they are the first/last section in a list (e.g. for cell borders). Adding this simple API, non-breaking.
Reviewed By: jessesquires
Differential Revision: D4016023
fbshipit-source-id: c75f9298fc73875a1cabad191fe2db6cb9ee4376
Summary:
- I ran the static analyzer, and it found a case in `performUpdatesAnimated:completion:` where it looks like we meant to bail out early if the `collectionView` or `dataSource` is nil, but it only does so if `completion` is provided.
- Fixed a spelling error in nearby documentation
- [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 have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
- There is one other analyzer warning, but it seems to be making an incorrect assumption. In any case, it's not something I can fix quickly (requires more time spent staring at IGListDiff.mm).
- A ticket should be opened to add static analysis to .travis.yml. I'lll do this soonish, unless someone beats me to it!
- I could add a test for this, but this project is annotated well enough with null
Closes https://github.com/Instagram/IGListKit/pull/51
Reviewed By: ocrickard
Differential Revision: D4008605
Pulled By: rnystrom
fbshipit-source-id: c2b7516cb8c1fc619aa63d1e9b0c26f2918cd8a1
Summary:
Replaced the two methods for generating a reusable identifier with an inline C function (as per #40) which has 3 parameters: `viewClass` (unchanged), `nibName` (for when #1 is added), and `kind`. The string is generated following the same pattern as before.
A few things:
- The current test only tests one of the options. May want to add more tests for each.
- Not sure if you guys prefer `NS_INLINE` vs `static inline`.
- Not sure if we want to add assertions for empty strings for nibName/kind parameters.
- [x] All tests pass. Demo project builds and runs.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/49
Differential Revision: D4005549
Pulled By: jessesquires
fbshipit-source-id: e1683ebe8882d1a8de934c8166f67d3508cffba9