feat: 앱 GA4 이벤트 틀(track, 웹과 같은 이벤트 목록을 shared로) — 기존 앱 기능에 창_열기·각_보기·글_열기·로그인·지역_변경·좋아요·댓글·신고·차단·약관_동의·공유, 전송은 Firebase 연결 뒤. 탭 밖 화면용 루트 스택

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 16:52:08 +09:00
1 parent fcc7ed804c
commit cab3336859
20 files changed
+201 -110

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
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';
import { DayTiles, Li, LiSkel, ScoreHelp, SkyHero, Timeline } from '@/components/sky/parts';
import { Sec, Skel, StateBox } from '@/components/ui';
import { useRegion } from '@/lib/region';
const THREE = [0, 1, 2];
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i);
/** 히어로 글자 자리 (실패·빈 안내를 같은 높이로 띄우려고) */
function HeroHold() {
return (
<View>
<Skel className="h-7 w-[230px]" />
<Skel className="mt-2 w-[180px]" />
</View>
);
}
function LiSkels({ n }: { n: number[] }) {
return (
<View className="mx-3 mt-1.5">
{n.map((i) => (
<LiSkel key={i} last={i === n.length - 1} />
))}
</View>
);
}
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="오늘 노을 정보가 없어요." hold={<HeroHold />} boxClassName="inset-x-0 top-1.5 bottom-0" />
</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' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} hold={<Timeline />} />}
{!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' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} hold={<LiSkels n={THREE} />} />
)}
<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="순위가 아직 없어요." hold={<LiSkels n={RANK_SKELS} />} boxClassName="inset-x-3 top-1.5 bottom-0" />
)}
</ScrollView>
);
}