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
@@ -0,0 +1,71 @@
|
||||
import type { TimeKind } from '@nalssigak/shared/lib';
|
||||
import { useIsFetching } from '@tanstack/react-query';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
|
||||
|
||||
import { Ic } from '@/components/ui';
|
||||
import { useSky } from '@/lib/sky';
|
||||
|
||||
// 덮개 색: 시간대별 하늘 맨 위 색을 반쯤 비치게
|
||||
const COVER: Record<TimeKind, string> = {
|
||||
morning: 'rgb(255 230 207 / 0.72)',
|
||||
day: 'rgb(214 235 255 / 0.72)',
|
||||
sunset: 'rgb(255 216 194 / 0.72)',
|
||||
night: 'rgb(14 20 51 / 0.72)',
|
||||
};
|
||||
|
||||
/** 캐릭터가 통통 뛴다 (웹 b-hop) */
|
||||
function Hop({ name }: { name: string }) {
|
||||
const reduce = useReducedMotion();
|
||||
const t = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
if (reduce) return;
|
||||
const ease = Easing.bezier(0.3, 0, 0.4, 1);
|
||||
t.value = withRepeat(withSequence(withTiming(1, { duration: 405, easing: ease }), withTiming(0, { duration: 495, easing: ease })), -1);
|
||||
return () => cancelAnimation(t);
|
||||
}, [reduce, t]);
|
||||
const style = useAnimatedStyle(() => ({
|
||||
transform: [{ translateY: -22 * t.value }, { scaleX: 1.06 - 0.09 * t.value }, { scaleY: 0.94 + 0.09 * t.value }],
|
||||
transformOrigin: 'bottom',
|
||||
}));
|
||||
return (
|
||||
<Animated.View style={style}>
|
||||
<Ic name={name} size={88} />
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 처음 들어올 때만: 첫 데이터를 다 받을 때까지 하늘 위에 캐릭터와 '날씨 불러오는 중…'. 한 번 사라지면 다시 안 뜬다 */
|
||||
export function FirstLoad() {
|
||||
const fetching = useIsFetching();
|
||||
const { kind } = useSky();
|
||||
const [started, setStarted] = useState(false);
|
||||
const [done, setDone] = useState(false);
|
||||
const [gone, setGone] = useState(false);
|
||||
// 받기 시작했다가 받는 게 없어지면 끝 (렌더 중에 바로 맞춘다)
|
||||
if (fetching > 0 && !started) setStarted(true);
|
||||
if (fetching === 0 && started && !done) setDone(true);
|
||||
// 느린 망에서도 10초 넘게 막지 않는다 (그 뒤는 화면 안 스켈레톤이 맡는다)
|
||||
useEffect(() => {
|
||||
const id = setTimeout(() => setDone(true), 10000);
|
||||
return () => clearTimeout(id);
|
||||
}, []);
|
||||
const shown = useSharedValue(1);
|
||||
useEffect(() => {
|
||||
if (!done) return;
|
||||
shown.value = withTiming(0, { duration: 400 });
|
||||
const id = setTimeout(() => setGone(true), 400);
|
||||
return () => clearTimeout(id);
|
||||
}, [done, shown]);
|
||||
const fade = useAnimatedStyle(() => ({ opacity: shown.value }));
|
||||
if (gone) return null;
|
||||
return (
|
||||
<Animated.View pointerEvents={done ? 'none' : 'auto'} accessibilityRole="progressbar" accessibilityLabel="날씨 불러오는 중" style={[StyleSheet.absoluteFill, { zIndex: 50, backgroundColor: COVER[kind] }, fade]}>
|
||||
<View className="flex-1 items-center justify-center gap-3">
|
||||
<Hop name={kind === 'night' ? 'bear' : 'rabbit'} />
|
||||
<Text className="font-jua text-[19px] text-ink">날씨 불러오는 중…</Text>
|
||||
</View>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user