Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support supplementaryViews created from nibs #90

Closed
wants to merge 4 commits into from

Conversation

rawlinxx
Copy link

Changes in this pull request

Summary: add dequeueReusableSupplementaryView with nib

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@rnystrom
Copy link
Contributor

@rawlinxx this is awesome! Thanks for taking this on.

In order to merge this, we're going to have to add some unit tests. Take a look at #56 for an example of requirements for this.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind
forSectionController:(IGListSectionController <IGListSectionType> *)sectionController
nibName:(NSString *)nibName
bundle:(NSBundle *)bundle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need this to be nullable: bundle:(nullable NSBundle *)bundle

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right! just like the documentation i copied said :)

nibName:(NSString *)nibName
bundle:(NSBundle *)bundle
atIndex:(NSInteger)index {
IGAssertMainThread();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add:

IGParameterAssert([nibName length] > 0);
IGParameterAssert([elementKind length] > 0);

I realize those are also missing from other methods. Adding some starter tasks for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bundle should be nullable here, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, I'm trying this framework, hope to have this feature ASAP, without attention to details

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rawlinxx no worries! PRs are an iterative process, its good to get something up and we can all work on it together 👨‍👩‍👧‍👦

atIndex:(NSInteger)index
{
const NSUInteger offset = [self offsetForSectionController:sectionController];
return (UICollectionViewCell *_Nonnull)[self.collectionContext dequeueReusableSupplementaryViewOfKind:elementKind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this cast?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not quite understand why (UICollectionViewCell *_Nonnull) is needed here, just following the previous method implementation since I have not read all the source code yet, i think UICollectionReusableView is more suitable here, am i wrong?

@jessesquires
Copy link
Contributor

Also need to update the CHANGELOG.md -- add an entry under the 2.0.0 release 😄

@facebook-github-bot
Copy link
Contributor

@rawlinxx updated the pull request - view changes

@@ -759,6 +761,25 @@ - (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(N
return [collectionView dequeueReusableSupplementaryViewOfKind:elementKind withReuseIdentifier:identifier forIndexPath:indexPath];
}

- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind
forSectionController:(IGListSectionController <IGListSectionType> *)sectionController
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's remove the space between IGListSectionController<IGListSectionType>

@note This method uses a string representation of the view class as the identifier.
*/
- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind
forSectionController:(IGListSectionController <IGListSectionType> *)sectionController
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing between class and protocol

forSectionController:self
class:viewClass
atIndex:(index + offset)];
}

- (UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind
forSectionController:(IGListSectionController <IGListSectionType> *)sectionController
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing between class/protocol

forSectionController:self
nibName:nibName
bundle:bundle
atIndex:(index + offset)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we realign the colons?

nibName:(NSString *)nibName
bundle:(NSBundle *)bundle
atIndex:(NSInteger)index
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curly needs to be on the same line as the last param

atIndex:(NSInteger)index
{
const NSUInteger offset = [self offsetForSectionController:sectionController];
return (UICollectionReusableView *_Nonnull)[self.collectionContext dequeueReusableSupplementaryViewOfKind:elementKind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think UICollectionReusableView is more suitable here, am i wrong?

Hmm I'm actually not sure why we're casting it in the other methods. I just tried it locally and we can remove those. I wouldn't worry about it now. Can we revert the UICollectionReusableView changes? We can do cleanup in another PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@facebook-github-bot
Copy link
Contributor

@rawlinxx updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@rawlinxx updated the pull request - view changes

@coveralls
Copy link

coveralls commented Oct 24, 2016

Coverage Status

Coverage decreased (-0.8%) to 85.123% when pulling 17bb25e on rawlinxx:master into 8ccdc83 on Instagram:master.

@rnystrom
Copy link
Contributor

@rawlinxx Circling back to this, we wont be able to land until we add some unit tests. #56 added nib support for cells along w/ some unit tests. If we can basically copy exactly what we added there we'll be able to merge!

@zhubofei
Copy link

zhubofei commented Nov 3, 2016

Any update on this PR 🤔?

@rawlinxx rawlinxx closed this Nov 3, 2016
@jessesquires
Copy link
Contributor

Re-opening. @rawlinxx - was this closed by mistake?

@jessesquires jessesquires reopened this Nov 3, 2016
@jessesquires
Copy link
Contributor

@rnystrom - If needed, we can push commits directly to this PR for tests and carry it forward.

@jessesquires
Copy link
Contributor

We're carrying these changes forward with some small modifications/additions in #162.

Closing in favor of #162.

facebook-github-bot pushed a commit that referenced this pull request Nov 5, 2016
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 #162

Differential Revision: D4137364

Pulled By: rnystrom

fbshipit-source-id: d8418ac5728fd6d9570fa1d1568f4343f5c4112b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants