import { Box } from '@/components/ui/box';
import { Button, ButtonText } from '@/components/ui/button';
import { Center } from '@/components/ui/center';
import { HStack } from '@/components/ui/hstack';
import { Text } from '@/components/ui/text';
import { Toast, ToastDescription, ToastTitle, useToast } from '@/components/ui/toast';
import { useCounterDispatch, useCounterState } from '@/states/CounterProvider';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Animated, {
useSharedValue,
useAnimatedStyle,
withSequence,
withTiming,
} from 'react-native-reanimated';
export default function IndexPage() {
const state = useCounterState();
const dispatch = useCounterDispatch();
const toast = useToast();
const insets = useSafeAreaInsets();
const bounceY = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateY: bounceY.value }],
}));
const onPress = () => {
const totalDuration = 500;
bounceY.value = 0; // 항상 리셋
bounceY.value = withSequence(
withTiming(-16, { duration: totalDuration * 0.3 }), // 위로 빠르게
withTiming(4, { duration: totalDuration * 0.3 }), // 아래로 반동
withTiming(-8, { duration: totalDuration * 0.2 }), // 위로 살짝
withTiming(0, { duration: totalDuration * 0.2 }) // 원위치
);
toast.show({
placement: 'top',
duration: 2000,
render: () => {
return (
타이틀
설명
);
},
});
};
return (
Count: {state.count}
Text1
Text2
);
}