feat: 앱 나머지 화면 이전 — 게시물 카드·시트·각/노을/주말/계절 탭·움직임

- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유
- 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타
- 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침
- 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
This commit is contained in:
minaChoi committed 2026-10-14 14:45:56 +09:00
1 parent 28ff032160
commit f71dd2cebb
33 files changed
+2786 -75

No files matched your search

+67 -5
View File
@@ -1,9 +1,71 @@
import { useMemo, useState, type ReactNode } from 'react';
import { subscribeAuth } from '@nalssigak/shared/api/auth';
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';
import { KeyboardAvoidingView, Modal, Platform, Pressable, Text, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { SheetContext, type SheetState } from '@/lib/sheet';
import { SheetContext, useSheet, type SheetState } from '@/lib/sheet';
import { ArticleSheet, SeasonWeekSheet } from './article';
import { CommentsSheet } from './comments';
import { GakSheet } from './gak';
import { LoginSheet } from './login';
import { MeSheet } from './me';
import { RegionSheet } from './region';
export function SheetProvider({ children }: { children: ReactNode }) {
const [, setState] = useState<SheetState>(null);
const api = useMemo(() => ({ open: (s: Exclude<SheetState, null>) => setState(s), close: () => setState(null) }), []);
return <SheetContext value={api}>{children}</SheetContext>;
const [state, setState] = useState<SheetState>(null);
const open = useCallback((s: Exclude<SheetState, null>) => setState(s), []);
const close = useCallback(() => setState(null), []);
const api = useMemo(() => ({ open, close }), [open, close]);
// 로그인이 필요한 요청이 401을 받으면 로그인 창을 띄운다
useEffect(() => subscribeAuth((reason) => reason === 'required' && open({ type: 'login' })), [open]);
return (
<SheetContext value={api}>
{children}
<SheetHost state={state} onClose={close} />
</SheetContext>
);
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기' } as const;
/** 아래에서 올라오는 창. 바깥을 누르거나 뒤로 가기(안드로이드)로 닫는다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
const { open } = useSheet();
const { bottom } = useSafeAreaInsets();
const [gakTitle, setGakTitle] = useState('');
const [articleTitle, setArticleTitle] = useState('');
const then = state?.type === 'login' ? state.then : undefined;
const title = !state ? '' : state.type === 'gak' ? gakTitle : state.type === 'article' ? articleTitle || TITLES.article : TITLES[state.type];
return (
<Modal visible={state != null} transparent animationType="slide" onRequestClose={onClose} statusBarTranslucent>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className="flex-1 justify-end">
<Pressable onPress={onClose} accessibilityLabel="닫기" className="absolute inset-0 bg-[rgb(20_26_45/0.45)]" />
{state && (
<View accessibilityViewIsModal accessibilityLabel={title} className="max-h-[86%] w-full max-w-[440px] self-center rounded-t-[22px] bg-card" style={{ paddingBottom: bottom }}>
<View className="border-b border-line px-4 pt-2 pb-2.5">
<View className="mb-2.5 h-1 w-10 self-center rounded-full bg-line" />
<Text numberOfLines={1} className="px-10 text-center text-[15px] font-extrabold text-ink">
{title}
</Text>
<Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel="닫기" className="absolute right-3 bottom-2 size-[30px] items-center justify-center">
<Text className="text-xl text-ink2">×</Text>
</Pressable>
</View>
{state.type === 'gak' && <GakSheet indexId={state.indexId} onTitle={setGakTitle} />}
{state.type === 'article' && <ArticleSheet articleId={state.articleId} onTitle={setArticleTitle} />}
{state.type === 'seasonWeek' && <SeasonWeekSheet />}
{state.type === 'comments' && <CommentsSheet postId={state.postId} draft={state.draft} />}
{state.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
{state.type === 'me' && <MeSheet onDone={onClose} />}
{state.type === 'region' && <RegionSheet onDone={onClose} />}
</View>
)}
</KeyboardAvoidingView>
</Modal>
);
}