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

+18
View File
@@ -0,0 +1,18 @@
import { Tabs } from 'expo-router/tabs';
import { TabBar } from '@/components/tab-bar';
import { TopBar } from '@/components/top-bar';
/** 아래 탭 다섯 개. 사주·게임 같은 화면은 탭 밖(루트 스택)에서 연다 */
export default function TabsLayout() {
return (
<Tabs initialRouteName="index" tabBar={(props) => <TabBar {...props} />} screenOptions={{ header: () => <TopBar />, sceneStyle: { backgroundColor: 'transparent' } }}>
{/* 메인인 오늘 탭을 가운데에 */}
<Tabs.Screen name="sky" />
<Tabs.Screen name="gak" />
<Tabs.Screen name="index" />
<Tabs.Screen name="week" />
<Tabs.Screen name="season" />
</Tabs>
);
}
+65
View File
@@ -0,0 +1,65 @@
import { listArticlesOptions, listIndicesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { ArticleCategory, IndexCategory } from '@nalssigak/shared/api/client/types.gen';
import { kst, loadOf, seasonOf } from '@nalssigak/shared/lib';
import { useQuery } from '@tanstack/react-query';
import { useState } from 'react';
import { Pressable, RefreshControl, ScrollView, View } from 'react-native';
import { Text } from '@/components/text';
import { GakGrid, GridSkel } from '@/components/gak/grid';
import { Podium, PodiumSkel } from '@/components/gak/podium';
import { Chips, Ic, Sec, StateBox } from '@/components/ui';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
type Cat = 'all' | 'out' | 'food' | 'home' | 'life' | 'core';
// 마지막 칩은 지금 계절의 제철 각 (예: 가을 각)
const CATS: readonly (readonly [Cat, string])[] = [
['all', '전체'],
['out', '밖에서 놀기'],
['food', '먹고 마시기'],
['home', '집안일'],
['life', '생활 고민'],
['core', `${seasonOf(kst(new Date()).mo)[0]} 각`],
];
const CAT_PARAM: Partial<Record<Cat, IndexCategory>> = { out: IndexCategory.OUTSIDE, food: IndexCategory.FOOD, home: IndexCategory.HOME, life: IndexCategory.LIFE };
export default function GakScreen() {
const { region } = useRegion();
const { open } = useSheet();
const [cat, setCat] = useState<Cat>('all');
const q = useQuery(listIndicesOptions({ query: { region: region.code, category: CAT_PARAM[cat], core: cat === 'core' ? true : undefined } }));
const articles = useQuery(listArticlesOptions({ query: { category: ArticleCategory.GAK } }));
const top = q.data?.top3 ?? [];
const items = q.data?.items ?? [];
const day = q.data?.day?.split('-').map(Number);
const load = loadOf(q);
const howto = articles.data?.articles?.find((a) => a.code === 'howgak');
return (
<ScrollView contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={q.isRefetching && !q.isPlaceholderData} onRefresh={() => q.refetch()} />}>
<Sec title="오늘 1~3위" sub={`${day ? `${day[1]}월 ${day[2]}일 기준 · ` : ''}${region.name}`} />
{top.length === 3 ? <Podium top={top} dim={q.isPlaceholderData} /> : load === 'loading' ? <PodiumSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="오늘 1~3위를 아직 못 정했어요." hold={<PodiumSkel />} />}
<Chips items={CATS} value={cat} onChange={setCat} />
{load === 'loading' ? (
<GridSkel />
) : !items.length ? (
// 실패 안내·다시 시도는 위 받침대 자리에 한 번만
<StateBox load="ready" empty={load === 'ready' ? '이 분야는 오늘 계산된 각이 없어요.' : '각 목록을 불러오지 못했어요.'} hold={<GridSkel />} boxClassName="inset-3" />
) : (
<GakGrid items={items} dim={q.isPlaceholderData} />
)}
{howto && load !== 'loading' && (
<Pressable onPress={() => open({ type: 'article', articleId: howto.article_id })} className="mx-3 mt-1.5 flex-row items-center gap-3 rounded-[22px] bg-[#ece7ff] p-3.5">
<Ic name="bulb" size={44} />
<View className="flex-1">
<Text className="font-jua text-[17px] text-[#28304a]">각 점수는 어떻게 매길까?</Text>
<Text className="text-[12.5px] font-semibold text-[#5a6380]">기온·비·바람·습도·공기·시간대 6가지로 계산해요</Text>
</View>
</Pressable>
)}
</ScrollView>
);
}
+71
View File
@@ -0,0 +1,71 @@
import { getFeedOptions, getWeatherTodayOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { kst, loadOf } from '@nalssigak/shared/lib';
import { atSlot, PREVIEW } from '@nalssigak/shared/lib/today';
import { useQuery } from '@tanstack/react-query';
import { Fragment, type ReactNode } from 'react';
import { RefreshControl, ScrollView } from 'react-native';
import { isAppPost, PostCard, PostCardSkel } from '@/components/post/post-card';
import { Hero } from '@/components/today/hero';
import { EventsBand, SeasonBand, Stories, StoriesSkel, TopBand } from '@/components/today/rails';
import { Sec, StateBox } from '@/components/ui';
import { useRegion } from '@/lib/region';
import { useSky } from '@/lib/sky';
export default function TodayScreen() {
const { region } = useRegion();
const feed = useQuery(getFeedOptions({ query: { region: region.code } }));
const today = useQuery(getWeatherTodayOptions({ query: { region: region.code } }));
const { preview } = useSky();
const f = feed.data;
const posts = (f?.posts ?? []).filter(isAppPost);
const stories = atSlot(f?.stories ?? [], preview);
const sloted = preview != null && stories !== f?.stories;
const bands = f?.bands;
const nowAt = f?.hero?.now_at;
const load = loadOf(feed);
const refresh = () => Promise.all([feed.refetch(), today.refetch()]);
// 웹처럼 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
const bandAt: [number, ReactNode][] = [
[3, bands?.events?.length ? <EventsBand events={bands.events} /> : null],
[6, bands?.top5?.length ? <TopBand items={sloted ? stories.filter((g) => g.active) : bands.top5} sub={sloted ? `${PREVIEW[preview].label} 기준` : nowAt ? `${kst(nowAt).h}시 기준` : '오늘 기준'} /> : null],
[9, bands?.season?.length ? <SeasonBand news={bands.season} /> : null],
];
return (
// 지역마다 새로 그려 넘긴 슬라이드 위치가 남지 않게 한다
<ScrollView key={region.code} contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={feed.isRefetching && !feed.isPlaceholderData} onRefresh={refresh} />} style={{ opacity: feed.isPlaceholderData ? 0.6 : 1 }}>
<Hero hero={f?.hero} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} />
<Sec title="오늘의 각" sub="누르면 계산 근거를 보여 줘요" more="/gak" />
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<StoriesSkel />} boxClassName="inset-x-3 top-3 bottom-1" />}
{load === 'loading' && (
<>
<PostCardSkel />
<PostCardSkel />
</>
)}
{/* 글이 없거나 못 받아도 스켈레톤 두 장 자리는 그대로 둔다. 다시 시도는 위 각 줄에 한 번만 */}
{load !== 'loading' && !posts.length && (
<StateBox
load="ready"
empty={load === 'ready' ? '오늘 올라온 글이 아직 없어요.' : '글을 불러오지 못했어요.'}
hold={
<>
<PostCardSkel />
<PostCardSkel />
</>
}
boxClassName="inset-x-3 top-3.5"
/>
)}
{posts.map((p, i) => (
<Fragment key={p.post_id}>
<PostCard post={p} />
{bandAt.find(([at]) => at === i + 1)?.[1]}
</Fragment>
))}
{feed.isSuccess && bandAt.filter(([at]) => at > posts.length).map(([at, node]) => <Fragment key={at}>{node}</Fragment>)}
</ScrollView>
);
}
+45
View File
@@ -0,0 +1,45 @@
import { getSeasonWeekOptions, listArticlesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { ArticleCategory } from '@nalssigak/shared/api/client/types.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 { ArticleRow, HeadSkel, RowsSkel, SeasonHead } from '@/components/season/parts';
import { Chips, StateBox } from '@/components/ui';
import { useSheet } from '@/lib/sheet';
const CATS = [
['all', '전체'],
['season', '계절 소식'],
['tip', '날씨 상식'],
['gak', '각 원리'],
] as const;
const CAT_PARAM = { season: ArticleCategory.SEASON, tip: ArticleCategory.TIP, gak: ArticleCategory.GAK } as const;
export default function SeasonScreen() {
const { open } = useSheet();
const [cat, setCat] = useState<(typeof CATS)[number][0]>('all');
const week = useQuery(getSeasonWeekOptions());
const arts = useQuery(listArticlesOptions(cat === 'all' ? undefined : { query: { category: CAT_PARAM[cat] } }));
const w = week.data;
const list = arts.data?.articles ?? [];
const weekLoad = loadOf(week);
const artLoad = loadOf(arts);
const refresh = () => Promise.all([week.refetch(), arts.refetch()]);
return (
<ScrollView contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={(week.isRefetching || arts.isRefetching) && !arts.isPlaceholderData} onRefresh={refresh} />}>
{w?.headline ? <SeasonHead week={w} onPress={() => open({ type: 'seasonWeek' })} /> : weekLoad === 'loading' ? <HeadSkel /> : <StateBox load={weekLoad} onRetry={() => week.refetch()} empty="이번 주 특집이 아직 없어요." hold={<HeadSkel />} />}
<Chips items={CATS} value={cat} onChange={setCat} />
<View className="mt-1.5" style={{ opacity: arts.isPlaceholderData ? 0.6 : 1 }}>
{artLoad === 'loading' && <RowsSkel />}
{artLoad !== 'loading' && !list.length && <StateBox load={artLoad} onRetry={() => arts.refetch()} empty="읽을거리가 아직 없어요." hold={<RowsSkel />} boxClassName="inset-3" />}
{list.map((a) => (
<ArticleRow key={a.article_id} article={a} onPress={() => open({ type: 'article', articleId: a.article_id })} />
))}
</View>
</ScrollView>
);
}
+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>
);
}
+152
View File
@@ -0,0 +1,152 @@
import { getWeekOptions, getWeekRankingOptions, listEventsOptions, listPlacesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { loadOf, shortDay } from '@nalssigak/shared/lib';
import { useQuery } from '@tanstack/react-query';
import { useRef, useState } from 'react';
import { Pressable, RefreshControl, ScrollView, View } from 'react-native';
import { Text } from '@/components/text';
import { DayStrip, EventRow, PickCard, PlaceCard, RankRow } from '@/components/week/sections';
import { DaysSkel, EventsSkel, PickSkel, PlacesSkel, RankSkel } from '@/components/week/skels';
import { Chips, Rail, Sec, Skel, StateBox } from '@/components/ui';
import { useRegion } from '@/lib/region';
import { shareView } from '@/lib/share-image';
import { SITE_URL } from '@/lib/site';
// 불러오는 동안에도 탭 줄 높이를 지키려고 같은 칩을 미리 그린다
const RANK_TABS_HOLD = [
['토', '토요일'],
['일', '일요일'],
] as const;
export default function WeekScreen() {
const { region } = useRegion();
const week = useQuery(getWeekOptions({ query: { region: region.code } }));
const days = week.data?.days ?? [];
const [picked, setPicked] = useState<string | null>(null);
// 지역을 바꾸면 동네 고르기는 전체로 돌아간다
const [areaPick, setAreaPick] = useState({ region: region.code, area: '전체' });
const area = areaPick.region === region.code ? areaPick.area : '전체';
// 처음에는 이번 토요일을 고른다
const sel = days.find((d) => d.day === picked) ?? days.find((d) => d.weekday === '토') ?? days[0];
const places = useQuery({ ...listPlacesOptions({ query: { region: region.code, day: sel?.day, area: area === '전체' ? undefined : area } }), enabled: !!sel });
const events = useQuery(listEventsOptions({ query: { region: region.code } }));
const ranking = useQuery(getWeekRankingOptions());
const rankDays = ranking.data?.days ?? [];
const [rankPick, setRankPick] = useState<string | null>(null);
const rankDay = rankDays.find((d) => d.day === rankPick) ?? rankDays[0];
const rankItems = (rankDay?.items ?? []).slice(0, 10);
const rankLoad = loadOf(ranking);
const areas = places.data?.areas ?? [];
const rainy = places.data?.rainy ?? sel?.is_rainy;
const placeList = places.data?.places ?? [];
const eventList = events.data?.events ?? [];
const weekLoad = loadOf(week);
const eventLoad = loadOf(events);
// 날씨(고른 날)가 와야 명소를 부를 수 있다
const placeLoad = sel ? loadOf(places) : weekLoad === 'loading' ? 'loading' : 'ready';
const refresh = () => Promise.all([week.refetch(), events.refetch(), ranking.refetch(), sel ? places.refetch() : null]);
const pickShot = useRef<View>(null);
// 고른 날 추천 카드를 이미지로
const sendPlan = () => {
if (!sel) return;
const message = [`${sel.weekday}요일 일정 · ${region.name}`, sel.headline, sel.summary, sel.pick, `날씨각 ${SITE_URL}`].filter(Boolean).join('\n');
void shareView(pickShot, { title: `${sel.weekday}요일 일정`, message });
};
const placeSub = sel ? `${sel.weekday}요일은 ${rainy ? '비가 와서 실내 명소를 먼저' : sel.icon === 'sun' ? '맑아서 야외 명소를 먼저' : '비 소식이 없어 야외 명소를 먼저'} 보여 줘요` : weekLoad === 'loading' ? undefined : '날씨에 맞춰 골라 보여 줘요';
return (
<ScrollView key={region.code} contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={week.isRefetching && !week.isPlaceholderData} onRefresh={refresh} />}>
<Sec title="열흘 날씨" sub="날짜를 누르면 그날 추천이 바뀌어요" />
{days.length ? (
<DayStrip days={days} selected={sel?.day} onPick={setPicked} dim={week.isPlaceholderData} />
) : weekLoad === 'loading' ? (
<>
<DaysSkel />
<PickSkel />
</>
) : (
<StateBox
load={weekLoad}
onRetry={() => week.refetch()}
empty="날씨가 아직 없어요."
hold={
<>
<DaysSkel />
<PickSkel />
</>
}
/>
)}
{sel && (
<View ref={pickShot} collapsable={false}>
<PickCard day={sel} />
</View>
)}
{(sel || weekLoad !== 'ready') && (
<>
<Text className="mx-4 mt-3.5 text-[13.5px] font-bold text-ink2">30km 안 · 데이트 명소</Text>
<Chips items={['전체', ...areas].map((a) => [a, a] as const)} value={area} onChange={(a) => setAreaPick({ region: region.code, area: a })} disabled={!areas.length} />
</>
)}
{/* 명소 데이터가 없으면 칸 전체를 숨긴다 */}
{!(placeLoad === 'ready' && !placeList.length) && (
<>
<View className="-mt-2.5">
<Sec title="날씨 맞춤 데이트 명소" sub={placeSub} />
</View>
{!placeSub && <Skel className="mx-4 w-56" />}
{placeList.length ? (
<View style={{ opacity: places.isPlaceholderData ? 0.6 : 1 }}>
<Rail>
{placeList.map((p, i) => (
<PlaceCard key={p.place_id} place={p} index={i} />
))}
</Rail>
</View>
) : placeLoad === 'loading' ? (
<PlacesSkel />
) : (
<StateBox load={placeLoad} onRetry={() => places.refetch()} empty={sel ? '30km 안에 데이트 명소가 아직 없어요.' : '날씨를 불러오면 명소를 골라 드려요.'} hold={<PlacesSkel />} />
)}
</>
)}
<Sec title="이번 주말 전국 날씨 순위" sub="낮 10~17시 나들이 날씨 · 대표 지역 30곳 중 10위까지" />
{rankDays.length ? (
<Chips items={rankDays.map((d) => [d.day, `${d.weekday}요일 ${shortDay(d.day)}`] as const)} value={rankDay?.day ?? ''} onChange={setRankPick} />
) : (
<Chips items={RANK_TABS_HOLD} value="토" onChange={() => undefined} disabled />
)}
{rankItems.length ? (
<View className="mx-3 mt-1.5" style={{ opacity: ranking.isPlaceholderData ? 0.6 : 1 }}>
{rankItems.map((r) => (
<RankRow key={r.region_code} item={r} mine={r.region_code === region.code} />
))}
</View>
) : rankLoad === 'loading' ? (
<RankSkel />
) : (
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="주말 예보가 아직 없어요." hold={<RankSkel />} boxClassName="inset-x-3 top-1.5 bottom-0" />
)}
<Sec title="가까운 축제·행사" sub="30km 안 · 앞으로 30일 · 그날 날씨까지 같이 봐요" />
{eventList.length ? (
<View style={{ opacity: events.isPlaceholderData ? 0.6 : 1 }}>
{eventList.map((e, i) => (
<EventRow key={e.event_id} event={e} index={i} />
))}
</View>
) : eventLoad === 'loading' ? (
<EventsSkel />
) : (
<StateBox load={eventLoad} onRetry={() => events.refetch()} empty="30km 안에 열리는 행사가 아직 없어요. 다른 지역을 골라 보세요." hold={<EventsSkel />} boxClassName="inset-x-3 top-2.5 bottom-0" />
)}
{/* 행사 수가 정해진 뒤에 붙여 목록이 늘어날 때 밀리지 않게 */}
{eventLoad !== 'loading' && (
<Pressable onPress={sendPlan} disabled={!sel} className="mx-3 mt-4 items-center rounded-full border-b-[5px] border-orange-deep bg-orange p-[13px] disabled:opacity-60">
<Text className="font-jua text-[17px] text-white">이번 주말 일정 보내기</Text>
</Pressable>
)}
</ScrollView>
);
}