Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Implement delegate methods for header/footer reference size #121

Merged
merged 10 commits into from
Aug 5, 2019

Conversation

christoff-1992
Copy link
Collaborator

This implements the delegate methods for header/footer reference sizes so they can be provided just like we do for the items.

This will allow users to provide dynamic heights for headers and footers if they wish.

@christoff-1992 christoff-1992 added the enhancement New feature or request label Jul 31, 2019
@christoff-1992 christoff-1992 requested a review from zenangst July 31, 2019 09:27
@christoff-1992 christoff-1992 self-assigned this Jul 31, 2019
Copy link
Owner

@zenangst zenangst left a comment

Choose a reason for hiding this comment

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

I think this looks great, just had some questions about zIndex.
Perhaps we already have that issue now, I just saw it 😄

)
layoutAttribute.size = resolveSizeForSupplementaryView(ofKind: .header, at: sectionIndexPath)
layoutAttribute.zIndex = numberOfSections
Copy link
Owner

Choose a reason for hiding this comment

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

@christoff-1992 Shouldn't we use section instead of setting the same zIndex for all attributes?

Copy link
Owner

Choose a reason for hiding this comment

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

We should just change it to section, then it would be incremental?

)
layoutAttribute.size = resolveSizeForSupplementaryView(ofKind: .footer, at: sectionIndexPath)
layoutAttribute.zIndex = numberOfSections
Copy link
Owner

Choose a reason for hiding this comment

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

Same question here as the previous comments.

width = headerReferenceSize.width
} else {
width = collectionView?.documentRect.width ?? headerReferenceSize.width
}
Copy link
Owner

Choose a reason for hiding this comment

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

Should you also be able to provide a width using the delegate or do you reckon that height would be enough?
Don't know how useful it would be to provide a width, what are your thoughts @christoff-1992

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm that's a good point, I don't know why you would have it anything other than the collection view's width but it's one of the options for the delegate methods since you provide the size. 🤷‍♂️

Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps the delegate should take precedence here if it exists. What do you think?

Copy link
Collaborator Author

@christoff-1992 christoff-1992 Aug 2, 2019

Choose a reason for hiding this comment

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

Hmmm.. true but if the size is 0 it's not going to be visible hence why I took the collection views width before.

Copy link
Owner

Choose a reason for hiding this comment

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

But wouldn't you expect it to be zero if you delegate method returns zero?
I think it would be more frustrating if you try and set the width and you don't get the expected result.

@christoff-1992
Copy link
Collaborator Author

christoff-1992 commented Aug 2, 2019

Ahh regarding the zIndex take a look.. it will make the cells scroll over the section, I think we need to offset this as it starts at 0.

@christoff-1992
Copy link
Collaborator Author

@zenangst - Although even without the zIndex changes have you seen the example project.. take a look at the footers, there a bit funky.. with sticking to the bottom. Do you think this is the invalidation context?

@zenangst
Copy link
Owner

zenangst commented Aug 4, 2019

@christoff-1992 I pushed some changes to the branch, I think I figured out what was going wrong. Mind taking it for a spin? 😄

@christoff-1992
Copy link
Collaborator Author

@christoff-1992 I pushed some changes to the branch, I think I figured out what was going wrong. Mind taking it for a spin? 😄

Looking good :D

@zenangst zenangst merged commit c0a4d89 into master Aug 5, 2019
@zenangst zenangst deleted the Dynamic-height-for-supplementary-views branch August 5, 2019 08:03
@zenangst
Copy link
Owner

zenangst commented Aug 5, 2019

@christoff-1992 good job mate!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants