feat: 앱을 웹과 맞춤 — 좋아요 하트·토스트, 별똥별, 단풍잎, 고운바탕, 안내 높이 유지, 시트 배경 페이드
This commit is contained in:
1 parent
865c521ab8
commit
b5d9adf396
19 files changed
+247
-52
No files matched your search
@@ -0,0 +1,64 @@
|
||||
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 (
|
||||
<Animated.View style={[{ position: 'absolute' }, style]}>
|
||||
<Svg viewBox="0 0 24 24" width={20} height={20} fill={color}>
|
||||
<Path d={HEART} />
|
||||
</Svg>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<Animated.View className="absolute top-[58%] rounded-full bg-white px-4 py-2" style={[{ boxShadow: '0 8px 18px rgb(40 48 74 / 0.18)' }, style]}>
|
||||
<Animated.Text className="font-jua text-[17px] text-heart">좋아요했어요!</Animated.Text>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 좋아요 때 하트 조각이 튀어 나가고 '좋아요했어요!' 가 떴다 사라진다 */
|
||||
export function LikeBurst() {
|
||||
const reduce = useReducedMotion();
|
||||
if (reduce) return null;
|
||||
return (
|
||||
<View pointerEvents="none" className="absolute inset-0 items-center justify-center" accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
||||
{BURST.map(([dx, dy, rot, color], k) => (
|
||||
<Bit key={k} dx={dx} dy={dy} rot={rot} color={color} />
|
||||
))}
|
||||
<Toast />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import Svg, { Path } from 'react-native-svg';
|
||||
import { useCSSVariable } from 'uniwind';
|
||||
|
||||
import { CommentIcon, HEART, HeartIcon, SendIcon } from '@/components/post/icons';
|
||||
import { LikeBurst } from '@/components/post/like-burst';
|
||||
import { Dots, Pager } from '@/components/post/pager';
|
||||
import { slideBg, SlideView } from '@/components/post/slides';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
@@ -197,6 +198,7 @@ function FullCard({ post }: PostProps) {
|
||||
</View>
|
||||
)}
|
||||
{pop > 0 && <HeartPop key={pop} />}
|
||||
{pop > 0 && <LikeBurst key={`b${pop}`} />}
|
||||
{likeFailed > 0 && (
|
||||
<View pointerEvents="none" className="absolute inset-x-0 bottom-4 items-center px-4" accessibilityRole="alert">
|
||||
<Text className="overflow-hidden rounded-full bg-[rgb(30_36_56/0.82)] px-3.5 py-2 text-[13px] font-bold text-white">{liked ? '좋아요를 취소하지 못했어요' : '좋아요를 반영하지 못했어요'}. 다시 해 주세요.</Text>
|
||||
|
||||
Reference in new issue
Block a user