import * as React from 'react';
import { View } from 'react-native';
import Animated, {
interpolate,
interpolateColor,
useAnimatedStyle,
} from 'react-native-reanimated';
import Carousel from 'rn-animated-carousel';
import type { TAnimationStyle } from '../../../src/layouts/BaseLayout';
import { SBItem } from '../components/SBItem';
import SButton from '../components/SButton';
import { ElementsText, window } from '../constants';
const PAGE_WIDTH = window.width;
function Index() {
const [isAutoPlay, setIsAutoPlay] = React.useState(false);
const animationStyle: TAnimationStyle = React.useCallback(
(value: number) => {
'worklet';
const zIndex = interpolate(value, [-1, 0, 1], [10, 20, 30]);
const translateX = interpolate(
value,
[-2, 0, 1],
[-PAGE_WIDTH, 0, PAGE_WIDTH]
);
return {
transform: [{ translateX }],
zIndex,
};
},
[]
);
return (
{
return (
);
}}
customAnimation={animationStyle}
scrollAnimationDuration={1200}
/>
{
setIsAutoPlay(!isAutoPlay);
}}
>
{ElementsText.AUTOPLAY}:{`${isAutoPlay}`}
);
}
interface ItemProps {
index: number;
animationValue: Animated.SharedValue;
}
const CustomItem: React.FC = ({ index, animationValue }) => {
const maskStyle = useAnimatedStyle(() => {
const backgroundColor = interpolateColor(
animationValue.value,
[-1, 0, 1],
['#000000dd', 'transparent', '#000000dd']
);
return {
backgroundColor,
};
}, [animationValue]);
return (
);
};
export default Index;