Commit graph

92 commits

Author SHA1 Message Date
Adam Stern
b4c8ea180f give section controllers access to collection view scrolling traits
Summary:
I'd like to be able to access the current collection view scrolling traits inside section controllers. These are expressed as three properties from `UIScrollView`:

`isTracking`, `isDragging`, and `isDecelerating`.

My approach is to add a new struct `IGListCollectionScrollingTraits` with these three values, and expose this to section controllers through `IGListCollectionContext`.

Reviewed By: rnystrom

Differential Revision: D7986814

fbshipit-source-id: 19e9bd3b89545b10238dd060a5af8c5a0f39eb82
2018-05-14 14:56:54 -07:00
Ryan Nystrom
583efb936b Add experimental collectionView getter fix
Summary:
Adding a fix to the `IGListAdapterUpdater` that requests the `UICollectionView` to perform updates on until just-before we update. This way if the `UICollectionView` is changed between update-queue and execution (b/c updates are async), we guarantee the update is performed on the correct view.

See the accompanying unit test that fails w/out the fix enabled.

Differential Revision: D7889908

fbshipit-source-id: 7178677f34951a1e42986b0289fc4abc708d6946
2018-05-11 08:08:44 -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
Ryan Nystrom
3059c5e6f5 Add experiment to defer requesting objects from data source until just before diffing
Summary:
Inspired by recent performance investigations in Instagram, adding an experimental feature to defer requesting objects from the `IGListAdapterDataSource` until //just before// diffing is executed. If //n// updates are coalesced into one, this results in just a single request for objects from the data source.

This is a **breaking change** to the public API, but since writing custom `IGListUpdatingDelegate`s is discouraged, I'm less worried about saving this for a major version launch.

Reviewed By: manicakes

Differential Revision: D7744518

fbshipit-source-id: f0001263cddda383e3dedd1d350a83d2cfb8362a
2018-04-26 08:27:49 -07:00
Chrisna Aing
f469c3440b Fix binding SC cell updates when the SC's section changes.
Summary:
Issue fixed: #1111

As discussed in the issue's comments, this seems to be the most expedient fix if we accept that `cellForItemAtIndex:` should be allowed within update blocks. I am not familiar enough with `IGListAdapter` to know whether this is the best solution but am willing to make any changes requested!

