feat: 앱 단풍 지도 — /foliage 지도(두 손가락 확대·이동, 눌러 가까운 명소)·단계별 명소 목록, 단풍철 오늘 피드 맨 앞 카드(foliage_post 좋아요·댓글)와 아이콘. 명소 데이터·계산을 shared/lib/foliage.ts 로 (GA foliage_open·foliage_spot)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 17:52:23 +09:00
1 parent 6daa2f4d2a
commit e5cdfa2642
11 files changed
+966 -180

No files matched your search

+6 -1
View File
@@ -7,6 +7,7 @@ import { router, useLocalSearchParams } from 'expo-router';
import { Fragment, useEffect, useRef, type ReactNode } from 'react';
import { RefreshControl, ScrollView, View, type LayoutRectangle } from 'react-native';
import { FoliageCard } from '@/components/foliage/foliage-card';
import { MyGakRow } from '@/components/my-gak/my-gak';
import { isAppPost, PostCard, PostCardSkel } from '@/components/post/post-card';
import { ShortsRail } from '@/components/shorts/rail';
@@ -17,6 +18,7 @@ import { TodayIcons } from '@/components/today/icons';
import { SeasonBand } from '@/components/today/rails';
import { StateBox } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useFoliage } from '@/lib/foliage';
import { fromShare } from '@/lib/my-gak';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
@@ -73,6 +75,7 @@ export default function TodayScreen() {
const talkFrom = Math.floor(posts.length / TALK_EVERY);
const eventNo = new Map(posts.filter((p) => p.post_type === PostType.EVENT).map((p, n) => [p.post_id, n + 1]));
const seen = useSeen();
const { inSeason } = useFoliage();
const scroll = useRef<ScrollView>(null);
const myGakY = useRef(0);
const { open } = useSheet();
@@ -104,7 +107,7 @@ export default function TodayScreen() {
onScroll={(e) => seen.onScroll(e.nativeEvent.contentOffset.y, e.nativeEvent.layoutMeasurement.height)}
>
<Hero hero={f?.hero} post={f?.hero_post} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} />
<TodayIcons foliage={false} onMyGak={() => scroll.current?.scrollTo({ y: myGakY.current, animated: true })} />
<TodayIcons foliage={inSeason} onMyGak={() => scroll.current?.scrollTo({ y: myGakY.current, animated: true })} />
<ShortsRail />
<Composer />
{/* 아이콘 줄 '내 각'이 여기로 내려온다 */}
@@ -139,6 +142,8 @@ export default function TodayScreen() {
boxClassName="inset-x-3 top-3.5"
/>
)}
{/* 단풍철엔 단풍 지도를 포스트 맨 앞에 */}
{load !== 'loading' && posts.length > 0 && <FoliageCard post={f?.foliage_post} />}
{posts.map((p, i) => {
const t = talkAt(i);
const ev = eventNo.get(p.post_id);
+85
View File
@@ -0,0 +1,85 @@
import { headline, md, type Kind, type Spot } from '@nalssigak/shared/lib/foliage';
import { useLocalSearchParams } from 'expo-router';
import { useEffect, useMemo, useRef, useState } from 'react';
import { Pressable, ScrollView, useWindowDimensions, View } from 'react-native';
import { useCSSVariable } from 'uniwind';
import { FoliageMap, type FoliageMapHandle } from '@/components/foliage/foliage-map';
import { ChosenBar, SpotList } from '@/components/foliage/spot-list';
import { SendIcon } from '@/components/post/icons';
import { ScreenHeader } from '@/components/screen-header';
import { Text } from '@/components/text';
import { Chips, Ic } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useFoliage } from '@/lib/foliage';
import { useShare } from '@/lib/share-image';
import { SITE_URL } from '@/lib/site';
type Filter = 'all' | Kind;
const FILTERS: [Filter, string][] = [
['all', '전체'],
['maple', '단풍'],
['ginkgo', '은행'],
];
/** 단풍 지도: 명소 67곳을 지도에서 확대해 보고 아래 목록으로 고른다. ?spot= 으로 열면 그 명소로 (웹 FoliagePage) */
export default function FoliageScreen() {
const params = useLocalSearchParams<{ spot?: string }>();
const { today, spots } = useFoliage();
const [filter, setFilter] = useState<Filter>('all');
const [sel, setSel] = useState<string | null>(params.spot ?? null);
const mapRef = useRef<FoliageMapHandle>(null);
const shotRef = useRef<View>(null);
const shareView = useShare();
const ink = String(useCSSVariable('--color-ink'));
const { width, height: winH } = useWindowDimensions();
// 지도는 스크롤 밖에 고정: 가로만큼 정사각형, 화면이 낮으면 화면 높이의 45%까지
const mapH = Math.max(280, Math.min(width * 1.05, winH * 0.45, 560));
const shown = useMemo(() => spots.filter((m) => filter === 'all' || m.kind === filter), [spots, filter]);
useEffect(() => track('foliage_open', {}), []);
useEffect(() => {
if (sel) track('foliage_spot', { spot_name: sel, from: 'page' });
}, [sel]);
const chosen = spots.find((m) => m.name === sel);
const peakCount = spots.filter((m) => m.stage === 'peak').length;
const title = headline(spots);
const pick = (m: Spot) => {
setSel(m.name);
mapRef.current?.focus(m);
};
const share = () => void shareView(shotRef, { title: chosen ? `${chosen.name} 단풍` : '단풍 지도', message: `${title} · 날씨각 단풍 지도 ${SITE_URL}/foliage` });
return (
<View className="flex-1">
<ScreenHeader
title="단풍 지도"
right={
<Pressable onPress={share} hitSlop={8} accessibilityRole="button" accessibilityLabel="단풍 지도 보내기" className="size-10 items-center justify-center">
<SendIcon size={24} color={ink} />
</Pressable>
}
/>
<View className="px-4 pt-1 pb-2">
<View className="flex-row items-center gap-1">
<Ic name="maple" size={16} />
<Text className="text-[13px] font-extrabold text-ink2">{`단풍 지도 · ${md(today)}`}</Text>
</View>
<Text className="mt-0.5 font-jua text-[24px] leading-tight text-ink">{title}</Text>
</View>
{/* 보내기는 지금 보이는 지도 그대로 찍어 보낸다 (웹은 따로 만든 공유 그림) */}
<View ref={shotRef} collapsable={false}>
<FoliageMap ref={mapRef} spots={shown} sel={sel} onSelect={setSel} height={mapH} />
</View>
<ChosenBar chosen={chosen} legendColor={ink} />
<ScrollView className="flex-1" contentContainerClassName="pb-8">
<Chips items={FILTERS} value={filter} onChange={setFilter} />
<SpotList spots={shown} sel={sel} onPick={pick} />
<Text className="px-5 pt-4 text-[11.5px] leading-relaxed font-semibold text-ink3">
{`출처: 산림청 2026 단풍절정 예측 · 잎 절반이 물든 때를 절정으로, 그 2주 전부터 첫 단풍으로 봐요${peakCount ? ` · 지금 절정 ${peakCount}곳` : ''}`}
</Text>
</ScrollView>
</View>
);
}