feat: React Native(Expo) 앱 추가 — 탭 구조와 오늘 화면

- Expo SDK 57 + expo-router, react-query, Uniwind(Tailwind v4), SecureStore 토큰
- Metro 가 앱의 react(19.2.3)만 쓰게 고정 (루트에는 웹용 react 19.3.0)
- 탭 5개·위 막대·시간대 하늘 배경·밤 테마, 오늘 히어로·각 순위·행사/TOP5/계절 띠
- 남은 이전 작업은 TODO.md 앱 마이그레이션 표
This commit is contained in:
minaChoi committed 2026-10-14 14:27:47 +09:00
1 parent 2ab2271d61
commit e52f93fdbb
56 files changed
+1211

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { Text, View } from 'react-native';
/** 아직 옮기지 않은 탭 */
export function ComingSoon({ title }: { title: string }) {
return (
<View className="flex-1 items-center justify-center gap-2">
<Text className="font-jua text-[22px] text-ink">{title}</Text>
<Text className="text-[13.5px] font-semibold text-ink2">앱으로 옮기는 중이에요</Text>
</View>
);
}
+26
View File
@@ -0,0 +1,26 @@
import type { TimeKind } from '@nalssigak/shared/lib';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet, View } from 'react-native';
import { useSky } from '@/lib/sky';
const SKY: Record<TimeKind, { colors: readonly [string, string, string]; locations: readonly [number, number, number] }> = {
morning: { colors: ['#ffe0c4', '#fff0e2', '#e4f2ff'], locations: [0, 0.38, 1] },
day: { colors: ['#cde7ff', '#e9f5ff', '#f7fbff'], locations: [0, 0.45, 1] },
sunset: { colors: ['#ffd0b5', '#f9c3cf', '#ddd2f6'], locations: [0, 0.42, 1] },
night: { colors: ['#0e1433', '#1b2356', '#2a2e6e'], locations: [0, 0.5, 1] },
};
const STARS = Array.from({ length: 46 }, (_, i) => ({ left: `${(i * 41 + 7) % 100}%`, top: `${(i * 67 + 3) % 96}%`, size: 1 + (i % 3) * 0.8, opacity: 0.4 + ((i * 7) % 6) / 10 }) as const);
/** 화면 전체 하늘: 시간대별 색, 밤에는 별 */
export function SkyBg() {
const { kind } = useSky();
return (
<View style={StyleSheet.absoluteFill} pointerEvents="none">
<LinearGradient {...SKY[kind]} style={StyleSheet.absoluteFill} />
{kind === 'night' &&
STARS.map((s, i) => <View key={i} style={{ position: 'absolute', left: s.left, top: s.top, width: s.size, height: s.size, borderRadius: s.size, backgroundColor: '#fff', opacity: s.opacity }} />)}
</View>
);
}
+39
View File
@@ -0,0 +1,39 @@
import Svg, { Circle, Path, Rect } from 'react-native-svg';
export type TabName = 'today' | 'gak' | 'sky' | 'week' | 'season';
const line = { fill: 'none', strokeLinecap: 'round', strokeLinejoin: 'round' } as const;
export function PinIcon({ size, color }: { size: number; color: string }) {
return (
<Svg viewBox="0 0 24 24" width={size} height={size} {...line} stroke={color} strokeWidth={2.2}>
<Path d="M12 21s7-6.2 7-11.5A7 7 0 0 0 5 9.5C5 14.8 12 21 12 21z" />
<Circle cx="12" cy="9.5" r="2.5" />
</Svg>
);
}
export function TabIcon({ name, size, color, strokeWidth }: { name: TabName; size: number; color: string; strokeWidth: number }) {
return (
<Svg viewBox="0 0 24 24" width={size} height={size} {...line} stroke={color} strokeWidth={strokeWidth}>
{name === 'today' && <Path d="M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z" />}
{name === 'gak' && (
<>
<Rect x="3.5" y="3.5" width="7" height="7" rx="2" />
<Rect x="13.5" y="3.5" width="7" height="7" rx="2" />
<Rect x="3.5" y="13.5" width="7" height="7" rx="2" />
<Rect x="13.5" y="13.5" width="7" height="7" rx="2" />
</>
)}
{name === 'sky' && <Path d="M3 18h18M6 14a6 6 0 0 1 12 0M12 4v3M4.9 7.9l2 2M19.1 7.9l-2 2M8 21h8" />}
{name === 'week' && (
<>
<Rect x="3.5" y="5" width="17" height="15.5" rx="2.5" />
<Path d="M3.5 10h17M8 3v4M16 3v4" />
<Circle cx="12" cy="15" r="1.6" />
</>
)}
{name === 'season' && <Path d="M12 6.5C10 5 7 4.5 3.5 5v14c3.5-.5 6.5 0 8.5 1.5 2-1.5 5-2 8.5-1.5V5C17 4.5 14 5 12 6.5zM12 6.5v14" />}
</Svg>
);
}
+60
View File
@@ -0,0 +1,60 @@
import type { BottomTabBarProps } from 'expo-router/tabs';
import { LinearGradient } from 'expo-linear-gradient';
import { Pressable, Text, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useCSSVariable } from 'uniwind';
import { TabIcon, type TabName } from '@/components/svg';
import { useSky } from '@/lib/sky';
const LABELS: Record<string, [TabName, string]> = {
sky: ['sky', '노을'],
gak: ['gak', '각'],
index: ['today', '오늘'],
week: ['week', '주말·행사'],
season: ['season', '계절·상식'],
};
/** 아래 탭 막대. 가운데 오늘 탭은 막대 위로 솟은 큰 주황 동그라미 */
export function TabBar({ state, navigation }: BottomTabBarProps) {
const { bottom } = useSafeAreaInsets();
const { kind } = useSky();
const [ink, ink3, orange] = useCSSVariable(['--color-ink', '--color-ink3', '--color-orange']).map(String);
const night = kind === 'night';
return (
<View
className="flex-row border-t px-1 pt-[7px]"
style={{ paddingBottom: 8 + bottom, backgroundColor: night ? 'rgb(18 24 60 / 0.92)' : 'rgb(255 255 255 / 0.85)', borderColor: night ? 'rgb(255 255 255 / 0.08)' : 'rgb(255 255 255 / 0.4)' }}
>
{state.routes.map((route, i) => {
const [icon, label] = LABELS[route.name] ?? ['today', route.name];
const focused = state.index === i;
const onPress = () => {
const event = navigation.emit({ type: 'tabPress', target: route.key, canPreventDefault: true });
if (!focused && !event.defaultPrevented) navigation.navigate(route.name);
};
if (icon === 'today')
return (
<Pressable key={route.key} onPress={onPress} accessibilityRole="tab" accessibilityState={{ selected: focused }} className="-mt-6 flex-1 items-center gap-1">
<View className="size-[68px] items-center justify-center rounded-full" style={{ backgroundColor: night ? 'rgb(18 24 60 / 0.9)' : 'rgb(255 255 255 / 0.85)' }}>
<LinearGradient colors={['#ffb067', '#ff7a45', '#d4552a']} locations={[0, 0.55, 1]} start={{ x: 0.3, y: 0 }} end={{ x: 0.7, y: 1 }} style={{ width: 60, height: 60, borderRadius: 30, alignItems: 'center', justifyContent: 'center', boxShadow: '0 8px 18px rgb(255 122 69 / 0.45)' }}>
<TabIcon name="today" size={30} color="#fff" strokeWidth={2.6} />
</LinearGradient>
</View>
<Text className="text-[12px] font-extrabold" style={{ color: focused ? orange : ink3 }}>
{label}
</Text>
</Pressable>
);
return (
<Pressable key={route.key} onPress={onPress} accessibilityRole="tab" accessibilityState={{ selected: focused }} className="flex-1 items-center gap-0.5">
<TabIcon name={icon} size={25} color={focused ? ink : ink3} strokeWidth={focused ? 2.4 : 1.9} />
<Text className="text-[11px] font-extrabold" style={{ color: focused ? ink : ink3 }}>
{label}
</Text>
</Pressable>
);
})}
</View>
);
}
+147
View File
@@ -0,0 +1,147 @@
import type { Hero as HeroData, ResWeatherToday, TopIndex } from '@nalssigak/shared/api/client/types.gen';
import { kindOfHour, kst, type Load, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib';
import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today';
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText';
import { useEffect, useState, type ReactNode } from 'react';
import { Pressable, Text, View } from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
import { Ic, Skel } from '@/components/ui';
import { useSky } from '@/lib/sky';
type Mode = 'now' | TimeKind;
const HERO_BG: Record<TimeKind | 'gray', readonly [string, string, string]> = {
morning: ['#ffd9b8', '#ffe9d4', '#dff0ff'],
day: ['#9fd3ff', '#cfe9ff', '#f1f8ff'],
sunset: ['#4c42b0', '#6a48b0', '#9a4a88'],
night: ['#141b3d', '#27306a', '#3d3f86'],
gray: ['#a9bbd0', '#cbd7e4', '#eef2f7'],
};
// 가운데 해(낮)·달(저녁·밤) 색과 글자색
const ORB: Record<'sun' | 'sunset' | 'night', { stops: [string, string, string, string]; text: string }> = {
sun: { stops: ['#fff5cf', '#ffc86e', '#ff8e4e', '#ee6436'], text: '#5c1f08' },
sunset: { stops: ['#fff4e6', '#ffd9b8', '#f7a991', '#e07a8f'], text: '#4a2442' },
night: { stops: ['#ffffff', '#e7e3ff', '#b9b0f2', '#8f86d9'], text: '#2b2a5c' },
};
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }) as const);
function useNow(ms = 20000) {
const [now, setNow] = useState(() => new Date());
useEffect(() => {
const id = setInterval(() => setNow(new Date()), ms);
return () => clearInterval(id);
}, [ms]);
return now;
}
const failed = (load: Load) => load === 'error' || load === 'retrying';
// 값이 오기 전엔 스켈레톤, 못 불러왔거나 값이 없으면 '?'
function heroVal(load: Load, v: ReactNode, skel: string) {
if (v != null) return v;
if (load === 'loading') return <Skel className={skel} />;
return <Text className="opacity-50">?</Text>;
}
type Props = { hero?: HeroData | null; today?: ResWeatherToday; ranked: TopIndex[]; feedLoad: Load; todayLoad: Load };
export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
const { preview, setServerKind, setPreview } = useSky();
const mode: Mode = preview ?? 'now';
const t = kst(useNow());
const nowKind = hero?.sky_mode ?? kindOfHour(t.h, t.mo, t.mi);
const kind = mode === 'now' ? nowKind : mode;
// 화면 전체 하늘 배경도 같은 시간대로 맞춘다
useEffect(() => setServerKind(hero?.sky_mode ?? null), [hero?.sky_mode, setServerKind]);
const slots = today?.slots ?? [];
// 지금은 가장 가까운 3시간 칸. 시간대는 그 시각 칸, 비어 있으면(지난 새벽 칸 등) 그 뒤 첫 예보 칸
const slotOf = (k: Mode) => {
if (k === 'now') {
const known = slots.filter((x) => x.temp_c != null);
const at = t.h + t.mi / 60;
return known.length ? known.reduce((a, b) => (Math.abs(kst(b.at).h - at) < Math.abs(kst(a.at).h - at) ? b : a)) : undefined;
}
const h = PREVIEW[k].hour;
const s = slots.length ? slotAt(slots, h) : undefined;
return s?.temp_c != null ? s : (slots.find((x) => kst(x.at).h > h && x.temp_c != null) ?? s);
};
const weather = weatherOf(slotOf(mode));
const slotScore = mode === 'now' ? undefined : hero?.weather_slots?.[SLOT_KEY[mode]];
const score = slotScore ?? hero?.weather_score;
const slotTop = mode === 'now' ? undefined : ranked.find((g) => g.active);
const top1 = slotTop ?? hero?.top1;
const dark = kind === 'sunset' || kind === 'night';
const moon = dark && hero?.moon_name && hero.moon_pct != null ? { pct: hero.moon_pct, waning: WANING.includes(hero.moon_name) } : null;
const when = mode === 'now' || mode === nowKind ? '지금' : PREVIEW[mode].label;
const bubble = slotTop ? (slotTop.score >= 70 ? `${when}은 ${slotTop.name}!` : `${when}은 쉬어 가요`) : hero ? (hero.bubble ?? '지금은 쉬어 가요') : failed(feedLoad) ? '앗, 날씨를 못 불러왔어요' : null;
const status = hero?.status ?? [];
const gray = !dark && weather !== 'clear' && weather !== 'partly';
const orb = ORB[kind === 'sunset' ? 'sunset' : kind === 'night' ? 'night' : 'sun'];
const text = dark ? 'text-white' : 'text-[#28304a]';
return (
<View className="mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3">
<LinearGradient colors={HERO_BG[gray ? 'gray' : kind]} locations={kind === 'night' ? [0, 0.6, 1] : [0, 0.5, 1]} style={{ position: 'absolute', inset: 0 }} />
{kind === 'night' && STARS.map((s, i) => <View key={i} className="absolute size-[3px] rounded-full bg-white" style={{ left: s.left, top: s.top, opacity: s.opacity }} />)}
<Text className={`text-[14px] font-bold opacity-80 ${text}`}>
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일
</Text>
<View className="h-[146px] items-center">
<View className="mt-2 size-32 items-center justify-center" style={{ boxShadow: `0 20px 40px ${kind === 'night' ? 'rgb(190 180 255 / 0.35)' : kind === 'sunset' ? 'rgb(255 150 110 / 0.4)' : 'rgb(240 106 58 / 0.32)'}`, borderRadius: 64 }}>
<Svg viewBox="-1 -1 2 2" width={128} height={128} style={{ position: 'absolute' }}>
<Defs>
<RadialGradient id="orb" cx="-0.32" cy="-0.4" r="1.4" gradientUnits="userSpaceOnUse">
<Stop offset="0" stopColor={orb.stops[0]} />
<Stop offset="0.3" stopColor={orb.stops[1]} />
<Stop offset="0.68" stopColor={orb.stops[2]} />
<Stop offset="1" stopColor={orb.stops[3]} />
</RadialGradient>
</Defs>
<Rect x="-1" y="-1" width="2" height="2" rx="1" fill="url(#orb)" opacity={gray ? 0.85 : 1} />
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
{moon && <Path d={moonPath(moon.pct, 1, false)} fill={kind === 'sunset' ? 'rgb(96 40 86 / .55)' : 'rgb(34 30 86 / .62)'} transform={moon.waning ? 'scale(-1,1)' : undefined} />}
</Svg>
<Text className="font-jua text-[12px]" style={{ color: orb.text }}>
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
</Text>
<Text className="font-bagel text-[52px] leading-[52px]" style={{ color: orb.text }}>
{heroVal(feedLoad, score, 'w-[84px] h-10')}
</Text>
</View>
</View>
<View className="items-center">
{bubble ? <Text className={`text-center font-jua text-[24px] leading-tight ${text}`}>{bubble}</Text> : <Skel className="h-6 w-[160px]" />}
{top1?.summary ? <Text className={`mt-0.5 text-center text-[15px] font-bold opacity-80 ${text}`}>{top1.summary}</Text> : feedLoad === 'loading' ? <Skel className="mt-1 w-[140px]" /> : null}
{/* 상태 한 줄: 습도·불쾌지수·자외선·미세먼지 단계 이름. 조심할 것만 색 */}
{status.length > 0 && (
<Text className={`mt-1.5 text-center font-jua text-[14px] ${text}`}>
{status.map((x, i) => (
<Text key={x.label}>
{i > 0 && <Text className="opacity-30"> · </Text>}
<Text style={x.tone === 'warn' ? { color: dark ? '#ffb38a' : '#d4552a' } : undefined}>
<Text className={x.tone !== 'warn' ? 'opacity-75' : undefined}>{x.label}</Text> {x.value}
</Text>
</Text>
))}
</Text>
)}
</View>
<View className="mt-2.5 flex-row gap-1 rounded-[18px] p-[3px]" style={{ backgroundColor: dark ? 'rgb(255 255 255 / 0.14)' : 'rgb(255 255 255 / 0.42)' }} accessibilityRole="tablist" accessibilityLabel="하루 흐름, 누르면 그 시간대 하늘로">
{KINDS.map((k) => {
const isNow = k === nowKind;
const s = slotOf(isNow ? 'now' : k);
const on = k === kind;
return (
<Pressable key={k} accessibilityRole="tab" accessibilityState={{ selected: on }} onPress={() => setPreview(isNow ? null : k)} className={`flex-1 items-center rounded-[14px] py-1.5 ${on ? 'bg-white' : ''}`} style={on ? { boxShadow: '0 4px 12px rgb(40 48 74 / 0.1)' } : undefined}>
<Text className={`text-[13px] font-bold ${on ? 'text-[#d4552a]' : `opacity-75 ${text}`}`}>{isNow ? '지금' : PREVIEW[k].label}</Text>
<Ic name={k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)]} size={22} style={{ marginVertical: 2 }} />
<Text className={`font-jua text-[15px] ${on ? 'text-[#28304a]' : text}`}>{heroVal(todayLoad, s?.temp_c != null ? deg(s.temp_c) : null, 'w-7')}</Text>
</Pressable>
);
})}
</View>
</View>
);
}
+135
View File
@@ -0,0 +1,135 @@
import type { BandArticle, BandEvent, TopIndex } from '@nalssigak/shared/api/client/types.gen';
import { cardBg, MEDALS } from '@nalssigak/shared/lib';
import { LinearGradient } from 'expo-linear-gradient';
import { Link, type Href } from 'expo-router';
import type { ReactNode } from 'react';
import { Pressable, Text, View } from 'react-native';
import { Ic, Rail, Sec, Skel, Thumb } from '@/components/ui';
import { CARD_BG, BAND_BG } from '@/lib/colors';
import { useSky } from '@/lib/sky';
const CARD = 'overflow-hidden rounded-[22px] border-b-[5px] border-shade bg-card';
/** 오늘의 각 순위: 동그라미 + 이름 + 점수. 지금 시간대가 아닌 각은 흐리게 */
export function Stories({ items }: { items: TopIndex[] }) {
return (
<Rail>
{items.map((g, i) => (
<View key={g.index_id} accessibilityLabel={g.active ? `${g.rank}위 ${g.name} ${g.score}점` : `${g.name}, 지금 시간대 아님`} className={`w-[72px] items-center gap-1 ${g.active ? '' : 'opacity-55'}`}>
<View className="size-[68px]">
{!g.active || g.score < 50 ? (
<View className="absolute inset-0 rounded-full bg-[#d6deea]" />
) : (
<LinearGradient colors={['#ff7a45', '#ffc86e', '#8fcaff']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={{ position: 'absolute', inset: 0, borderRadius: 34 }} />
)}
<View className="m-[3px] flex-1 items-center justify-center rounded-full border-[3px] border-page bg-page">
<Ic name={g.icon} size={42} />
</View>
{i < 3 && g.active && <Ic name={MEDALS[i]} size={25} style={{ position: 'absolute', right: -4, bottom: -4 }} />}
</View>
<Text numberOfLines={1} className="font-jua text-[13px] text-ink">
{g.name}
</Text>
{g.active ? <Text className="font-bagel text-[12.5px] leading-[14px] text-orange">{g.score}</Text> : <Text className="text-[11px] leading-[14px] font-extrabold text-ink3">지금 아님</Text>}
</View>
))}
</Rail>
);
}
const SKELS = Array.from({ length: 6 }, (_, i) => i);
export function StoriesSkel() {
return (
<Rail>
{SKELS.map((i) => (
<View key={i} className="w-[72px] items-center gap-1.5">
<View className="size-[68px] rounded-full bg-skel" />
<Skel className="w-12" />
<Skel className="w-6" />
</View>
))}
</Rail>
);
}
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: Href; children: ReactNode }) {
const { kind } = useSky();
return (
<View className="mt-3.5 pb-3.5" accessibilityLabel={title}>
<LinearGradient colors={BAND_BG[kind === 'night' ? 'night' : 'day'][tone]} style={{ position: 'absolute', inset: 0 }} />
<View className="-mt-[6px]">
<Sec title={title} sub={sub} more={to} />
</View>
{children}
</View>
);
}
function useCardBg() {
const { kind } = useSky();
return CARD_BG[kind === 'night' ? 'night' : 'day'];
}
export function EventsBand({ events }: { events: BandEvent[] }) {
const bg = useCardBg();
return (
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week">
<Rail>
{events.map((e, i) => (
<Link key={e.event_id} href="/week" asChild>
<Pressable className={`w-[200px] ${CARD}`}>
<Thumb image={e.image} icon={e.icon} iconSize={76} className="h-[116px]">
<LinearGradient colors={bg[cardBg(e.icon, i)]} style={{ position: 'absolute', inset: 0, zIndex: -1 }} />
<View className={`absolute top-2.5 left-2.5 rounded-full px-2 py-[3px] ${e.status_label === '진행 중' ? 'bg-[#1f9d62]' : 'bg-orange'}`}>
<Text className="text-[11.5px] font-extrabold text-white">{e.status_label}</Text>
</View>
</Thumb>
<Text className="px-3 pt-2.5 pb-3 font-jua text-[16.5px] leading-snug text-ink">{e.name}</Text>
</Pressable>
</Link>
))}
</Rail>
</Band>
);
}
export function TopBand({ items, sub }: { items: TopIndex[]; sub: string }) {
return (
<Band tone={2} title="지금 뜨는 각 TOP 5" sub={sub} to="/gak">
<Rail>
{items.slice(0, 5).map((g, i) => (
<View key={g.index_id} className="w-[138px] gap-1 rounded-[22px] border-b-[5px] border-shade bg-card p-3">
{i < 3 ? <Ic name={MEDALS[i]} size={26} style={{ position: 'absolute', top: 8, left: 8 }} /> : <Text className="absolute top-2.5 left-3 font-jua text-ink3">{i + 1}위</Text>}
<Ic name={g.icon} size={58} style={{ alignSelf: 'center' }} />
<Text className="font-jua text-base text-ink">{g.name}</Text>
<Text className="font-bagel text-[22px] leading-[24px] text-orange">{g.score}</Text>
{g.summary && <Text className="text-xs font-semibold text-ink2">{g.summary}</Text>}
</View>
))}
</Rail>
</Band>
);
}
export function SeasonBand({ news }: { news: BandArticle[] }) {
const bg = useCardBg();
return (
<Band tone={3} title="이번 주 계절 이야기" sub="예년 이맘때의 소식" to="/season">
<Rail>
{news.map((a) => (
<View key={a.article_id} className={`w-[200px] ${CARD}`}>
<Thumb image={a.image} icon={a.icon} iconSize={76} className="h-[116px]">
<LinearGradient colors={bg[cardBg(a.icon, a.article_id)]} style={{ position: 'absolute', inset: 0, zIndex: -1 }} />
</Thumb>
<View className="px-3 pt-2.5 pb-3">
<Text className="font-jua text-[16.5px] leading-snug text-ink">{a.title}</Text>
<Text className="text-[12.5px] font-semibold text-ink2">{a.meta}</Text>
</View>
</View>
))}
</Rail>
</Band>
);
}
+55
View File
@@ -0,0 +1,55 @@
import { getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { kst, seasonOf } from '@nalssigak/shared/lib';
import { useQuery } from '@tanstack/react-query';
import { usePathname } from 'expo-router';
import { useState } from 'react';
import { Text, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useCSSVariable } from 'uniwind';
import { PinIcon } from '@/components/svg';
import { Ic } from '@/components/ui';
import { useRegion } from '@/lib/region';
import { useSky } from '@/lib/sky';
const TITLES: Record<string, string> = { '/sky': '노을', '/gak': '오늘의 각', '/week': '주말·행사', '/season': '계절·상식' };
/** 로고 옆 계절 칩: 계절 이름과 지금 절기 */
function SeasonChip() {
const week = useQuery(getSeasonWeekOptions());
const [month] = useState(() => kst(new Date()).mo);
const [name, icon] = seasonOf(month);
const term = week.data?.term_now?.name;
return (
<View className="shrink flex-row items-center gap-1 rounded-full bg-card/70 py-1 pr-2.5 pl-1.5">
<Ic name={icon} size={18} />
<Text numberOfLines={1} className="text-[13px] font-extrabold text-ink">
{name}
{term && <Text className="font-bold opacity-70"> · {term}</Text>}
</Text>
</View>
);
}
export function TopBar() {
const pathname = usePathname();
const { region } = useRegion();
const { kind } = useSky();
const { top } = useSafeAreaInsets();
const ink = String(useCSSVariable('--color-ink'));
const title = TITLES[pathname];
return (
<View style={{ paddingTop: top, backgroundColor: kind === 'night' ? 'rgb(14 20 51 / 0.35)' : 'rgb(255 255 255 / 0.18)' }}>
<View className="h-[54px] flex-row items-center gap-2 px-4">
{title ? <Text className="font-jua text-[22px] text-ink">{title}</Text> : <Text className="font-jua text-[25px] text-orange">날씨각</Text>}
<SeasonChip />
<View className="ml-auto shrink-0 flex-row items-center gap-1 rounded-full border-b-4 border-shade bg-card px-3 pt-1 pb-1.5">
<PinIcon size={14} color={ink} />
<Text numberOfLines={1} className="text-[13.5px] font-bold text-ink">
{region.name.split(' ').at(-1)}
</Text>
</View>
</View>
</View>
);
}
+86
View File
@@ -0,0 +1,86 @@
import type { Load } from '@nalssigak/shared/lib';
import { Image, type ImageStyle } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { Link, type Href } from 'expo-router';
import { useState, type ReactNode } from 'react';
import { Pressable, ScrollView, Text, View, type StyleProp, type ViewStyle } from 'react-native';
import { ICONS } from '@/lib/icons';
import { imageUri } from '@/lib/site';
/** 아이콘 이름 → 그림. 'none'(데이터 없는 칸)은 빈 자리, 모르는 이름은 구름 낀 해 */
export function Ic({ name, size, style }: { name: string; size: number; style?: StyleProp<ImageStyle> }) {
if (name === 'none') return <View style={{ width: size, height: size }} />;
return <Image source={ICONS[name] ?? ICONS.sun_cloud} style={[{ width: size, height: size }, style]} contentFit="contain" />;
}
type Stops = readonly [string, string, ...string[]];
/** 위에서 아래로 흐르는 그라데이션 (웹 linear-gradient(180deg, ...)) */
export function Grad({ colors, locations, className, style, children }: { colors: Stops; locations?: readonly [number, number, ...number[]]; className?: string; style?: StyleProp<ViewStyle>; children?: ReactNode }) {
return (
<View className={className} style={style}>
<LinearGradient colors={colors} locations={locations} style={{ position: 'absolute', inset: 0 }} />
{children}
</View>
);
}
/** 사진이 있으면 사진, 없거나 못 불러오면 아이콘 */
export function Thumb({ image, icon, iconSize, className, style, children }: { image?: string | null; icon: string; iconSize: number; className?: string; style?: StyleProp<ViewStyle>; children?: ReactNode }) {
const [failed, setFailed] = useState<string | null>(null);
const photo = image && image !== failed ? image : null;
return (
<View className={`items-center justify-center overflow-hidden ${className ?? ''}`} style={style}>
{photo ? <Image source={{ uri: imageUri(photo) }} onError={() => setFailed(photo)} style={{ position: 'absolute', inset: 0 }} contentFit="cover" /> : <Ic name={icon} size={iconSize} />}
{children}
</View>
);
}
/** 불러오는 동안 자리만 잡는 막대 */
export function Skel({ className }: { className?: string }) {
return <View className={`h-[0.9em] min-h-3 rounded-full bg-skel ${className ?? ''}`} />;
}
export function Sec({ title, sub, more }: { title: string; sub?: string; more?: Href }) {
return (
<View className="flex-row items-end justify-between px-4 pt-[22px] pb-1.5">
<View>
<Text className="font-jua text-[21px] text-ink">{title}</Text>
{sub && <Text className="mt-0.5 text-[13px] font-semibold text-ink2">{sub}</Text>}
</View>
{more && (
<Link href={more} className="text-[13px] font-bold text-ink2">
전체 보기
</Link>
)}
</View>
);
}
/** 가로로 넘기는 줄 */
export function Rail({ children }: { children: ReactNode }) {
return (
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerClassName="gap-2.5 px-4 pt-3 pb-1">
{children}
</ScrollView>
);
}
/** 실패·빈 목록 안내. 불러오는 중엔 그리지 않는다(그 자리는 스켈레톤) */
export function StateBox({ load, onRetry, empty }: { load: Load; onRetry?: () => void; empty?: string }) {
const failed = load === 'error' || load === 'retrying';
const text = failed ? '정보를 불러오지 못했어요.' : load === 'ready' ? empty : undefined;
if (!text) return null;
return (
<View className="mx-3 mt-3 items-center gap-2 rounded-[22px] border-b-[5px] border-shade bg-card px-4 py-6">
<Text className="text-center text-[13.5px] font-semibold text-ink2">{text}</Text>
{failed && onRetry && (
<Pressable onPress={onRetry} disabled={load === 'retrying'} className="rounded-full bg-ink-btn px-4 py-1.5 disabled:opacity-60">
<Text className="text-[13px] font-bold text-white">{load === 'retrying' ? '다시 불러오는 중…' : '다시 시도'}</Text>
</Pressable>
)}
</View>
);
}