feat: 앱 나머지 화면 이전 — 게시물 카드·시트·각/노을/주말/계절 탭·움직임

- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유
- 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타
- 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침
- 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
This commit is contained in:
minaChoi committed 2026-10-14 14:45:56 +09:00
1 parent 28ff032160
commit f71dd2cebb
33 files changed
+2786 -75

No files matched your search

+247
View File
@@ -0,0 +1,247 @@
import type { GakSlide, HoursSlide, PlanSlide, PostData, RowsSlide, SunsetSlide, WeekSlide } from '@nalssigak/shared/api/client/types.gen';
import { PostType, SlotTone } from '@nalssigak/shared/api/client/types.gen';
import { cardBg, clockShort } from '@nalssigak/shared/lib';
import type { SlideBg } from '@nalssigak/shared/lib/types';
import { deg } from '@nalssigak/shared/lib/weatherText';
import { Image } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import type { ReactNode } from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
import Svg, { Polygon } from 'react-native-svg';
import { Credit, Ic, Rows, Thumb } from '@/components/ui';
import { CARD_BG } from '@/lib/colors';
import { useSheet } from '@/lib/sheet';
import { imageUri } from '@/lib/site';
import { useSky } from '@/lib/sky';
export type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide;
type Stops = readonly [string, string, ...string[]];
const GAK_BG: SlideBg[] = ['butter', 'peach', 'lilac'];
const ROW_ICON_BG: Record<string, SlideBg> = { umbrella: 'lilac', vent: 'mint', sunset: 'peach', thermo: 'sky', maple: 'peach', moon: 'lilac', glasses: 'butter' };
const DARK = new Set<SlideBg>(['dusk', 'night']);
// 노을 하늘 상황(1 가려짐 2 낮은 구름 3 물들 구름 적음 4 넓게 물듦 5 두꺼움)별 하늘, 시간 칸 색 (웹 .b-sit-*, .b-cut-*)
const SIT_BG: Record<number, { colors: Stops; locations: readonly [number, number, ...number[]] }> = {
1: { colors: ['#6f7690', '#9aa0b4', '#b9b4c0'], locations: [0, 0.55, 1] },
2: { colors: ['#7a7f9c', '#a7a3bb', '#c9b8b8'], locations: [0, 0.55, 1] },
3: { colors: ['#4b5aa8', '#7f86c6', '#e9b9a8', '#ffb27a', '#ff8a4c'], locations: [0, 0.38, 0.68, 0.86, 1] },
4: { colors: ['#5b3f9e', '#c2559a', '#ff7a6a', '#ffb35c'], locations: [0, 0.4, 0.68, 1] },
5: { colors: ['#6a6aa0', '#a98fb4', '#e3b1a0'], locations: [0, 0.55, 1] },
};
const CUT_BG: Stops[] = [
['#9fd0ff', '#ffd79a', '#ff9a5c'],
['#8f7cf0', '#ff6f8e', '#ff8a4c'],
['#34306e', '#7a5cc8'],
];
// 건물 실루엣 (웹 .b-skyline clip-path)
const SKYLINE = '0,55 8,55 8,30 15,30 15,50 22,50 22,10 28,10 28,45 36,45 36,25 44,25 44,55 52,55 52,35 60,35 60,5 66,5 66,40 74,40 74,20 82,20 82,50 90,50 90,30 100,30 100,100 0,100';
const HOUR_TONE: Record<string, { bg: string; edge: string }> = {
[SlotTone.NIGHT]: { bg: '#e3e7ff', edge: '#c7cff5' },
[SlotTone.SUNSET]: { bg: '#ffe3d2', edge: '#ffc19f' },
};
/** 배경색은 API에 없어 글 종류·아이콘으로 고른다 */
export function slideBg(post: PostData, slide: Slide): SlideBg {
if (slide.kind === 'hours') return 'sky';
if (slide.kind === 'sunset') return 'dusk';
if (slide.kind === 'week') return 'mint';
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter';
if (slide.kind === 'gak') return GAK_BG[post.post_id % GAK_BG.length];
if (post.post_type === PostType.EVENT) return 'night';
if (post.post_type === PostType.TIP) return 'sky';
if (post.post_type === PostType.AIR) return slide.icon === 'vent' ? 'mint' : 'lilac';
if (post.post_type === PostType.DAY_TRIP) return slide.image ? 'night' : 'mint';
return (ROW_ICON_BG[slide.icon] ?? cardBg(slide.icon, post.post_id)) as SlideBg;
}
function Base({ colors, locations, children }: { colors: Stops; locations?: readonly [number, number, ...number[]]; children: ReactNode }) {
return (
<View className="flex-1 px-5 py-[22px]">
<LinearGradient colors={colors} locations={locations} style={StyleSheet.absoluteFill} />
{children}
</View>
);
}
function Eyebrow({ children, light, className }: { children: ReactNode; light?: boolean; className?: string }) {
return <Text className={`text-[13px] font-extrabold opacity-75 ${light ? 'text-white' : 'text-ink'} ${className ?? ''}`}>{children}</Text>;
}
function Big({ children, light, className }: { children: ReactNode; light?: boolean; className?: string }) {
return <Text className={`mt-1.5 font-jua text-[29px] leading-tight ${light ? 'text-white' : 'text-ink'} ${className ?? ''}`}>{children}</Text>;
}
function Pic({ name, widthPct = 42 }: { name: string; widthPct?: number }) {
return (
<View pointerEvents="none" className="absolute top-[30%] right-3.5 aspect-square" style={{ width: `${widthPct}%` }}>
<Ic name={name} size={0} style={{ width: '100%', height: '100%' }} />
</View>
);
}
export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
const { open } = useSheet();
const { kind } = useSky();
const palette = CARD_BG[kind === 'night' ? 'night' : 'day'];
const colors = palette[bg] ?? palette.sky;
const light = DARK.has(bg);
if (slide.kind === 'hours') {
const temps = slide.hours.flatMap((h) => (h.temp_c == null ? [] : [h.temp_c]));
const lo = Math.min(...temps);
const span = Math.max(...temps) - lo || 1;
return (
<Base colors={palette.sky}>
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big>{slide.line}</Big>
<View className="mt-3.5 flex-1 flex-row gap-2">
{slide.hours.map((h) => {
const tone = HOUR_TONE[h.tone ?? ''];
return (
<View key={h.label} className={`flex-1 items-center justify-between overflow-hidden rounded-[18px] px-1 pt-2.5 pb-[9px] ${tone ? '' : 'border-b-[5px] border-shade bg-card'}`} style={tone ? { backgroundColor: tone.bg, borderBottomWidth: 5, borderColor: tone.edge } : undefined}>
{h.temp_c != null && <LinearGradient colors={['rgba(255,122,69,0.1)', 'rgba(255,122,69,0.34)']} style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: `${20 + ((h.temp_c - lo) / span) * 70}%` }} />}
<Text className={`text-xs font-bold ${tone ? 'text-[#5a6380]' : 'text-ink2'}`}>{h.label}</Text>
<Ic name={h.icon} size={34} />
<Text className={`font-bagel text-[21px] ${tone ? 'text-[#28304a]' : 'text-ink'}`}>{deg(h.temp_c)}</Text>
</View>
);
})}
</View>
</Base>
);
}
if (slide.kind === 'gak')
return (
<Base colors={colors}>
<Eyebrow>오늘의 각 · {slide.rank}위</Eyebrow>
<Big>{slide.line}</Big>
<Pic name={slide.code} />
<Text className="mt-auto font-bagel text-[82px] leading-[82px] text-orange">{slide.score}</Text>
<Text className="font-jua text-[29px] leading-tight text-ink">{slide.name}</Text>
<Eyebrow className="mt-1">{slide.summary}</Eyebrow>
<Pressable onPress={() => open({ type: 'gak', indexId: slide.index_id })} className="mt-3 self-start rounded-full border-b-[5px] border-orange-deep bg-orange px-4 py-[9px]">
<Text className="font-jua text-[15px] text-white">계산 근거 보기</Text>
</Pressable>
</Base>
);
if (slide.kind === 'sunset') {
const sit = slide.situation ? SIT_BG[slide.situation] : undefined;
return (
<Base colors={sit?.colors ?? palette.dusk} locations={sit?.locations}>
<Eyebrow light>{slide.eyebrow}</Eyebrow>
{/* 노을 탭 히어로와 같은 순서: 결론 → 가장 붉을 때 → 쉬운 이유 */}
<Big light>{slide.headline ?? slide.grade_label}</Big>
{slide.line && <Text className="mt-0.5 font-jua text-[18px] text-white">{slide.line}</Text>}
<View className="mt-3 flex-1 gap-2">
{slide.cuts.map((c, i) => (
<View key={c.kind} className="flex-1 overflow-hidden rounded-2xl px-3 py-2">
<LinearGradient colors={CUT_BG[Math.min(i, 2)]} style={StyleSheet.absoluteFill} />
<Svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: '32%' }}>
<Polygon points={SKYLINE} fill="#2d2440" />
</Svg>
<Text className="font-bagel text-[21px] text-white">
{clockShort(c.at)}
<Text className="font-jua text-sm"> {c.label}</Text>
</Text>
</View>
))}
</View>
</Base>
);
}
if (slide.kind === 'week')
return (
<Base colors={palette.mint}>
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big>{slide.line}</Big>
{/* 칸은 제목 바로 아래, 팁만 맨 아래로 */}
<View className="mt-4 flex-row flex-wrap gap-2.5">
{slide.days.map((d) => (
<View key={d.day} className="grow basis-[45%] gap-0.5 rounded-[18px] border-b-[5px] border-shade bg-card/85 px-3 py-2.5">
<Ic name={d.icon} size={34} />
<Text className="font-jua text-lg text-ink">
{d.weekday} {d.day.split('-').slice(1).map(Number).join('.')}
</Text>
<Text className="font-jua text-[22px] text-ink">
<Text className="text-rain">{deg(d.temp_min_c)}</Text> → <Text className="text-orange">{deg(d.temp_max_c)}</Text>
</Text>
<Text className="text-xs font-bold text-ink2">
비 {d.rain_prob ?? '?'}%{d.temp_min_c != null && d.temp_max_c != null && ` · 일교차 ${Math.round(d.temp_max_c - d.temp_min_c)}°`}
</Text>
{d.gaks && d.gaks.length > 0 && (
<View className="mt-2 gap-1.5 border-t border-shade pt-2" accessibilityLabel={`${d.weekday}요일 대표 각`}>
<Text className="text-[11px] font-extrabold text-ink2">이날 할 만한 각</Text>
{d.gaks.map((g) => (
<View key={g.index_id} className="flex-row items-center gap-1.5">
<Ic name={g.icon} size={26} />
<Text numberOfLines={1} className="flex-1 text-[14px] font-bold text-ink">
{g.name}
</Text>
<Text className="font-bagel text-[16px] text-orange">{g.score}</Text>
</View>
))}
</View>
)}
</View>
))}
</View>
{slide.tip && <Text className="mt-auto overflow-hidden rounded-[14px] bg-ink-btn px-3 py-2.5 text-[13px] leading-snug font-bold text-white">{slide.tip}</Text>}
</Base>
);
if (slide.kind === 'plan') {
const credits = [...new Set(slide.steps.flatMap((st) => (st.image && st.image_credit ? [st.image_credit] : [])))];
return (
<Base colors={colors}>
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big className="text-[24px]">{slide.line}</Big>
<View className="mt-auto gap-2">
{slide.steps.map((st, i) => (
<View key={i} className="flex-row items-center gap-1.5 rounded-[14px] bg-card/80 px-2 py-1.5">
<Text className="w-[52px] font-jua text-sm text-ink2">{st.time}</Text>
<Ic name={st.icon} size={22} />
<View className="ml-1 flex-1">
<Text numberOfLines={1} className="text-[13.5px] font-bold text-ink">
{st.title}
</Text>
<Text numberOfLines={1} className="text-[11.5px] font-semibold text-ink2">
{st.sub}
</Text>
</View>
{st.image && <Thumb image={st.image} icon={st.icon} iconSize={26} className="size-[46px] rounded-[10px]" />}
</View>
))}
</View>
{credits.length > 0 && <Text className="mt-1.5 text-right text-[10px] font-semibold text-ink2">사진 {credits.join(' · ')}</Text>}
</Base>
);
}
if (slide.kind === 'rows' && slide.image)
return (
<View className="flex-1 justify-end">
<Image source={{ uri: imageUri(slide.image) }} style={StyleSheet.absoluteFill} contentFit="cover" />
{slide.image_credit && <Credit text={slide.image_credit} className="top-2.5 right-2.5" />}
<View className="px-5 pt-20 pb-3.5">
<LinearGradient colors={['rgba(16,20,34,0)', 'rgba(16,20,34,0.55)', 'rgba(16,20,34,0.85)']} locations={[0, 0.35, 1]} style={StyleSheet.absoluteFill} />
<Eyebrow light>{slide.eyebrow}</Eyebrow>
<Big light>{slide.line}</Big>
<Rows rows={slide.rows ?? []} dark />
</View>
</View>
);
return (
<Base colors={colors}>
<Eyebrow light={light} className={light ? 'opacity-85' : undefined}>
{slide.eyebrow}
</Eyebrow>
<Big light={light} className="z-[1]">
{slide.line}
</Big>
<Pic name={slide.icon} widthPct={36} />
<Rows rows={slide.rows ?? []} dark={light} />
</Base>
);
}