-
Notifications
You must be signed in to change notification settings - Fork 346
[feat] Introduce stickyHeaderConfig (offset, backdrop, native driver, hide cell) and onChangeStickyIndex #1953
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
Conversation
2e4a922 to
b52a523
Compare
src/recyclerview/RecyclerView.tsx
Outdated
| {renderEmpty} | ||
| {renderFooter} | ||
| </CompatScrollView> | ||
| {stickyHeaderIndices ? renderStickyHeaderBackground : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it something generic. Atleast the name
src/recyclerview/RecyclerView.tsx
Outdated
| {renderHeader} | ||
| {!isHorizontalRTL && viewToMeasureBoundedSize} | ||
| {/* Spacer for sticky header offset */} | ||
| {stickyHeaderIndices && stickyHeaderOffset > 0 && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's handle this using contentContainerStyle padding
b52a523 to
1fb193a
Compare
1fb193a to
6adb670
Compare
| outputRange: [0, -currentStickyHeight], | ||
| extrapolate: "clamp", | ||
| }), | ||
| opacity: stickyHeaderOffset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put an explicit check > 0
| getY: (index: number) => number | ||
| ): number { | ||
| // Special case: when at the top of the list, show the first sticky header if it's near the top | ||
| if (adjustedValue <= 0 && sortedIndices.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this a bit more?
| style={{ | ||
| position: "absolute", | ||
| inset: 0, | ||
| zIndex: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The zIndex isn't needed I think
| /** Additional data to trigger re-renders */ | ||
| extraData: FlashListProps<TItem>["extraData"]; | ||
| /** Sticky header change handler */ | ||
| onChangeStickyIndex?: (index: number) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a useful prop on FlashList too. onChangeStickyIndex: (current, previous) => void. Let's add it.
6adb670 to
98e5177
Compare
| } | ||
| } | ||
|
|
||
| console.log("RESULT", result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing log statement
src/recyclerview/RecyclerView.tsx
Outdated
| {renderEmpty} | ||
| {renderFooter} | ||
| </CompatScrollView> | ||
| {stickyHeaderIndices ? renderStickyHeaderBackdrop : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check length also, in case it's empty
src/recyclerview/RecyclerView.tsx
Outdated
| <CompatView | ||
| style={{ | ||
| height: horizontal ? undefined : 0, | ||
| height: horizontal ? undefined : 0 + stickyHeaderOffset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. It can throw off compute. I think we discussed doing this will padding instead. You can also try applying it as marginTop here.
3585f42 to
76355de
Compare
… offset spacer, background layer, and header hiding; update docs/changelog and add StickyHeader example in RN fixture
76355de to
3da7a69
Compare
What problem does this PR solve?
Sticky headers lacked key capabilities needed in real apps:
This PR adds configuration and APIs to control sticky header behavior and appearance, while keeping defaults backward compatible.
Changes
Test Plan