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

Implement pinned (sticky) header and footer #80

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

heoblitz
Copy link
Contributor

@heoblitz heoblitz commented Oct 25, 2024

What is this PR for?

This PR introduces support for pinned (sticky) headers and footers. The implementation allows headers and footers to stay visible within the collection view's bounds.

The changes will not impact existing ChatLayout users who do not utilize the pinned feature.

Related PR: airbnb/MagazineLayout#52

Tests

test project: ChatLayoutPinTest.zip

1. Scroll

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-10-25.at.22.24.45.mp4

2. Scroll with contentInsets

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-10-25.at.22.30.31.mp4

3. Dynamic cell height

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-10-25.at.22.26.14.mp4

@heoblitz heoblitz changed the title Implement Pinned (sticky) Header and Footer Implement pinned (sticky) header and footer Oct 25, 2024
@@ -619,7 +627,7 @@ open class CollectionViewChatLayout: UICollectionViewLayout {
|| (isUserInitiatedScrolling && state == .beforeUpdate)

invalidationActions.remove(.shouldInvalidateOnBoundsChange)
return shouldInvalidateLayout
return shouldInvalidateLayout || hasPinnedHeaderOrFooter
Copy link
Contributor Author

@heoblitz heoblitz Oct 25, 2024

Choose a reason for hiding this comment

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

Ensure that the footer and header are properly updated when the bounds change, in the same way as in MagazineLayout.

( The default behavior of UICollectionViewCompositionalLayout also always returns true when section pinToVisibleBounds is set. )

@heoblitz heoblitz force-pushed the feature/pinned_header_footer branch from 5791b05 to 9fdab05 Compare October 25, 2024 13:50
@ekazaev ekazaev self-requested a review October 26, 2024 16:27
@ekazaev
Copy link
Owner

ekazaev commented Oct 26, 2024

@heoblitz Amazing job. Ill have a proper look and merge. Thank you.

@ekazaev
Copy link
Owner

ekazaev commented Nov 18, 2024

@heoblitz Sorry, I was on my vacation. Got back. Will have a proper look and merge.

@heoblitz
Copy link
Contributor Author

@ekazaev Hope you had a great vacation! Please feel free to review it at your convenience. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants