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,13 @@
|
||||
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 { useSky } from '@/lib/sky';
|
||||
|
||||
const KINDS: TimeKind[] = ['morning', 'day', 'sunset', 'night'];
|
||||
|
||||
const SKY: Record<TimeKind, { colors: readonly [string, string, string]; locations: readonly [number, number, number] }> = {
|
||||
morning: { colors: ['#ffe0c4', '#fff0e2', '#e4f2ff'], locations: [0, 0.38, 1] },
|
||||
day: { colors: ['#cde7ff', '#e9f5ff', '#f7fbff'], locations: [0, 0.45, 1] },
|
||||
@@ -11,16 +15,44 @@ const SKY: Record<TimeKind, { colors: readonly [string, string, string]; locatio
|
||||
night: { colors: ['#0e1433', '#1b2356', '#2a2e6e'], locations: [0, 0.5, 1] },
|
||||
};
|
||||
|
||||
const STARS = Array.from({ length: 46 }, (_, i) => ({ left: `${(i * 41 + 7) % 100}%`, top: `${(i * 67 + 3) % 96}%`, size: 1 + (i % 3) * 0.8, opacity: 0.4 + ((i * 7) % 6) / 10 }) as const);
|
||||
const STARS = Array.from({ length: 46 }, (_, i) => ({ left: `${(i * 41 + 7) % 100}%`, top: `${(i * 67 + 3) % 96}%`, size: 1 + (i % 3) * 0.8, period: (3 + (i % 5)) * 1000, delay: ((i * 0.7) % 6) * 1000 }) as const);
|
||||
|
||||
/** 화면 전체 하늘: 시간대별 색, 밤에는 별 */
|
||||
/** 시간대 하나의 하늘 판. 고른 시간대만 1.4초 동안 서서히 드러난다 */
|
||||
function Layer({ kind, on, reduce }: { kind: TimeKind; on: boolean; reduce: boolean }) {
|
||||
const shown = useSharedValue(on ? 1 : 0);
|
||||
useEffect(() => {
|
||||
shown.value = reduce ? (on ? 1 : 0) : withTiming(on ? 1 : 0, { duration: 1400, easing: Easing.ease });
|
||||
}, [on, reduce, shown]);
|
||||
const style = useAnimatedStyle(() => ({ opacity: shown.value }));
|
||||
return (
|
||||
<Animated.View style={[StyleSheet.absoluteFill, style]}>
|
||||
<LinearGradient {...SKY[kind]} style={StyleSheet.absoluteFill} />
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 밤 별: 제각각 주기로 반짝인다 */
|
||||
function Star({ star, reduce }: { star: (typeof STARS)[number]; reduce: boolean }) {
|
||||
const glow = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
if (reduce) return;
|
||||
glow.value = withDelay(star.delay, withRepeat(withTiming(1, { duration: star.period / 2, easing: Easing.inOut(Easing.ease) }), -1, true));
|
||||
return () => cancelAnimation(glow);
|
||||
}, [reduce, glow, star]);
|
||||
const style = useAnimatedStyle(() => ({ opacity: reduce ? 0.7 : 0.25 + glow.value * 0.75 }));
|
||||
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 function SkyBg() {
|
||||
const { kind } = useSky();
|
||||
const reduce = useReducedMotion();
|
||||
return (
|
||||
<View style={StyleSheet.absoluteFill} pointerEvents="none">
|
||||
<LinearGradient {...SKY[kind]} style={StyleSheet.absoluteFill} />
|
||||
{kind === 'night' &&
|
||||
STARS.map((s, i) => <View key={i} style={{ position: 'absolute', left: s.left, top: s.top, width: s.size, height: s.size, borderRadius: s.size, backgroundColor: '#fff', opacity: s.opacity }} />)}
|
||||
{KINDS.map((k) => (
|
||||
<Layer key={k} kind={k} on={k === kind} reduce={reduce} />
|
||||
))}
|
||||
{kind === 'night' && STARS.map((s, i) => <Star key={i} star={s} reduce={reduce} />)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user