- [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/1144

Differential Revision: D7585125

Pulled By: rnystrom

fbshipit-source-id: 29a0e68da33bb4b94c2eb5e68844e537a7b05868
2018-04-11 08:00:40 -07:00
Sho Ikeda
9315299fbc Minimum fixes for Xcode 9.3 build errors
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
2018-04-09 08:37:18 -07:00
Brandon Kieft
01770eb303 Prefix all private methods with an underscore
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
2018-04-02 15:08:21 -07:00
Jeremy Lawrence
f47753e361 Add dequeue method with reuse identifier
Summary: Added the ability to register/dequeue a cell with a customized reuse identifier. This will allow for registering the same cell class for multiple reuse identifiers, as will be needed for `IGListItemView` cells.

Reviewed By: rnystrom

Differential Revision: D7436575

fbshipit-source-id: d557836b5454c50611c5a5f9367f2f2e496c3878
2018-04-02 09:17:40 -07:00
Jared Verdi
f15b167e85 Interactive Reordering
Summary:
I had a desire for interactive reordering in a personal project, so here's a first attempt at adding support in IGListKit.

I figured I might as well get a WIP PR up for comments before I continue further as there are a few aspects to interactive reordering that don't interplay perfectly with IGListKit.

As discussed in #291, I went after two prime use cases:
1. Moving items amongst a section
2. Rearranging whole sections

I also "disabled" moving items between sections by having those moves revert, to mimic interactive reordering cancellation as closely as possible.

You can see both in the Mixed Data example. Grid items can be moved within a section, while users can be moved to reorder whole sections. But trying to move a grid item out of a grid or a user item into a grid will auto-revert. The revert animation isn't as tight as it should be. It may be more desirable to disable the animation - though you lose the visual cue.

There is a also a new example, `ReorderableViewController`, that demonstrates 2 in its pure form (likely the most desired use case), where all sections are reorderable single rows.

Happy to take feedback -- this is my first experience working on IGListKit, so I would expect there to be gaps. (Ex. I haven't used `IGListStackedSectionController`, and its tests failed as I hadn't implemented reordering delegates for it. Those are simply stubbed out for now.)

Issue fixed: #291

- [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] Proper support in `IGListStackedSectionController`
Closes https://github.com/Instagram/IGListKit/pull/976

Differential Revision: D6674493

Pulled By: rnystrom

fbshipit-source-id: cd53c5fdc6fb59636edc4747c4bbd0f81a4610e5
2018-02-12 09:27:08 -08:00
Zhisheng Huang
c617b18eb6 Move the DEBUG uniqueness check outside of for-loop inside IGListAdapter
Summary:
The original DEBUG was put inside a for loop, which caused a quadratic looping while creating bigger and bigger NSSet.

This is very inefficient and I verified that by profiling with 10000 objects in the array and it caused significant amount of CPU. The main thread is pretty much unresponsive.
Closes https://github.com/Instagram/IGListKit/pull/1084

Reviewed By: rnystrom

Differential Revision: D6903043

Pulled By: lorixx

fbshipit-source-id: 311e8a402eb8d5574fce0eabd626a674b6a5e8c5
2018-02-05 12:38:27 -08:00
Jesse Squires
ae7f36f5c2 Update gems, fix warnings, pod install
Summary:
- Update CocoaPods + Gems
- Update SwiftLint version
- Fix lint errors
- Fix `pod_setup.sh` script, move to `scripts/` (should now be run from root dir)
- Run `pod_setup.sh`
Closes https://github.com/Instagram/IGListKit/pull/1038

Differential Revision: D6602297

Pulled By: rnystrom

fbshipit-source-id: 1bf69611e041903cf982fe7d9a95197729e44d94
2017-12-19 09:31:37 -08:00
yiplee
e63a0e78fe Add new iOS 11 api adjustedContentInset support
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
2017-12-18 08:51:14 -08:00
yemodin
c7d4dc29a8 Make sure collection have unique ListDiffable objects on initial data…
Summary:
… source setup too

Issue fixed: #815

- [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/993

Reviewed By: manicakes

Differential Revision: D6388270

Pulled By: rnystrom

fbshipit-source-id: e5e7e047bad5f21b81b562ebd586f7f5036325ff
2017-11-21 13:18:12 -08:00
Ryan Nystrom
2f17cb5fdf Revert D6264886: [IGListKit][PR] Make sure collection have unique ListDiffable objects on initial data…
Summary:
This reverts commit 5159b7989f1d17fd0a7522d986ed6abf012da77f

bypass-lint

Differential Revision: D6264886

fbshipit-source-id: 54b230fab0e7b1fdf15e065e60f4c3bfd743629b
2017-11-17 12:33:54 -08:00
Maxime Ollivier
82a2a2ee18 added experiment to make [IGListAdapter visibleSectionControllers] a bit faster
Summary:
* Issue: [IGListAdapter visibleSectionControllers] calls [UICollectionViewLayout layoutAttributesForElementsInRect:] which can be expensive. And since visibleSectionControllers is called in scrollViewDidScroll, it can add up and take a toll on scroll performance. On an iPhone 7, it's in 2-10% of the main-thread samples (using Time Profiler).
* Fix: IGListDisplayHandler conveniently keeps track of visible IGListSectionControllers, so let's just use that. Now, [IGListAdapter visibleSectionControllers] drops to ~0.3% of samples.

Reviewed By: rnystrom

Differential Revision: D6351474

fbshipit-source-id: 66914db95e08498927bfbceda4d2e9d58cbc7530
2017-11-16 16:07:29 -08:00
yemodin
319928f697 Make sure collection have unique ListDiffable objects on initial data…
Summary:
… source setup too

Issue fixed: #815

- [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/993

Reviewed By: jeremycohen

Differential Revision: D6264886

Pulled By: rnystrom

fbshipit-source-id: 5159b7989f1d17fd0a7522d986ed6abf012da77f
2017-11-15 11:27:25 -08:00
Ryan Nystrom
8cffc50d7d Copy and nil block queue before executing #trivial
Summary:
Discovered in rnystrom/GitHawk#781 and introduced in d9a89c9b00. Can't repro in unit test, but have obvious stack traces (see GitHawk issue) that collection is being mutated while enumerated.

No changelog since this is a new fix for 3.2.
Closes https://github.com/Instagram/IGListKit/pull/995

Reviewed By: manicakes

Differential Revision: D6206957

Pulled By: rnystrom

fbshipit-source-id: c42e3688d0f2b31693199f8015b5de48b7b3b9e6
2017-11-03 11:29:41 -07:00
Ryan Nystrom
a6f264fc12 Update project settings and fix errors
Summary:
Updated the main project lib settings for iOS 11, fixed all errors (which are from warnings-as-errors).

- [x] All tests pass. Demo project builds and runs.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
Closes https://github.com/Instagram/IGListKit/pull/942

Differential Revision: D6161473

Pulled By: rnystrom

fbshipit-source-id: 1fd51d8805f9c6483942b44d750b2756efde9376
2017-10-26 11:20:55 -07:00
Ryan Nystrom
5cf01cc0a7 Add update finished announcer API
Summary:
Adding a new API to support adding 1:many listeners to observe when an `IGListAdapter` finishes performing an update event. It supports:

- `performUpdates:`
- `reloadData...`
- Even handling update triggered from //inside// a section controller

Differential Revision: D6108096

fbshipit-source-id: d0b43d83f1963fdbf6ef388685cbd8f6890177fa
2017-10-20 08:57:11 -07:00
Ryan Nystrom
b2860c3604 Fix scrollToObject: bug when scrolling to bottom with content inset
Summary:
This has been around forever, surprised we've never run into it. Instagram doesn't really use the `bottom` position except for one place that is already at the bottom of a view. Looks like this bug has just been hanging around quietly for ages.

`UIScrollView` takes into account the content inset when changing the content offset. Doing math w/ the inset is both useless and incorrect.

Issue fixed: #932

- [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/940

Differential Revision: D5881117

Pulled By: rnystrom

fbshipit-source-id: 5c9af4b6f8b59be977491ba734e9b0fa3c538cb9
2017-09-21 11:16:32 -07:00
Ryan Nystrom
d9a89c9b00 Defer invalidatation until all batch updates are finished
Summary:
Added a mechanism to `IGListAdapter` to defer (_queue or execute_) blocks around asking the updater to do batch updates. I discovered a crash where the `_updateCompletionHandler` (private ivar) of `UICollectionView` was not being niled when two batch updates collide. There is an assert in `-[UICollectionView dealloc]` that fires if this block != nil. Took some reverse eng to track down what is happening.

Sadly I cannot reproduce the issue in a unit test _or_ sample app. However I can 100% repro this in my GitHawk app. Applying this patch fixes the problem. I added a unit test that got me _close_ to the state of the crash. Consider this new test future-proofing (also covers the enter/exit/defer stuff).

Also dumping the `UICollectionView` internals confirms that the bad state (`_updateCompletionHandler != nil`) is no longer true.

Issue fixed: #929

Depends on #930

- [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/931

Differential Revision: D5863761

Pulled By: rnystrom

fbshipit-source-id: 496aa939e3a5e83472b26bfb5a4cdc872f58cc0e
2017-09-20 09:49:48 -07:00
Phil Larson
1717b2c904 IGListAdapter support for scrollViewDidEndDecelerating
Summary:
References #842

We use -[UIScrollViewDelegate scrollViewDidEndDecelerating:] delegate callback in the app we are building to hide/show elements when motion has ended.
Closes https://github.com/Instagram/IGListKit/pull/899

Differential Revision: D5689239

Pulled By: rnystrom

fbshipit-source-id: ea17fe94ccacc5e4f0a9e085e61f8f77cfcea3b4
2017-08-23 13:30:44 -07:00
Gulam Moledina
f79516ee66 Proper support vertical and bottom positions in IGListAdapter scrollToObject: API
Summary:
I simply wrote failing tests for `scrollToObject` API for the `ScrollPosition` parameter and then fixed the code.

If we agree that these tests are correct, I don't mind suggesting a fix for it. I think it's the `indexPath`'s row that is hardcoded to `0` that needs to be changed depending on the `scrollPosition` desired. (Done!)

- [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/861

Differential Revision: D5678607

Pulled By: rnystrom

fbshipit-source-id: ab902b58fe70667ef6133cb05569a2223a668243
2017-08-22 13:31:27 -07:00
Ryan Nystrom
5ca167806b Disable prefetching when setting the collection view
Summary:
Followup from #852 since `UIAppearance` doesn't have any effect. Automatically disable prefetching.

Issue fixed: #846

- [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/889

Reviewed By: jeremycohen

Differential Revision: D5651413

Pulled By: rnystrom

fbshipit-source-id: ed602aa4609038bd629c9366c383a23f32fc88df
2017-08-21 07:30:10 -07:00
Ryan Nystrom
ae3604c3fe Restore scrollToObject: API with layout fix
Summary:
Reverting the revert in D5651413. The origin PR:

https://github.com/Instagram/IGListKit/pull/808/files

Had a small bug in it that wasn't captured via unit tests b/c we use a custom layout. However this should also repro in `IGListCollectionViewLayout`, but none of our tests combine the two atm.

Differential Revision: D5651585

fbshipit-source-id: da6c67cba57ab1aad51535467bff86a21f16f2fa
2017-08-21 07:06:32 -07:00
Ryan Nystrom
79b8290a1e Back out D5353285 which crashes custom layout
Summary: Public PR crashes our custom layout b/c requesting # of items doesn't trigger `prepareLayout` on the layout. End up w/ OOB exceptions.

Differential Revision: D5622021

fbshipit-source-id: ecc8cc7bfb38e3ebe7f7433c96b816469f16774c
2017-08-14 10:05:07 -07:00
Gulam Moledina
e8ddaf8740 Fix CollectionView scroll behaviour when section is empty
Summary:
Issue fixed: When a section is empty (0 cells) but has a header/footer supplementary views, calling `scrollToObject:supplementaryKinds:scrollDirection:scrollPosition:animated` wouldn't do anything as the method implementation has an early return if the section doesn't have any cells:
![screen shot 2017-06-15 at 14 07 18](https://user-images.githubusercontent.com/978865/27195239-fd86401e-51d3-11e7-8630-a018fbba6858.png)

As the section does have supplementary views and is displayed on screen, there's no reason not to scroll to it. This minor change fixes this detail.

Change in internal implementation of one method - all current tests pass. No tests added.

- [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/808

Differential Revision: D5353285

Pulled By: rnystrom

fbshipit-source-id: 2b6700f98f7d38716d655dfecceb0353d65ef681
2017-08-11 15:45:00 -07:00
Marvin Nazari
5bede7b78e Select an item through IGListCollectionContext
Summary:
We already had a API to deselect an item through `IGListCollectionContext` this is the support for selecting an item.

- [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/874

Reviewed By: ryanolsonk

Differential Revision: D5562902

Pulled By: rnystrom

fbshipit-source-id: 756a154607d7d758faddc70ac784e544739f5a93
2017-08-04 15:19:56 -07:00
Mani Ghasemlou
bb9b037ed3 Fix visible section controllers bug (#643)
Summary:
Issue fixed: #643

- [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/868

Reviewed By: manicakes

Differential Revision: D5553538

Pulled By: rnystrom

fbshipit-source-id: 25d98a28d47a15d494ba530c850e0335d87d758c
2017-08-03 13:06:14 -07:00
Weyert de Boer
9f5bf3fb7e Improved the documentation
Summary:
Improved the documentation so it that the Getting Started guide calls out that you need to set `dataSource`-property of the `IGListAdapter` as I totally misse that.
Closes https://github.com/Instagram/IGListKit/pull/820

Differential Revision: D5353295

Pulled By: rnystrom

fbshipit-source-id: deca1d75fad08f69081033ae1a65302a4f10ba9f
2017-06-29 18:32:31 -07:00
Chen (Bert) Li
1d926d9a97 Fix over-scrolling issue in IGListAdapter scrollToObject: method
Summary:
UIScrollView can over-scroll, if content offset is too small or too large.

Providing methods to help calculate safe content offsets, given the desired values. Use the safe content offsets in IGListAdapter.

Reviewed By: rnystrom

Differential Revision: D5312473

fbshipit-source-id: d882948940ce08c48f5ff0ab8d997591f62915a8
2017-06-29 09:09:00 -07:00
Ryan Nystrom
d0253b705a Don't assert indexForCell: API when cell isn't visible
Summary:
Noticed this randomly debugging. Say you have a completion block that finishes after some async task happens. If you scroll the cell off screen it will return `nil` for `-[UICollectionView indexPathForCell:]`, and the assert will fail (unless the SC is at 0). Quiet some asserts.
Closes https://github.com/Instagram/IGListKit/pull/824

Differential Revision: D5303432

Pulled By: rnystrom

fbshipit-source-id: 64432c43f46d33ce052e6f4fedc094c1fc1f04e1
2017-06-22 13:03:30 -07:00
Viktor Gardart
95367bb6a4 replace alloc] init] -> new]
Summary:
Issue fixed: #822

As rnystrom would've said: Go 💚
Closes https://github.com/Instagram/IGListKit/pull/823

Differential Revision: D5301864

Pulled By: rnystrom

fbshipit-source-id: c7a0f62b91712a54ee75ee0d1fe62b8611745e37
2017-06-22 09:31:45 -07:00
Viktor Gardart
8073736772 Add assertion and tests for non unique diffIdentifiers
Summary:
Issue fixed: #814

- [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/821

Differential Revision: D5301480

Pulled By: rnystrom

fbshipit-source-id: 3a1989aae8de5d03aa803d51b88c65eed999c4bb
2017-06-22 07:53:56 -07:00
Weyert de Boer
68b73133fc Feature/beginners warning
Summary:
Issue fixed: #811

I don't think this change needs a item in `CHANGELOG.md` as it's not a real bug fix or enhancement that influences the behaviour of the library.

- [X] All tests pass. Demo project builds and runs.
- [ ] 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/812

Differential Revision: D5283118

Pulled By: rnystrom

fbshipit-source-id: 518d38c7f620cef3e85cae5fd4a1c48567bcc48c
2017-06-20 08:32:58 -07:00
Andrew Monshizadeh
1d140e441a Reset all section controllers when a list adapter is deallocated
Summary:
This change will ensure that section controllers have the following properties reset to sensible default values when their owning list adapter is deallocated.

```
isFirstSection = NO
isLastSection = NO
sectionIndex = NSNotFound
```

Issue fixed: #709

- [X] All tests pass. Demo project builds and runs.
- [X] I added tests, an experiment, or detailed why my change isn't tested. (Existing test is updated to ensure this doesn't regress)
- [ ] 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/723

Reviewed By: rnystrom

Differential Revision: D5032445

Pulled By: jessesquires

fbshipit-source-id: 446a30f4206ce02d3ad89fcd9b4586587f396f58
2017-05-10 10:02:55 -07:00
Ryan Nystrom
a4dfe9676e Fix reusing collection views among multiple adapters
Summary:
When multiple `UICollectionView`s are reused among multiple `IGListAdapter`s (horizontal lists embedded in a bigger, vertical list), the mapping between the old view and adapter is not broken. When a new collection view is attached to the old adapter, an unrelated adapter->collection view reference will be erroneously broken.

The unit test in this diff fails on the second `XCTAssertEqual(adapter2.collectionView, collectionView1);` without this patch.

Issue fixed: #699

t15661237 internally

cc amonshiz since we were talking about this

- [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/721

Reviewed By: amonshiz

Differential Revision: D5026330

Pulled By: rnystrom

fbshipit-source-id: b2164a4ab39802f7fba870ceab6692b7b501b5c2
2017-05-09 08:08:46 -07:00
Andrew Monshizadeh
a4e5ad862e Move section index to property
Summary:
This pull request removes the `sectionForSectionController:` method from the `IGListCollectionContext` protocol so that the protocol is exclusively for presentation methods.

This should not add new functionality, but rather makes the index directly accessible on the section controllers themselves. This change makes sense because at no time will there be an update to the list that the list adapter is unaware of and so it will always be able to set and update any indexes for a section controller that has changed.

Issue fixed: #609

- [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/671

Reviewed By: jessesquires

Differential Revision: D4942159

Pulled By: amonshiz

fbshipit-source-id: d648cfdd381cbf1d9ee7ff549ae27d2972a84622
2017-05-01 07:28:27 -07:00
Ryan Nystrom
5fe27d8809 Add debug dump scripts
Summary:
Got a little time on the plane to mess around with this idea. Very much want comments on this! Some questions:

- We should probably compile out parts of this using `#if DEBUG`.
  - Should I compile out all of the description methods?
  - Maybe I wrap the entire debug files w/ `#if DEBUG ... #endif` so none of it is loaded?
- ryanolsonk I used [FLEX](https://github.com/Flipboard/FLEX/blob/master/Classes/Utility/FLEXHeapEnumerator.m) for searching the heap, lmk if you see any problems w/ this
  - Its lifted w/ only a few changes for my specific needs (including comments 😂)
  - Chalk us up for using [another bit](https://github.com/Instagram/IGListKit/blob/master/Source/Internal/IGListAdapterProxy.m#L77-L82) of your code
- Added a basic test so that the basics of this work and coverage doesn't tank
  - Anything else I should test?
- Is there more data we should be dumping?
- I have to track batch update state on the updater in order to dump it. If this seems dan
Closes https://github.com/Instagram/IGListKit/pull/617

Reviewed By: jessesquires

Differential Revision: D4929426

Pulled By: rnystrom

fbshipit-source-id: fcba0d6f0b7766485440f208cf70ad39dfc7a42e
2017-04-21 16:46:06 -07:00
Bas Broek
ea5a4cc00f Init without working range size
Summary:
Issue fixed: #414

- [x] All tests pass. Demo project builds and runs.
- [ ] 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)

What should we do with testing? I changed all the occurrences of the old initializer with the new one, so I think this is good to go?
Closes https://github.com/Instagram/IGListKit/pull/686

Differential Revision: D4931986

Pulled By: jessesquires

fbshipit-source-id: d6f0ac6578c11f8ef37ec0e385bc110e3abd7c91
2017-04-21 14:30:46 -07:00
Ryan Nystrom
073fc073e0 Prevent duplicate item deletes and drop reload collisions
Summary:
a415ef5552 exposed a bug in `UICollectionView` where its state gets corrupted when deleting the same index path more than once in a single batch update block. This resulted crashes like

```
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x4)
Closes https://github.com/Instagram/IGListKit/pull/657

Reviewed By: jessesquires

Differential Revision: D4913790

Pulled By: rnystrom

fbshipit-source-id: 8f6fcdd2e2438da309fc64ca0ac111b9a0980149
2017-04-19 17:17:41 -07:00
Jesse Squires
145327647b Invalidate layout when collection view reused between IGListAdapters
Summary:
Closes #659
Closes https://github.com/Instagram/IGListKit/pull/677

Differential Revision: D4915322

Pulled By: jessesquires

fbshipit-source-id: 2ae6ff4ee1726fe2395233d7d662c0b12956a746
2017-04-19 13:00:47 -07:00
Ryan Nystrom
3102852ce2 Remove IGListSectionType
Summary:
Removing the `IGListSectionType` protocol and adding default implementations into `IGListSectionController`.

- `numberOfItems` returns 1
- `cellForItemAtIndex:` asserts (have to return a cell)
- `didUpdateToObject:` no-ops
- `didSelectItemAtIndex:` no-ops

Fixes #168

Reviewed By: jessesquires

Differential Revision: D4909585

fbshipit-source-id: 8816702504e3fc0683868914ff4dd20e4af7c166
2017-04-19 08:26:30 -07:00
Andrew Monshizadeh
ae11d6af53 Move UICollectionView(DataSource|Delegate) to category
Summary:
This reduces the quantity of the code within IGListAdapter.m and is a bit more in line with Swift style of putting protocol conformance into extensions.

This does not change functionality just rearranges where code lives.

- [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/599

Reviewed By: jessesquires

Differential Revision: D4861777

Pulled By: amonshiz

fbshipit-source-id: eaa31aa9438f3892193aeb8b4ae580ba2960ee8b
2017-04-18 11:21:18 -07:00
heshamsalman
3c41fb15e5 Uniqueness assert of section controllers, close #567
Summary:
Issue fixed: #567

- [ ] 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)
Closes https://github.com/Instagram/IGListKit/pull/639

Differential Revision: D4878842

Pulled By: jessesquires

fbshipit-source-id: 664648cf4f5e28d0a6af308e30151cb66863962c
2017-04-12 16:15:55 -07:00
Jesse Squires
2284ce3897 kill IGListCollectionView. GH issue #409 (redo of D4640425)
Summary:
Take 2. Remove `IGListCollectionView` per #409. Use plain old `UICollectionView`.
(This re-applies D4640425 and updates as needed.)

Also:
- run `pod update` everywhere
- update changelog

Reviewed By: paulvanderspek

Differential Revision: D4812207

fbshipit-source-id: 1ddbae06cdeddb43d8af175d3e8a045a36ff150e
2017-03-31 14:54:09 -07:00
Ryan Nystrom
623ff2a8a8 Container size doesnt use content inset, add new APIs
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
2017-03-30 09:35:03 -07:00
Ryan Nystrom
4e9b0bb4c4 Prevent negative spaces for items and supplementaries
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
2017-03-29 15:01:08 -07:00
Ryan Nystrom
ca9e9a16b7 Fix unused variable warning when asserts compiled out
Summary:
Found this examining Travis output. Warning removed when asserts aren't compiled.

Closes https://github.com/Instagram/IGListKit/pull/580

Differential Revision: D4763179

Pulled By: rnystrom

fbshipit-source-id: af23780387e8d8f95f11fe778d91e281006ff6fb
2017-03-23 11:47:58 -07:00
Ryan Nystrom
a15ea08614 Move section controller mutation API to object provided in update block
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
2017-03-22 12:46:49 -07:00