diff options
author | dan <dan.abramov@gmail.com> | 2024-12-03 01:29:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-03 01:29:45 +0000 |
commit | cd811114ef0fc1164b8909e3debda792cd2a659c (patch) | |
tree | c866398bb1fec935c3d61305a0530d220fcbad1d /src/view/com/pager/PagerWithHeader.tsx | |
parent | 5a313c2d10b112458830b3bfc708031f6f8726a0 (diff) | |
download | voidsky-cd811114ef0fc1164b8909e3debda792cd2a659c.tar.zst |
[Nicer Tabs] New native pager (#6868)
* Remove tab bar autoscroll This will be replaced by a different mechanism. * Track pager drag gesture in a worklet * Track pager state change in a worklet * Track offset relative to current page * Sync scroll to swipe * Extract TabBarItem * Sync scroll to swipe properly * Implement all interactions * Clarify more hacks * Simplify the implementation I was trying to be too smart and this was causing the current page event to lag behind if you continuously drag. Better to let the library do its job. * Interpolate the indicator * Fix an infinite swipe loop * Add TODO * Animate header color * Respect initial page * Keep layouts in a shared value * Fix profile and types * Fast path for initial styles * Scroll to initial * Factor out a helper * Fix positioning * Scroll into view on tap if needed * Divide free space proportionally * Scroll into view more aggressively * Fix corner case * Ignore spurious event on iOS * Simplify the condition Due to RN onLayout event ordering, we know that by now we'll have container and content sizes already. * Change boolean state to enum * Better syncing heuristic * Rm extra return
Diffstat (limited to 'src/view/com/pager/PagerWithHeader.tsx')
-rw-r--r-- | src/view/com/pager/PagerWithHeader.tsx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/view/com/pager/PagerWithHeader.tsx b/src/view/com/pager/PagerWithHeader.tsx index 1aa45ffba..617445964 100644 --- a/src/view/com/pager/PagerWithHeader.tsx +++ b/src/view/com/pager/PagerWithHeader.tsx @@ -97,6 +97,8 @@ export const PagerWithHeader = React.forwardRef<PagerRef, PagerWithHeaderProps>( scrollY={scrollY} testID={testID} allowHeaderOverScroll={allowHeaderOverScroll} + dragProgress={props.dragProgress} + dragState={props.dragState} /> </PagerHeaderProvider> ) @@ -226,6 +228,8 @@ let PagerTabBar = ({ onCurrentPageSelected, onSelect, allowHeaderOverScroll, + dragProgress, + dragState, }: { currentPage: number headerOnlyHeight: number @@ -239,6 +243,8 @@ let PagerTabBar = ({ onCurrentPageSelected?: (index: number) => void onSelect?: (index: number) => void allowHeaderOverScroll?: boolean + dragProgress: SharedValue<number> + dragState: SharedValue<'idle' | 'dragging' | 'settling'> }): React.ReactNode => { const headerTransform = useAnimatedStyle(() => { const translateY = Math.min(scrollY.get(), headerOnlyHeight) * -1 @@ -297,6 +303,8 @@ let PagerTabBar = ({ selectedPage={currentPage} onSelect={onSelect} onPressSelected={onCurrentPageSelected} + dragProgress={dragProgress} + dragState={dragState} /> </View> </Animated.View> |