feat: 앱을 웹과 맞춤 — 좋아요 하트·토스트, 별똥별, 단풍잎, 고운바탕, 안내 높이 유지, 시트 배경 페이드
This commit is contained in:
1 parent
865c521ab8
commit
b5d9adf396
19 files changed
+247
-52
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import type { TimeKind } from '@nalssigak/shared/lib';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useEffect } from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
import { StyleSheet, View, type DimensionValue } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
|
||||
import { useSky } from '@/lib/sky';
|
||||
|
||||
@@ -43,7 +43,40 @@ function Star({ star, reduce }: { star: (typeof STARS)[number]; reduce: boolean
|
||||
return <Animated.View style={[{ position: 'absolute', left: star.left, top: star.top, width: star.size, height: star.size, borderRadius: star.size, backgroundColor: '#fff', boxShadow: '0 0 6px rgb(255 255 255 / 0.8)' }, style]} />;
|
||||
}
|
||||
|
||||
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝인다 */
|
||||
export type ShootSpec = { top: DimensionValue; left: DimensionValue; len: number; dur: number; dl: number };
|
||||
|
||||
// 별똥별: 위치·길이·주기를 엇갈려 몇 초마다 하나씩 떨어지게 (웹 BLayout SHOOTS, 밀리초)
|
||||
const SHOOTS: ShootSpec[] = [
|
||||
{ top: '8%', left: '78%', len: 110, dur: 7000, dl: 1000 },
|
||||
{ top: '22%', left: '46%', len: 80, dur: 9000, dl: 3500 },
|
||||
{ top: '5%', left: '30%', len: 95, dur: 8000, dl: 5500 },
|
||||
{ top: '36%', left: '88%', len: 70, dur: 10000, dl: 2200 },
|
||||
{ top: '52%', left: '62%', len: 90, dur: 11000, dl: 7000 },
|
||||
{ top: '14%', left: '96%', len: 120, dur: 12000, dl: 9000 },
|
||||
];
|
||||
|
||||
/** 별똥별 하나: 주기 끝 14% 동안만 비스듬히 240px 미끄러지며 반짝 (웹 .b-shoot). 동작 줄이기면 그리지 않는다 */
|
||||
export function Shoot({ top, left, len, dur, dl }: ShootSpec) {
|
||||
const reduce = useReducedMotion();
|
||||
const p = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
if (reduce) return;
|
||||
p.value = withDelay(dl, withRepeat(withTiming(1, { duration: dur, easing: Easing.in(Easing.ease) }), -1, false));
|
||||
return () => cancelAnimation(p);
|
||||
}, [reduce, dur, dl, p]);
|
||||
const style = useAnimatedStyle(() => ({
|
||||
opacity: interpolate(p.value, [0, 0.86, 0.89, 1], [0, 0, 1, 0]),
|
||||
transform: [{ rotate: '-24deg' }, { translateX: interpolate(p.value, [0, 0.86, 1], [0, 0, -240]) }],
|
||||
}));
|
||||
if (reduce) return null;
|
||||
return (
|
||||
<Animated.View style={[{ position: 'absolute', top, left, width: len, height: 1.5 }, style]}>
|
||||
<LinearGradient colors={['rgba(255,255,255,0)', '#ffffff']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={{ flex: 1, borderRadius: 2 }} />
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝이고 별똥별이 떨어진다 */
|
||||
export function SkyBg() {
|
||||
const { kind } = useSky();
|
||||
const reduce = useReducedMotion();
|
||||
@@ -53,6 +86,7 @@ export function SkyBg() {
|
||||
<Layer key={k} kind={k} on={k === kind} reduce={reduce} />
|
||||
))}
|
||||
{kind === 'night' && STARS.map((s, i) => <Star key={i} star={s} reduce={reduce} />)}
|
||||
{kind === 'night' && SHOOTS.map((s, i) => <Shoot key={i} {...s} />)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user