import * as React from 'react';
import { View } from 'react-native-ui-lib';
import Carousel from 'rn-animated-carousel';
import SButton from '../components/SButton';
import { ElementsText, window } from '../constants';
import Animated, {
Extrapolate,
interpolate,
useAnimatedStyle,
} from 'react-native-reanimated';
import { withAnchorPoint } from '../utils/anchor-point';
const fruit_0 = require('../../assets/fruit-0.png');
const fruit_1 = require('../../assets/fruit-1.png');
const fruit_2 = require('../../assets/fruit-2.png');
const fruits = [fruit_0, fruit_2, fruit_1];
const colors = ['#fda282', '#fdba4e', '#800015'];
const PAGE_WIDTH = window.width;
const PAGE_HEIGHT = window.width * 1.2;
function Index() {
const [isAutoPlay, setIsAutoPlay] = React.useState(false);
const baseOptions = {
vertical: false,
width: PAGE_WIDTH,
height: PAGE_HEIGHT,
} as const;
return (
(
)}
/>
{
setIsAutoPlay(!isAutoPlay);
}}
>
{ElementsText.AUTOPLAY}:{`${isAutoPlay}`}
);
}
const Card: React.FC<{
index: number;
animationValue: Animated.SharedValue;
}> = ({ index, animationValue }) => {
const WIDTH = PAGE_WIDTH / 1.5;
const HEIGHT = PAGE_HEIGHT / 1.5;
const cardStyle = useAnimatedStyle(() => {
const scale = interpolate(
animationValue.value,
[-0.1, 0, 1],
[0.95, 1, 1],
Extrapolate.CLAMP
);
const translateX = interpolate(
animationValue.value,
[-1, -0.2, 0, 1],
[0, WIDTH * 0.3, 0, 0]
);
const transform = {
transform: [
{ scale },
{ translateX },
{ perspective: 200 },
{
rotateY: `${interpolate(
animationValue.value,
[-1, 0, 0.4, 1],
[30, 0, -25, -25],
Extrapolate.CLAMP
)}deg`,
},
],
};
return {
...withAnchorPoint(
transform,
{ x: 0.5, y: 0.5 },
{ width: WIDTH, height: HEIGHT }
),
};
}, [index]);
const blockStyle = useAnimatedStyle(() => {
const translateX = interpolate(
animationValue.value,
[-1, 0, 1],
[0, 60, 60]
);
const translateY = interpolate(
animationValue.value,
[-1, 0, 1],
[0, -40, -40]
);
const rotateZ = interpolate(
animationValue.value,
[-1, 0, 1],
[0, 0, -25]
);
return {
transform: [
{ translateX },
{ translateY },
{ rotateZ: `${rotateZ}deg` },
],
};
}, [index]);
return (
);
};
export default Index;