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:
1 parent
6daa2f4d2a
commit
e5cdfa2642
11 files changed
+966
-180
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user