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
+79
-3
@@ -1,5 +1,81 @@
|
||||
import { ComingSoon } from '@/components/coming-soon';
|
||||
import { getSkyOptions, getSkyRankingOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
|
||||
import { loadOf } from '@nalssigak/shared/lib';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useState } from 'react';
|
||||
import { RefreshControl, ScrollView, View } from 'react-native';
|
||||
|
||||
export default function Screen() {
|
||||
return <ComingSoon title="노을" />;
|
||||
import { DayTiles, Li, LiSkel, ScoreHelp, SkyHero, Timeline } from '@/components/sky/parts';
|
||||
import { Sec, StateBox } from '@/components/ui';
|
||||
import { useRegion } from '@/lib/region';
|
||||
|
||||
const THREE = [0, 1, 2];
|
||||
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i);
|
||||
|
||||
export default function SkyScreen() {
|
||||
const { region } = useRegion();
|
||||
const sky = useQuery(getSkyOptions({ query: { region: region.code } }));
|
||||
const ranking = useQuery(getSkyRankingOptions());
|
||||
const load = loadOf(sky);
|
||||
const rankLoad = loadOf(ranking);
|
||||
const plans = sky.data?.plans ?? [];
|
||||
const [picked, setPicked] = useState<string>();
|
||||
// 타일을 누르면 그날, 아니면 다음에 오는 날
|
||||
const plan = plans.find((p) => p.day === picked) ?? sky.data?.plan ?? undefined;
|
||||
const spots = (sky.data?.spots ?? []).slice(0, 3);
|
||||
const items = (ranking.data?.items ?? []).slice(0, 8);
|
||||
const rise = plan?.kind === 'sunrise';
|
||||
const refresh = () => Promise.all([sky.refetch(), ranking.refetch()]);
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={sky.isRefetching && !sky.isPlaceholderData} onRefresh={refresh} />} style={{ opacity: sky.isPlaceholderData ? 0.6 : 1 }}>
|
||||
{plan || load === 'loading' ? (
|
||||
<SkyHero plan={plan} />
|
||||
) : (
|
||||
<SkyHero>
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." />
|
||||
</SkyHero>
|
||||
)}
|
||||
{plans.length > 1 && <DayTiles plans={plans} day={plan?.day} onPick={setPicked} />}
|
||||
{plan && <ScoreHelp plan={plan} />}
|
||||
<Sec title="언제 보면 좋을까" />
|
||||
{plan?.timeline?.length || load === 'loading' ? <Timeline rows={plan?.timeline} kind={plan?.kind} /> : <StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} />}
|
||||
{!rise && <Sec title="가까운 노을 명소" sub="가까운 순 · 방향은 내 동네에서 본 쪽" />}
|
||||
{rise ? null : spots.length ? (
|
||||
<View className="mx-3 mt-1.5">
|
||||
{spots.map((p, i) => (
|
||||
<Li key={p.no} no={p.no} title={p.name} sub={p.direction ? `${p.direction}쪽` : null} right={`${p.distance_km}km`} place={p.name} last={i === 2} />
|
||||
))}
|
||||
{/* 3곳이 안 되면 빈 줄로 높이를 지켜 아래 순위가 밀리지 않게 */}
|
||||
{THREE.slice(spots.length).map((i) => (
|
||||
<LiSkel key={`ghost-${i}`} ghost last={i === 2} />
|
||||
))}
|
||||
</View>
|
||||
) : load === 'loading' ? (
|
||||
<View className="mx-3 mt-1.5">
|
||||
{THREE.map((i) => (
|
||||
<LiSkel key={i} last={i === 2} />
|
||||
))}
|
||||
</View>
|
||||
) : (
|
||||
// 실패 안내·다시 시도는 위 히어로에 한 번만
|
||||
<StateBox load="ready" empty={load === 'ready' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} />
|
||||
)}
|
||||
<Sec title="전국 노을 순위" sub={ranking.data?.summary ?? '오늘 기준'} />
|
||||
{items.length ? (
|
||||
<View className="mx-3 mt-1.5">
|
||||
{items.map((r, i) => (
|
||||
<Li key={r.region_code} no={r.rank} title={r.name} sub={[r.note, r.situation_label].filter(Boolean).join(' · ')} right={`${r.score}점`} mine={r.region_code === region.code} last={i === items.length - 1} />
|
||||
))}
|
||||
</View>
|
||||
) : rankLoad === 'loading' ? (
|
||||
<View className="mx-3 mt-1.5">
|
||||
{RANK_SKELS.map((i) => (
|
||||
<LiSkel key={i} last={i === RANK_SKELS.length - 1} />
|
||||
))}
|
||||
</View>
|
||||
) : (
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="순위가 아직 없어요." />
|
||||
)}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user