Animate header color
This commit is contained in:
@@ -4,6 +4,7 @@ import Animated, {
|
|||||||
interpolate,
|
interpolate,
|
||||||
runOnUI,
|
runOnUI,
|
||||||
scrollTo,
|
scrollTo,
|
||||||
|
SharedValue,
|
||||||
useAnimatedReaction,
|
useAnimatedReaction,
|
||||||
useAnimatedRef,
|
useAnimatedRef,
|
||||||
useAnimatedStyle,
|
useAnimatedStyle,
|
||||||
@@ -189,7 +190,7 @@ export function TabBar({
|
|||||||
<TabBarItem
|
<TabBarItem
|
||||||
index={i}
|
index={i}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
selected={i === selectedPage}
|
dragProgress={dragProgress}
|
||||||
item={item}
|
item={item}
|
||||||
onPressItem={onPressItem}
|
onPressItem={onPressItem}
|
||||||
/>
|
/>
|
||||||
@@ -221,17 +222,25 @@ export function TabBar({
|
|||||||
function TabBarItem({
|
function TabBarItem({
|
||||||
index,
|
index,
|
||||||
testID,
|
testID,
|
||||||
selected,
|
dragProgress,
|
||||||
item,
|
item,
|
||||||
onPressItem,
|
onPressItem,
|
||||||
}: {
|
}: {
|
||||||
index: number
|
index: number
|
||||||
testID: string | undefined
|
testID: string | undefined
|
||||||
selected: boolean
|
dragProgress: SharedValue<number>
|
||||||
item: string
|
item: string
|
||||||
onPressItem: (index: number) => void
|
onPressItem: (index: number) => void
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
const style = useAnimatedStyle(() => ({
|
||||||
|
opacity: interpolate(
|
||||||
|
dragProgress.get(),
|
||||||
|
[index - 1, index, index + 1],
|
||||||
|
[0.7, 1, 0.7],
|
||||||
|
'clamp',
|
||||||
|
),
|
||||||
|
}))
|
||||||
return (
|
return (
|
||||||
<PressableWithHover
|
<PressableWithHover
|
||||||
testID={`${testID}-selector-${index}`}
|
testID={`${testID}-selector-${index}`}
|
||||||
@@ -239,15 +248,15 @@ function TabBarItem({
|
|||||||
hoverStyle={pal.viewLight}
|
hoverStyle={pal.viewLight}
|
||||||
onPress={() => onPressItem(index)}
|
onPress={() => onPressItem(index)}
|
||||||
accessibilityRole="tab">
|
accessibilityRole="tab">
|
||||||
<View style={[styles.itemInner]}>
|
<Animated.View style={[style, styles.itemInner]}>
|
||||||
<Text
|
<Text
|
||||||
emoji
|
emoji
|
||||||
type="lg-bold"
|
type="lg-bold"
|
||||||
testID={testID ? `${testID}-${item}` : undefined}
|
testID={testID ? `${testID}-${item}` : undefined}
|
||||||
style={[selected ? pal.text : pal.textLight, {lineHeight: 20}]}>
|
style={[pal.text, {lineHeight: 20}]}>
|
||||||
{item}
|
{item}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</Animated.View>
|
||||||
</PressableWithHover>
|
</PressableWithHover>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user