Commit graph

29 commits

Author SHA1 Message Date
Jesse Squires
8dd464e712 Update swiftlint + script, add newrules, autocorrect
Summary:
- Updates to SwiftLint 0.24.2
- Improve `scripts/lint.sh`
    - pull version out to a var for easier maintenance
    - better error message
    - make script fail xcode build if not installed (so we don't commit lint errors)
- Adds a few new SwiftLint rules
- Correct all new lint errors (most can be done by running `swiftlint autocorrect`)
- Cleans up `.swiftlint.yml`
- Fix up example projects
Closes https://github.com/Instagram/IGListKit/pull/1058

Differential Revision: D6776177

Pulled By: rnystrom

fbshipit-source-id: 345172237b97aaed0d62312c8f366f46145f8cd9
2018-01-22 12:14:38 -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
Igor Vasilenko
a0cf76c757 Added support UICollectionElementKindSectionFooter for IGListCollectionViewLayout
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
![simulator screen shot - iphone 6 - 2017-11-14 at 13 35 22](https://user-images.githubusercontent.com/7735730/32775551-c69868cc-c940-11e7-8307-ae2e353519ff.png)

- [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
2017-11-21 12:45:38 -08:00
Ryan Nystrom
f7220b5cfe Update example project files, convert to Swift 4, and fix errors
Summary:
Used migration tool with Swift 4, fixed build errors, and killed all warnings. Only non-trivial change was in the macOS example. Will flag that one.

No changelog needed for this, right?

- [x] All tests pass. Demo project builds and runs.
Closes https://github.com/Instagram/IGListKit/pull/941

Differential Revision: D5890505

Pulled By: rnystrom

fbshipit-source-id: 7e0d3510ff0e5856a0ffd59f1a97548a72266c20
2017-09-22 06:55:23 -07:00
Kim de Vo
595c09e5ec Removed empty methods
Summary:
Issue fixed: #

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

Differential Revision: D5881110

Pulled By: rnystrom

fbshipit-source-id: 7f20fcaac04f64576a52ca68af87d3db64f199b9
2017-09-21 07:17:01 -07:00
Rishabh Tayal
3f7c7f316a Fixed Search controller section in example project
Summary:
The search bar used to set the text as empty when the user scrolls.
Closes https://github.com/Instagram/IGListKit/pull/922

Differential Revision: D5768667

Pulled By: rnystrom

fbshipit-source-id: 8a77708c2bd4101fbdef1401a1ad0d8d6e2fae7d
2017-09-05 12:12:00 -07:00
Ryan Nystrom
6540f960e2 Add cell deselection API
Summary:
Adding support for a cell deselection API. Trying to make some headway to move and drag+drop support, but also want better stock `UICollectionView` API support. Will also assist eventual `UITableView` support.

- Added overridable API to `IGListSectionController`
- Support for stacked SC
- Breaking, required protocol for binding SC

Assists #524 and #184

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

Reviewed By: jeremycohen

Differential Revision: D5425414

Pulled By: rnystrom

fbshipit-source-id: 0b25c125b1f171979a15c3095095fc18b4108be6
2017-07-17 14:19:41 -07:00
heshamsalman
02f28fc994 Implemented SwiftLint, new PR
Summary:
Replaces #642, #681

Issue ref: #394

Changes from last PR:
- Deleted the shared SwiftLint folder, incl. all files (On the plus side, did this in the quest to get this PR in https://github.com/realm/SwiftLint/pull/1513)
- Changed the build script such that it runs the user's `HomeBrew` installation of SwiftLint instead of the local copy

Integrates SwiftLint into DangerBot.
You may want to append a ?w=1 to the end of the files-changed url to exclude whitespace-only changes.

- [ ] 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/741

Differential Revision: D5068134

Pulled By: jessesquires

fbshipit-source-id: 68d6a57e0072672e38eeb94908d00f26bbd68fbc
2017-05-16 07:31:43 -07:00
Ryan Nystrom
0a416914d5 Rename sectionIndex API to just section
Summary:
Quick rename before releasing 3.0 to get this API in parity w/ `isFirstSection` and `isLastSection`. My b I should have caught this in review.

Closes #720

Reviewed By: jessesquires, amonshiz

Differential Revision: D5031184

fbshipit-source-id: 1cd7b00c8b32084fecd861e78808eea0d0056337
2017-05-11 14:49:59 -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
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
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
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
heshamsalman
6758355f0c Chore/variable accessibility, close #618
Summary:
Issue fixed: #618

- [ ] 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/637

Differential Revision: D4869624

Pulled By: jessesquires

fbshipit-source-id: a9d5623dbb7a032691f3af5a2abf61adc3a42cd0
2017-04-11 13:46:41 -07:00
Adlai Holler
4a5fd32ad8 Add Nullability to a Few Headers
Summary:
I saw some `!` in the Swift example that we can remove 🙂

Same as I mentioned in my last PR, the iOS examples project can't be opened on my machine, but I believe I updated the examples to be compatible.
Closes https://github.com/Instagram/IGListKit/pull/626

Differential Revision: D4860165

Pulled By: jessesquires

fbshipit-source-id: 74bcac8fc759da8105e658901c3df9e71afc609f
2017-04-10 10:18:20 -07:00
Ryan Nystrom
ba65b56a9b Improve the ObjC demo to reflect best-practices
Summary:
Couple best practices I want to make sure our examples reflect:

- Multiple cells in a section controller
- Unique models returned in `objectsForListAdapter:` (no dupes!)
- Dynamic item count (`comments` array)

Issue fixed: #595

- [x] All tests pass. Demo project builds and runs.
Closes https://github.com/Instagram/IGListKit/pull/615

Differential Revision: D4852192

Pulled By: jessesquires

fbshipit-source-id: f4a89800f90e6b5ea4b6dd7c0d9a78ca5d65082c
2017-04-07 11:33:43 -07:00
Ryan Nystrom
49bf24693d Demo for dependency injection and announcing changes
Summary:
Created a new demo that shows off how to:

- Inject dependencies to section controllers
  - Objects shared between section controllers
  - Things that aren't the core "object"
- Announce changes from the VC that make their way to the section controllers
  - Without calling updates
Closes https://github.com/Instagram/IGListKit/pull/612

Differential Revision: D4827188

Pulled By: rnystrom

fbshipit-source-id: 9575df0e105fd06f9a59db49432b19e8b824e0e3
2017-04-04 10:16:39 -07:00
Andrew Monshizadeh
2ac81d4c37 Generics are now necessary on the IGListBindingSectionController object
Summary:
PR #602 added generics to `IGListBindingSectionController` in the ObjC code but did not update the Swift Examples. Swift fails to compile without any form of generic specification.

Fixed example compilation.

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

Differential Revision: D4818132

Pulled By: rnystrom

fbshipit-source-id: 8ccdab044ac68d2a95085faedf683ac1b882cbff
2017-04-02 20:30:57 -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
79348164a7 Auto diffing section controller
Summary:
Started work on the plane to get this moving since #418  is up and ready to land. We'll likely need to spend some time fleshing out the API of this, and I think I'll split it up into a couple different PRs once ready for review. Putting this up now to get early feedback.

This adds an auto-diffing section controller as outlined in #38. There are several key parts:

- Subclass a new section controller `IGListAutoSectionController` (naming wip)
- Connect a data source
- Implement the data source methods that do 3 things:
  - Given a top-level object, transform it into an array of **diffable** view models
  - Given a view model, return a cell
  - Given a view model, return a size for a cell
- A new protocol for the cell `IGListBindable` so that we can control when the cell is updated w/ the view model.
  - The most important part of this is that it unlocks moving and reloading a cell, which you can't do w/ `UICollectionView`

- [ ] Unit test `reloadObjects:`
- [x] Add
Closes https://github.com/Instagram/IGListKit/pull/494

Reviewed By: amonshiz

Differential Revision: D4696966

Pulled By: rnystrom

fbshipit-source-id: f21b8341b3ed4389f2a4a106d0d316f481ba6943
2017-03-15 07:47:24 -07:00
Nikolai Johan Heum
a7855d15ac consistent use of finall class
Summary:
You are already using `final class` as the default swift declaration as I guess most people agree this is best practice for classes you are not planning to inherit from :) So I just made the example code more consistent.

I will not add much more reasoning to why, other than open source projects like this is a _big_ inspirations and starting ground to play with swift for new develoeprs joining the iOS community. Nuding them to ask the right questions (composition vs inheritance) early could only be a good thing (?)

- [X] All tests pass. Demo project builds and runs.
- [X] No new tests. No new classes.
- [X] No breaking changes.
- [X] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/539

Differential Revision: D4696591

Pulled By: rnystrom

fbshipit-source-id: 73539b907452ec0cb7a8e842a95cb4fd27138f2f
2017-03-12 13:17:54 -07:00
Ryan Nystrom
6bdcac81d8 Layout invalidation API
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
2017-02-21 15:30:56 -08:00
charles
1f33a77412 Add Example-iOS in ObjC
Summary:
Related issue: [#425](https://github.com/Instagram/IGListKit/issues/425)

- [ ] 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/446

Differential Revision: D4589989

Pulled By: rnystrom

fbshipit-source-id: df91f10e0896dfe2f39a643f68e7ebd91e8461cb
2017-02-20 16:18:21 -08:00
Ryan Nystrom
1b70435993 Add stacked section controller demo
Summary:
Adding a pretty basic stacked demo. 3 different sections, each with 3 child section controllers that handle an `Int` data.

Requires #354 to be fully functional (working range).

Closes #134

- [x] All tests pass. Demo project builds and runs.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/355

Differential Revision: D4363859

Pulled By: jessesquires

fbshipit-source-id: 5dbc8e18388fed4930f189e3477ff57f0edf2d13
2016-12-22 14:29:08 -08:00
Daniel Rosado
90cf9d5dfb Fix crash in Examples-iOS app when tapping "Mixed Data"
Summary:
Fix crash in Examples-iOS app when tapping "Mixed Data"

Make GridItem conform to IGListDiffable now that NSObject+IGListDiffable category has been removed.

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

Differential Revision: D4224337

Pulled By: jessesquires

fbshipit-source-id: 16a437c4e5e45185481b4262ea7770f4a8559618
2016-11-22 17:14:00 -08:00
Ryan Nystrom
316fbe2b8b Remove NSObject+IGListDiffable category
Summary: Removing the category entirely (recreated for unit tests and examples). Went through and updated all of Instagram so we don't rely on the category and found a few models that needed cleaning up.

Reviewed By: jessesquires

Differential Revision: D4206552

fbshipit-source-id: ee8147e8872ea19f6c8bd8072df61eed5bffb6f3
2016-11-21 16:59:00 -08:00
Bofei Zhu
1d3e58b9fd Create a grid layout for IGList
Summary:
Rebase from #140:

Create a flow layout for IGList that does not newline sections. Closes #3

- [x] Minimum inter-item spacing
- [x] Minimum line spacing
- [x] Constant item size with constant layout time
- [x] Update layout on insert/delete/move
- [x] Unit Test
Closes https://github.com/Instagram/IGListKit/pull/225

Differential Revision: D4211469

Pulled By: rnystrom

fbshipit-source-id: f4710dbf195701098ac50f94b6b2aa8c801b2a83
2016-11-21 13:29:04 -08:00
Jesse Squires
879260b417 internal diff for PR #209
Summary: https://github.com/Instagram/IGListKit/pull/209

Reviewed By: rnystrom

Differential Revision: D4190633

fbshipit-source-id: 9d382b9ba3f3d20c8b9c48d900650ec354bc9728
2016-11-16 12:44:19 -08:00