From f2522aafdd8013402de2f086324b53378478f2c8 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 30 Nov 2024 13:51:50 +0000 Subject: [PATCH] Animate header color --- src/view/com/pager/TabBar.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/view/com/pager/TabBar.tsx b/src/view/com/pager/TabBar.tsx index a8a02e57fe..73a2a4c1c0 100644 --- a/src/view/com/pager/TabBar.tsx +++ b/src/view/com/pager/TabBar.tsx @@ -4,6 +4,7 @@ import Animated, { interpolate, runOnUI, scrollTo, + SharedValue, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, @@ -189,7 +190,7 @@ export function TabBar({ @@ -221,17 +222,25 @@ export function TabBar({ function TabBarItem({ index, testID, - selected, + dragProgress, item, onPressItem, }: { index: number testID: string | undefined - selected: boolean + dragProgress: SharedValue item: string onPressItem: (index: number) => void }) { const pal = usePalette('default') + const style = useAnimatedStyle(() => ({ + opacity: interpolate( + dragProgress.get(), + [index - 1, index, index + 1], + [0.7, 1, 0.7], + 'clamp', + ), + })) return ( onPressItem(index)} accessibilityRole="tab"> - + + style={[pal.text, {lineHeight: 20}]}> {item} - + ) }