feat: 앱 나머지 화면 이전 — 게시물 카드·시트·각/노을/주말/계절 탭·움직임
- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유 - 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타 - 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침 - 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
This commit is contained in:
1 parent
28ff032160
commit
f71dd2cebb
33 files changed
+2786
-75
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import type { Hero as HeroData, ResWeatherToday, TopIndex } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { kindOfHour, kst, type Load, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib';
|
||||
import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today';
|
||||
import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today';
|
||||
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText';
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
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 { LinearGradient } from 'expo-linear-gradient';
|
||||
import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
|
||||
|
||||
@@ -28,6 +29,77 @@ const ORB: Record<'sun' | 'sunset' | 'night', { stops: [string, string, string,
|
||||
};
|
||||
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }) as const);
|
||||
|
||||
// 구름 자리·떨어지는 지연·둥둥 주기 (웹 CLOUDS). 구름 수: 구름 많음 둘, 흐림·비·눈 셋
|
||||
const CLOUDS = [
|
||||
{ top: 36, left: '5%', w: 84, h: 32, d: 100, f: 6000 },
|
||||
{ top: 96, left: '63%', w: 96, h: 36, d: 250, f: 6400 },
|
||||
{ top: 30, left: '72%', w: 64, h: 28, d: 400, f: 5400 },
|
||||
] as const;
|
||||
const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain: 3, snow: 3, sleet: 3 };
|
||||
|
||||
// 비·눈 줄기: 위치·주기를 엇갈려 고르게
|
||||
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';
|
||||
const big = w * 0.46;
|
||||
const small = w * 0.36;
|
||||
return (
|
||||
<View style={{ width: w, height: h }}>
|
||||
<View style={{ position: 'absolute', left: w * 0.16, top: -h * 0.58, width: big, height: big, borderRadius: big, backgroundColor: bg }} />
|
||||
<View style={{ position: 'absolute', left: w * 0.5, top: -h * 0.36, width: small, height: small, borderRadius: small, backgroundColor: bg }} />
|
||||
<View style={{ width: w, height: h, borderRadius: h, backgroundColor: bg, boxShadow: '0 16px 28px rgb(40 70 120 / 0.13)' }} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 비 줄기·눈송이 하나: 위에서 아래로 계속 떨어진다. 동작 줄이기면 제자리에 멈춘다 */
|
||||
function Particle({ left, top, delay, dur, snow, light }: { left: DimensionValue; top: DimensionValue; delay: number; dur: number; snow: boolean; light: boolean }) {
|
||||
const reduce = useReducedMotion();
|
||||
const t = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
if (reduce) return;
|
||||
t.value = withDelay(delay, withRepeat(withTiming(1, { duration: dur, easing: Easing.linear }), -1, false));
|
||||
return () => cancelAnimation(t);
|
||||
}, [reduce, delay, dur, t]);
|
||||
const anim = useAnimatedStyle(() => ({ transform: [{ translateX: (snow ? 18 : -8) * t.value }, { translateY: 440 * t.value }] }));
|
||||
const place: ViewStyle = { position: 'absolute', left, top: reduce ? top : -24 };
|
||||
if (snow) return <Animated.View style={[place, { width: 7, height: 7, borderRadius: 7, backgroundColor: '#fff', boxShadow: '0 0 4px rgb(120 150 200 / 0.5)' }, anim]} />;
|
||||
return (
|
||||
<Animated.View style={[place, anim]}>
|
||||
<LinearGradient colors={['transparent', light ? 'rgba(220,230,255,0.7)' : 'rgba(80,130,200,0.7)']} style={{ width: 2, height: 18, borderRadius: 2 }} />
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
function useNow(ms = 20000) {
|
||||
const [now, setNow] = useState(() => new Date());
|
||||
useEffect(() => {
|
||||
@@ -80,6 +152,8 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
const bubble = slotTop ? (slotTop.score >= 70 ? `${when}은 ${slotTop.name}!` : `${when}은 쉬어 가요`) : hero ? (hero.bubble ?? '지금은 쉬어 가요') : failed(feedLoad) ? '앗, 날씨를 못 불러왔어요' : null;
|
||||
const status = hero?.status ?? [];
|
||||
const gray = !dark && weather !== 'clear' && weather !== 'partly';
|
||||
const rain = weather === 'rain' || weather === 'sleet';
|
||||
const snow = weather === 'snow' || weather === 'sleet';
|
||||
const orb = ORB[kind === 'sunset' ? 'sunset' : kind === 'night' ? 'night' : 'sun'];
|
||||
const text = dark ? 'text-white' : 'text-[#28304a]';
|
||||
|
||||
@@ -87,31 +161,44 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
<View className="mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3">
|
||||
<LinearGradient colors={HERO_BG[gray ? 'gray' : kind]} locations={kind === 'night' ? [0, 0.6, 1] : [0, 0.5, 1]} style={{ position: 'absolute', inset: 0 }} />
|
||||
{kind === 'night' && STARS.map((s, i) => <View key={i} className="absolute size-[3px] rounded-full bg-white" style={{ left: s.left, top: s.top, opacity: s.opacity }} />)}
|
||||
{(rain || snow) && (
|
||||
<View pointerEvents="none" style={{ position: 'absolute', inset: 0 }}>
|
||||
{rain && DROPS.map((p, i) => <Particle key={`r${i}`} {...p} snow={false} light={dark} />)}
|
||||
{snow && FLAKES.map((p, i) => <Particle key={`s${i}`} {...p} snow light={dark} />)}
|
||||
</View>
|
||||
)}
|
||||
<Text className={`text-[14px] font-bold opacity-80 ${text}`}>
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일
|
||||
</Text>
|
||||
<View className="h-[146px] items-center">
|
||||
<View className="mt-2 size-32 items-center justify-center" style={{ boxShadow: `0 20px 40px ${kind === 'night' ? 'rgb(190 180 255 / 0.35)' : kind === 'sunset' ? 'rgb(255 150 110 / 0.4)' : 'rgb(240 106 58 / 0.32)'}`, borderRadius: 64 }}>
|
||||
<Svg viewBox="-1 -1 2 2" width={128} height={128} style={{ position: 'absolute' }}>
|
||||
<Defs>
|
||||
<RadialGradient id="orb" cx="-0.32" cy="-0.4" r="1.4" gradientUnits="userSpaceOnUse">
|
||||
<Stop offset="0" stopColor={orb.stops[0]} />
|
||||
<Stop offset="0.3" stopColor={orb.stops[1]} />
|
||||
<Stop offset="0.68" stopColor={orb.stops[2]} />
|
||||
<Stop offset="1" stopColor={orb.stops[3]} />
|
||||
</RadialGradient>
|
||||
</Defs>
|
||||
<Rect x="-1" y="-1" width="2" height="2" rx="1" fill="url(#orb)" opacity={gray ? 0.85 : 1} />
|
||||
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
|
||||
{moon && <Path d={moonPath(moon.pct, 1, false)} fill={kind === 'sunset' ? 'rgb(96 40 86 / .55)' : 'rgb(34 30 86 / .62)'} transform={moon.waning ? 'scale(-1,1)' : undefined} />}
|
||||
</Svg>
|
||||
<Text className="font-jua text-[12px]" style={{ color: orb.text }}>
|
||||
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
|
||||
</Text>
|
||||
<Text className="font-bagel text-[52px] leading-[52px]" style={{ color: orb.text }}>
|
||||
{heroVal(feedLoad, score, 'w-[84px] h-10')}
|
||||
</Text>
|
||||
</View>
|
||||
<Fall d={0} f={5600} amp={8}>
|
||||
<View className="mt-2 size-32 items-center justify-center" style={{ boxShadow: `0 20px 40px ${kind === 'night' ? 'rgb(190 180 255 / 0.35)' : kind === 'sunset' ? 'rgb(255 150 110 / 0.4)' : 'rgb(240 106 58 / 0.32)'}`, borderRadius: 64 }}>
|
||||
<Svg viewBox="-1 -1 2 2" width={128} height={128} style={{ position: 'absolute' }}>
|
||||
<Defs>
|
||||
<RadialGradient id="orb" cx="-0.32" cy="-0.4" r="1.4" gradientUnits="userSpaceOnUse">
|
||||
<Stop offset="0" stopColor={orb.stops[0]} />
|
||||
<Stop offset="0.3" stopColor={orb.stops[1]} />
|
||||
<Stop offset="0.68" stopColor={orb.stops[2]} />
|
||||
<Stop offset="1" stopColor={orb.stops[3]} />
|
||||
</RadialGradient>
|
||||
</Defs>
|
||||
<Rect x="-1" y="-1" width="2" height="2" rx="1" fill="url(#orb)" opacity={gray ? 0.85 : 1} />
|
||||
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
|
||||
{moon && <Path d={moonPath(moon.pct, 1, false)} fill={kind === 'sunset' ? 'rgb(96 40 86 / .55)' : 'rgb(34 30 86 / .62)'} transform={moon.waning ? 'scale(-1,1)' : undefined} />}
|
||||
</Svg>
|
||||
<Text className="font-jua text-[12px]" style={{ color: orb.text }}>
|
||||
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
|
||||
</Text>
|
||||
<Text className="font-bagel text-[52px] leading-[52px]" style={{ color: orb.text }}>
|
||||
{heroVal(feedLoad, score, 'w-[84px] h-10')}
|
||||
</Text>
|
||||
</View>
|
||||
</Fall>
|
||||
{CLOUDS.slice(0, CLOUD_N[weather]).map((c) => (
|
||||
<Fall key={c.left} d={c.d} f={c.f} style={{ position: 'absolute', top: c.top, left: c.left }}>
|
||||
<Cloud w={c.w} h={c.h} night={kind === 'night'} />
|
||||
</Fall>
|
||||
))}
|
||||
</View>
|
||||
<View className="items-center">
|
||||
{bubble ? (
|
||||
|
||||
Reference in new issue
Block a user