mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-14 20:01:58 +08:00
Refactor components for consistent styling and improve button animations
This commit is contained in:
18
hooks/useButtonAnimation.ts
Normal file
18
hooks/useButtonAnimation.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useRef, useEffect } from 'react';
|
||||
import { Animated } from 'react-native';
|
||||
|
||||
export const useButtonAnimation = (isSelected: boolean, isFocused: boolean) => {
|
||||
const scaleValue = useRef(new Animated.Value(1)).current;
|
||||
|
||||
useEffect(() => {
|
||||
Animated.spring(scaleValue, {
|
||||
toValue: isSelected || isFocused ? 1.1 : 1,
|
||||
friction: 5,
|
||||
useNativeDriver: true,
|
||||
}).start();
|
||||
}, [isSelected, isFocused, scaleValue]);
|
||||
|
||||
return {
|
||||
transform: [{ scale: scaleValue }],
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user