diff --git a/mobile/package.json b/mobile/package.json index 1019e19..8d752d8 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -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": "*", diff --git a/mobile/src/components/fall.tsx b/mobile/src/components/fall.tsx new file mode 100644 index 0000000..eb31beb --- /dev/null +++ b/mobile/src/components/fall.tsx @@ -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 {children}; +} diff --git a/mobile/src/components/today/hero.tsx b/mobile/src/components/today/hero.tsx index 532a1e5..b260140 100644 --- a/mobile/src/components/today/hero.tsx +++ b/mobile/src/components/today/hero.tsx @@ -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 = { 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 {children}; -} - /** 둥근 구름: 몸통 위에 동그라미 둘을 겹친다 (웹 .b-cloud ::before/::after) */ function Cloud({ w, h, night }: { w: number; h: number; night: boolean }) { const bg = night ? '#c9cdf0' : '#fff'; diff --git a/package-lock.json b/package-lock.json index 5a36d01..ec66e20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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",