import { useEffect } from 'react';
import { View } from 'react-native';
import Animated, { Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
import Svg, { Path } from 'react-native-svg';
import { HEART } from '@/components/post/icons';
// 튀어 나가는 작은 하트: x·y 이동, 회전, 색 (웹 BURST)
const BURST: [number, number, number, string][] = [
[-86, -60, -24, '#ff3b5c'],
[84, -66, 22, '#ff8e4e'],
[-104, 18, -40, '#ffc86e'],
[102, 24, 36, '#ff3b5c'],
[-48, -104, -8, '#ff8aa0'],
[52, -100, 12, '#ffc86e'],
];
function Bit({ dx, dy, rot, color }: { dx: number; dy: number; rot: number; color: string }) {
const p = useSharedValue(0);
useEffect(() => {
p.value = withDelay(80, withTiming(1, { duration: 900, easing: Easing.bezier(0.2, 0.8, 0.3, 1) }));
}, [p]);
const style = useAnimatedStyle(() => ({
opacity: interpolate(p.value, [0, 0.25, 1], [0, 1, 0]),
transform: [{ translateX: dx * p.value }, { translateY: dy * p.value }, { scale: interpolate(p.value, [0, 1], [0.4, 1.1]) }, { rotate: `${rot * p.value}deg` }],
}));
return (
);
}
function Toast() {
const p = useSharedValue(0);
useEffect(() => {
p.value = withTiming(1, { duration: 1300, easing: Easing.bezier(0.2, 0.9, 0.3, 1) });
}, [p]);
const style = useAnimatedStyle(() => ({
opacity: interpolate(p.value, [0, 0.18, 0.78, 1], [0, 1, 1, 0]),
transform: [{ translateY: interpolate(p.value, [0, 0.18, 0.78, 1], [14, 0, 0, -8]) }, { scale: interpolate(p.value, [0, 0.18, 0.3, 1], [0.85, 1.06, 1, 1]) }],
}));
return (
좋아요했어요!
);
}
/** 좋아요 때 하트 조각이 튀어 나가고 '좋아요했어요!' 가 떴다 사라진다 */
export function LikeBurst() {
const reduce = useReducedMotion();
if (reduce) return null;
return (
{BURST.map(([dx, dy, rot, color], k) => (
))}
);
}