refactor: 앱 떨어지고 둥둥 움직임(Fall)을 공통 컴포넌트로, 고운바탕 글꼴 패키지 추가

This commit is contained in:
minaChoi committed 2026-10-14 15:10:09 +09:00
1 parent d56e906371
commit 865c521ab8
4 files changed
+39 -27

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
"version": "1.0.0",
"dependencies": {
"@expo-google-fonts/bagel-fat-one": "^0.4.0",
"@expo-google-fonts/gowun-batang": "^0.4.1",
"@expo-google-fonts/jua": "^0.4.1",
"@expo/ui": "~57.0.23",
"@nalssigak/shared": "*",
+29
View File
@@ -0,0 +1,29 @@
import { useEffect, type ReactNode } from 'react';
import type { ViewStyle } from 'react-native';
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
/** 하늘에서 떨어진 뒤 둥둥 (웹 b-fall: b-drop 1.05초 뒤 b-float 무한). d·f 는 밀리초 */
export function Fall({ d, f, amp = 9, style, children }: { d: number; f: number; amp?: number; style?: ViewStyle; children: ReactNode }) {
const reduce = useReducedMotion();
const drop = useSharedValue(reduce ? 1 : 0);
const float = useSharedValue(0);
useEffect(() => {
if (reduce) return;
drop.value = withDelay(d, withTiming(1, { duration: 1050, easing: Easing.bezier(0.22, 0.9, 0.3, 1) }));
float.value = withDelay(d + 1050, withRepeat(withTiming(1, { duration: f / 2, easing: Easing.inOut(Easing.ease) }), -1, true));
return () => {
cancelAnimation(drop);
cancelAnimation(float);
};
}, [reduce, d, f, drop, float]);
const anim = useAnimatedStyle(() => {
const p = drop.value;
const y = interpolate(p, [0, 0.72, 0.86, 1], [-400, 0, -10, 0]) - amp * float.value;
const rot = interpolate(p, [0, 0.72, 1], [-10, 2, 0]) + 1.2 * float.value;
return {
opacity: interpolate(p, [0, 0.55, 1], [0, 1, 1]),
transform: [{ translateY: y }, { rotate: `${rot}deg` }, { scaleX: interpolate(p, [0, 0.72, 0.86, 1], [1, 1.04, 1, 1]) }, { scaleY: interpolate(p, [0, 0.72, 0.86, 1], [1, 0.96, 1, 1]) }],
};
});
return <Animated.View style={[style, anim]}>{children}</Animated.View>;
}
+2 -27
View File
@@ -4,10 +4,11 @@ import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON,
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText';
import { useEffect, useState, type ReactNode } from 'react';
import { Pressable, Text, View, type DimensionValue, type ViewStyle } from 'react-native';
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
import { LinearGradient } from 'expo-linear-gradient';
import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
import { Fall } from '@/components/fall';
import { Ic, Skel } from '@/components/ui';
import { useSheet } from '@/lib/sheet';
import { useSky } from '@/lib/sky';
@@ -41,32 +42,6 @@ const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain:
const DROPS = Array.from({ length: 22 }, (_, i) => ({ left: `${(i * 41) % 100}%`, top: `${(i * 29) % 90}%`, delay: ((i * 37) % 100) * 10, dur: 550 + ((i * 13) % 5) * 100 }) as const);
const FLAKES = Array.from({ length: 16 }, (_, i) => ({ left: `${(i * 47) % 100}%`, top: `${(i * 31) % 90}%`, delay: ((i * 53) % 100) * 40, dur: 3200 + ((i * 7) % 5) * 500 }) as const);
/** 하늘에서 떨어진 뒤 둥둥 (웹 b-fall: b-drop 1.05초 뒤 b-float 무한). d·f 는 밀리초 */
function Fall({ d, f, amp = 9, style, children }: { d: number; f: number; amp?: number; style?: ViewStyle; children: ReactNode }) {
const reduce = useReducedMotion();
const drop = useSharedValue(reduce ? 1 : 0);
const float = useSharedValue(0);
useEffect(() => {
if (reduce) return;
drop.value = withDelay(d, withTiming(1, { duration: 1050, easing: Easing.bezier(0.22, 0.9, 0.3, 1) }));
float.value = withDelay(d + 1050, withRepeat(withTiming(1, { duration: f / 2, easing: Easing.inOut(Easing.ease) }), -1, true));
return () => {
cancelAnimation(drop);
cancelAnimation(float);
};
}, [reduce, d, f, drop, float]);
const anim = useAnimatedStyle(() => {
const p = drop.value;
const y = interpolate(p, [0, 0.72, 0.86, 1], [-400, 0, -10, 0]) - amp * float.value;
const rot = interpolate(p, [0, 0.72, 1], [-10, 2, 0]) + 1.2 * float.value;
return {
opacity: interpolate(p, [0, 0.55, 1], [0, 1, 1]),
transform: [{ translateY: y }, { rotate: `${rot}deg` }, { scaleX: interpolate(p, [0, 0.72, 0.86, 1], [1, 1.04, 1, 1]) }, { scaleY: interpolate(p, [0, 0.72, 0.86, 1], [1, 0.96, 1, 1]) }],
};
});
return <Animated.View style={[style, anim]}>{children}</Animated.View>;
}
/** 둥근 구름: 몸통 위에 동그라미 둘을 겹친다 (웹 .b-cloud ::before/::after) */
function Cloud({ w, h, night }: { w: number; h: number; night: boolean }) {
const bg = night ? '#c9cdf0' : '#fff';
+7
View File
@@ -39,6 +39,7 @@
"version": "1.0.0",
"dependencies": {
"@expo-google-fonts/bagel-fat-one": "^0.4.0",
"@expo-google-fonts/gowun-batang": "^0.4.1",
"@expo-google-fonts/jua": "^0.4.1",
"@expo/ui": "~57.0.23",
"@nalssigak/shared": "*",
@@ -1466,6 +1467,12 @@
"integrity": "sha512-f7JwE9QxBqReG9CnHzNcpM7mDVT1NErKKvbp06FTUSyDOd28Mu6PwIIfAa7JDLFwuj0r4C1uk9ui4SS+Mzj1aQ==",
"license": "MIT AND OFL-1.1"
},
"node_modules/@expo-google-fonts/gowun-batang": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@expo-google-fonts/gowun-batang/-/gowun-batang-0.4.1.tgz",
"integrity": "sha512-d0bdZaGH7Nu3sCW1c5fbtZDufA5RpE+Ph+Laa9xi9QlvHylMKS1lohZ7elhkJSy1hmJket4JeokzS4DzjGfpYg==",
"license": "MIT AND OFL-1.1"
},
"node_modules/@expo-google-fonts/jua": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@expo-google-fonts/jua/-/jua-0.4.1.tgz",