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:
1 parent
2ab2271d61
commit
e52f93fdbb
56 files changed
+1211
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import '@/lib/api';
|
||||
import { BagelFatOne_400Regular } from '@expo-google-fonts/bagel-fat-one';
|
||||
import { Jua_400Regular, useFonts } from '@expo-google-fonts/jua';
|
||||
import { QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Tabs } from 'expo-router/tabs';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { useEffect } from 'react';
|
||||
import { View } from 'react-native';
|
||||
|
||||
import '@/global.css';
|
||||
import { SkyBg } from '@/components/sky-bg';
|
||||
import { TabBar } from '@/components/tab-bar';
|
||||
import { TopBar } from '@/components/top-bar';
|
||||
import { queryClient } from '@/lib/query-client';
|
||||
import { RegionProvider } from '@/lib/region';
|
||||
import { SkyProvider, useSky } from '@/lib/sky';
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
function Shell() {
|
||||
const { kind } = useSky();
|
||||
return (
|
||||
<View className="flex-1">
|
||||
<SkyBg />
|
||||
<StatusBar style={kind === 'night' ? 'light' : 'dark'} />
|
||||
<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>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
const [loaded, error] = useFonts({ Jua_400Regular, BagelFatOne_400Regular });
|
||||
useEffect(() => {
|
||||
if (loaded || error) SplashScreen.hideAsync();
|
||||
}, [loaded, error]);
|
||||
if (!loaded && !error) return null;
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<SkyProvider>
|
||||
<RegionProvider>
|
||||
<Shell />
|
||||
</RegionProvider>
|
||||
</SkyProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ComingSoon } from '@/components/coming-soon';
|
||||
|
||||
export default function Screen() {
|
||||
return <ComingSoon title="오늘의 각" />;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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 { RefreshControl, ScrollView } from 'react-native';
|
||||
|
||||
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 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()]);
|
||||
|
||||
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="오늘 계산된 각이 없어요." />}
|
||||
{!!bands?.events?.length && <EventsBand events={bands.events} />}
|
||||
{!!bands?.top5?.length && <TopBand items={sloted ? stories.filter((g) => g.active) : bands.top5} sub={sloted ? `${PREVIEW[preview].label} 기준` : nowAt ? `${kst(nowAt).h}시 기준` : '오늘 기준'} />}
|
||||
{!!bands?.season?.length && <SeasonBand news={bands.season} />}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ComingSoon } from '@/components/coming-soon';
|
||||
|
||||
export default function Screen() {
|
||||
return <ComingSoon title="계절·상식" />;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ComingSoon } from '@/components/coming-soon';
|
||||
|
||||
export default function Screen() {
|
||||
return <ComingSoon title="노을" />;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ComingSoon } from '@/components/coming-soon';
|
||||
|
||||
export default function Screen() {
|
||||
return <ComingSoon title="주말·행사" />;
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
@import 'tailwindcss';
|
||||
@import 'uniwind';
|
||||
|
||||
/* 웹 b.css 의 색 토큰. 밤(dark)은 화면 전체를 어두운 테마로 (글자 대비 AA 4.5:1 이상) */
|
||||
@layer theme {
|
||||
:root {
|
||||
@variant light {
|
||||
--color-ink: #28304a;
|
||||
--color-ink2: #5a6380;
|
||||
--color-ink3: #8a92aa;
|
||||
--color-line: #e6ecf4;
|
||||
--color-page: #f7fbff;
|
||||
--color-shade: #d9e5f4;
|
||||
--color-orange: #ff7a45;
|
||||
--color-orange-deep: #d4552a;
|
||||
--color-rain: #4f97e3;
|
||||
--color-heart: #ff3b5c;
|
||||
--color-card: #ffffff;
|
||||
--color-chip: #ffffff;
|
||||
--color-warn: #d4552a;
|
||||
--color-skel: rgb(40 48 74 / 0.13);
|
||||
--color-ink-btn: #28304a;
|
||||
}
|
||||
@variant dark {
|
||||
--color-ink: #eef1ff;
|
||||
--color-ink2: #c3c9ec;
|
||||
--color-ink3: #a1a9db;
|
||||
--color-line: rgb(255 255 255 / 0.1);
|
||||
--color-page: #1a2150;
|
||||
--color-shade: #141a42;
|
||||
--color-orange: #ff8a57;
|
||||
--color-orange-deep: #d4552a;
|
||||
--color-rain: #4f97e3;
|
||||
--color-heart: #ff6b85;
|
||||
--color-card: #222a5c;
|
||||
--color-chip: #2b3470;
|
||||
--color-warn: #ffb38a;
|
||||
--color-skel: rgb(238 241 255 / 0.17);
|
||||
--color-ink-btn: #4b56b5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@theme {
|
||||
--font-jua: 'Jua_400Regular';
|
||||
--font-bagel: 'BagelFatOne_400Regular';
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { configureApi } from '@nalssigak/shared/api/setup';
|
||||
import * as SecureStore from 'expo-secure-store';
|
||||
|
||||
configureApi({
|
||||
baseUrl: process.env.EXPO_PUBLIC_API_BASE_URL ?? 'http://localhost:9810',
|
||||
storage: {
|
||||
getItem: (key) => SecureStore.getItem(key),
|
||||
setItem: (key, value) => SecureStore.setItem(key, value),
|
||||
removeItem: (key) => {
|
||||
SecureStore.deleteItemAsync(key).catch((e: unknown) => console.warn('토큰 삭제 실패', key, e));
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
// 웹 b.css 의 카드 배경(.b-bg-*)·가로 띠(.b-band-*) 그라데이션. 밤은 어두운 판
|
||||
type Stops = readonly [string, string, ...string[]];
|
||||
|
||||
export const CARD_BG: Record<'day' | 'night', Record<string, Stops>> = {
|
||||
day: {
|
||||
sky: ['#bfe3ff', '#eef7ff'],
|
||||
butter: ['#ffe7a0', '#fff6d8'],
|
||||
peach: ['#ffd2bb', '#fff2ea'],
|
||||
mint: ['#bfecd6', '#effaf4'],
|
||||
lilac: ['#d8cffc', '#f4f1ff'],
|
||||
dusk: ['#7e6fe6', '#f08aa2', '#ffc28a'],
|
||||
night: ['#1f2658', '#3d3f86'],
|
||||
},
|
||||
night: {
|
||||
sky: ['#2a4384', '#1f2c62'],
|
||||
butter: ['#4d4128', '#2c2a3e'],
|
||||
peach: ['#553632', '#2e2840'],
|
||||
mint: ['#1f4a45', '#1d2d4a'],
|
||||
lilac: ['#3d3480', '#262a5e'],
|
||||
dusk: ['#7e6fe6', '#f08aa2', '#ffc28a'],
|
||||
night: ['#1f2658', '#3d3f86'],
|
||||
},
|
||||
};
|
||||
|
||||
export const BAND_BG: Record<'day' | 'night', Record<1 | 2 | 3, Stops>> = {
|
||||
day: { 1: ['#fff4ec', '#f7fbff'], 2: ['#fff6d8', '#f7fbff'], 3: ['#e9fbf2', '#f7fbff'] },
|
||||
night: { 1: ['rgba(255,160,110,0.12)', 'rgba(255,255,255,0)'], 2: ['rgba(255,214,110,0.12)', 'rgba(255,255,255,0)'], 3: ['rgba(110,230,180,0.12)', 'rgba(255,255,255,0)'] },
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
// frontend/public 의 아이콘을 그대로 쓴다. Metro 는 정적 require 만 묶을 수 있어 이름마다 적는다
|
||||
export const ICONS: Record<string, number> = {
|
||||
apple: require('../../../frontend/public/icons/apple.png'),
|
||||
baseball: require('../../../frontend/public/icons/baseball.png'),
|
||||
bear: require('../../../frontend/public/icons/bear.png'),
|
||||
bike: require('../../../frontend/public/icons/bike.png'),
|
||||
bingsu: require('../../../frontend/public/icons/bingsu.png'),
|
||||
blanket: require('../../../frontend/public/icons/blanket.png'),
|
||||
bronze: require('../../../frontend/public/icons/bronze.png'),
|
||||
bungeoppang: require('../../../frontend/public/icons/bungeoppang.png'),
|
||||
camping: require('../../../frontend/public/icons/camping.png'),
|
||||
carwash: require('../../../frontend/public/icons/carwash.png'),
|
||||
chestnut: require('../../../frontend/public/icons/chestnut.png'),
|
||||
chimaek: require('../../../frontend/public/icons/chimaek.png'),
|
||||
cloud: require('../../../frontend/public/icons/cloud.png'),
|
||||
coldwind: require('../../../frontend/public/icons/coldwind.png'),
|
||||
delivery: require('../../../frontend/public/icons/delivery.png'),
|
||||
dog: require('../../../frontend/public/icons/dog.png'),
|
||||
drive: require('../../../frontend/public/icons/drive.png'),
|
||||
fallen_leaf: require('../../../frontend/public/icons/fallen_leaf.png'),
|
||||
fishing: require('../../../frontend/public/icons/fishing.png'),
|
||||
flower: require('../../../frontend/public/icons/flower.png'),
|
||||
garden: require('../../../frontend/public/icons/garden.png'),
|
||||
glasses: require('../../../frontend/public/icons/glasses.png'),
|
||||
gold: require('../../../frontend/public/icons/gold.png'),
|
||||
golf: require('../../../frontend/public/icons/golf.png'),
|
||||
hiking: require('../../../frontend/public/icons/hiking.png'),
|
||||
iced_hot: require('../../../frontend/public/icons/iced_hot.png'),
|
||||
indoordry: require('../../../frontend/public/icons/indoordry.png'),
|
||||
jipkok: require('../../../frontend/public/icons/jipkok.png'),
|
||||
jjamppong: require('../../../frontend/public/icons/jjamppong.png'),
|
||||
kimchi: require('../../../frontend/public/icons/kimchi.png'),
|
||||
kite: require('../../../frontend/public/icons/kite.png'),
|
||||
laundry: require('../../../frontend/public/icons/laundry.png'),
|
||||
letter: require('../../../frontend/public/icons/letter.png'),
|
||||
makeup: require('../../../frontend/public/icons/makeup.png'),
|
||||
makgeolli: require('../../../frontend/public/icons/makgeolli.png'),
|
||||
maple: require('../../../frontend/public/icons/maple.png'),
|
||||
mask: require('../../../frontend/public/icons/mask.png'),
|
||||
moon: require('../../../frontend/public/icons/moon.png'),
|
||||
muggy: require('../../../frontend/public/icons/muggy.png'),
|
||||
naengmyeon: require('../../../frontend/public/icons/naengmyeon.png'),
|
||||
netflix: require('../../../frontend/public/icons/netflix.png'),
|
||||
pajeon: require('../../../frontend/public/icons/pajeon.png'),
|
||||
peanut: require('../../../frontend/public/icons/peanut.png'),
|
||||
photo: require('../../../frontend/public/icons/photo.png'),
|
||||
picnic: require('../../../frontend/public/icons/picnic.png'),
|
||||
rabbit: require('../../../frontend/public/icons/rabbit.png'),
|
||||
rain: require('../../../frontend/public/icons/rain.png'),
|
||||
riverwind: require('../../../frontend/public/icons/riverwind.png'),
|
||||
running: require('../../../frontend/public/icons/running.png'),
|
||||
silver: require('../../../frontend/public/icons/silver.png'),
|
||||
singing_rain: require('../../../frontend/public/icons/singing_rain.png'),
|
||||
snow: require('../../../frontend/public/icons/snow.png'),
|
||||
stars: require('../../../frontend/public/icons/stars.png'),
|
||||
study: require('../../../frontend/public/icons/study.png'),
|
||||
sun_cloud: require('../../../frontend/public/icons/sun_cloud.png'),
|
||||
sun: require('../../../frontend/public/icons/sun.png'),
|
||||
sunset: require('../../../frontend/public/icons/sunset.png'),
|
||||
sweet_potato: require('../../../frontend/public/icons/sweet_potato.png'),
|
||||
tangerine: require('../../../frontend/public/icons/tangerine.png'),
|
||||
taxi: require('../../../frontend/public/icons/taxi.png'),
|
||||
trot: require('../../../frontend/public/icons/trot.png'),
|
||||
umbrella: require('../../../frontend/public/icons/umbrella.png'),
|
||||
vent: require('../../../frontend/public/icons/vent.png'),
|
||||
walk: require('../../../frontend/public/icons/walk.png'),
|
||||
waterplay: require('../../../frontend/public/icons/waterplay.png'),
|
||||
yajang: require('../../../frontend/public/icons/yajang.png'),
|
||||
bulb: require('../../../frontend/public/b/icons/bulb.png'),
|
||||
calendar: require('../../../frontend/public/b/icons/calendar.png'),
|
||||
concert: require('../../../frontend/public/b/icons/concert.png'),
|
||||
exhibition: require('../../../frontend/public/b/icons/exhibition.png'),
|
||||
fireworks: require('../../../frontend/public/b/icons/fireworks.png'),
|
||||
popup: require('../../../frontend/public/b/icons/popup.png'),
|
||||
sheaf: require('../../../frontend/public/b/icons/sheaf.png'),
|
||||
thermo: require('../../../frontend/public/b/icons/thermo.png'),
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { focusManager, keepPreviousData, QueryClient } from '@tanstack/react-query';
|
||||
import { AppState, Platform } from 'react-native';
|
||||
|
||||
// 앱이 다시 앞으로 오면 '포커스'로 보고, 5분 넘게 묵은 데이터만 다시 받는다
|
||||
if (Platform.OS !== 'web') {
|
||||
focusManager.setEventListener((setFocused) => {
|
||||
const sub = AppState.addEventListener('change', (state) => setFocused(state === 'active'));
|
||||
return () => sub.remove();
|
||||
});
|
||||
}
|
||||
|
||||
// 웹과 같은 기본값: 다시 받는 동안 이전 결과를 그대로 두어 화면이 비지 않게 한다
|
||||
export const queryClient = new QueryClient({
|
||||
defaultOptions: { queries: { staleTime: 5 * 60 * 1000, retry: 1, placeholderData: keepPreviousData } },
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { RegionData } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { DEFAULT_REGION } from '@nalssigak/shared/lib';
|
||||
import { createContext, use, useMemo, useState, type ReactNode } from 'react';
|
||||
|
||||
export type RegionApi = { region: RegionData; setRegion: (r: RegionData) => void };
|
||||
|
||||
const RegionContext = createContext<RegionApi | null>(null);
|
||||
|
||||
export function useRegion() {
|
||||
const ctx = use(RegionContext);
|
||||
if (!ctx) throw new Error('useRegion must be used inside RegionProvider');
|
||||
return ctx;
|
||||
}
|
||||
|
||||
export function RegionProvider({ children }: { children: ReactNode }) {
|
||||
const [region, setRegion] = useState<RegionData>(DEFAULT_REGION);
|
||||
const api = useMemo(() => ({ region, setRegion }), [region]);
|
||||
return <RegionContext value={api}>{children}</RegionContext>;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export const SITE_URL = (process.env.EXPO_PUBLIC_SITE_URL ?? 'https://weather.o2o.kr').replace(/\/+$/, '');
|
||||
|
||||
/** 서버가 주는 사진 경로가 '/season/..' 처럼 사이트 기준이면 사이트 주소를 붙인다 */
|
||||
export const imageUri = (path: string) => (path.startsWith('/') ? `${SITE_URL}${path}` : path);
|
||||
@@ -0,0 +1,30 @@
|
||||
import { kindOfHour, kst, type TimeKind } from '@nalssigak/shared/lib';
|
||||
import { createContext, use, useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||
import { Uniwind } from 'uniwind';
|
||||
|
||||
/** 화면 전체 하늘의 시간대. 히어로에서 고른 미리보기는 탭을 옮겨도 유지된다 */
|
||||
export type SkyApi = { kind: TimeKind; preview: TimeKind | null; setServerKind: (k: TimeKind | null) => void; setPreview: (k: TimeKind | null) => void };
|
||||
|
||||
const SkyContext = createContext<SkyApi | null>(null);
|
||||
|
||||
export function useSky() {
|
||||
const ctx = use(SkyContext);
|
||||
if (!ctx) throw new Error('useSky must be used inside SkyProvider');
|
||||
return ctx;
|
||||
}
|
||||
|
||||
export function SkyProvider({ children }: { children: ReactNode }) {
|
||||
const [preview, setPreview] = useState<TimeKind | null>(null);
|
||||
const [serverKind, setServerKind] = useState<TimeKind | null>(null);
|
||||
const [now, setNow] = useState(() => new Date());
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => setNow(new Date()), 60000);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
const t = kst(now);
|
||||
const kind = preview ?? serverKind ?? kindOfHour(t.h, t.mo, t.mi);
|
||||
// 밤에만 어두운 테마 (기기 다크 모드와 상관없이 하늘 시간대를 따른다)
|
||||
useEffect(() => Uniwind.setTheme(kind === 'night' ? 'dark' : 'light'), [kind]);
|
||||
const api = useMemo(() => ({ kind, preview, setPreview, setServerKind }), [kind, preview]);
|
||||
return <SkyContext value={api}>{children}</SkyContext>;
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// NOTE: This file is generated by uniwind and it should not be edited manually.
|
||||
/// <reference types="uniwind/types" />
|
||||
|
||||
declare module 'uniwind' {
|
||||
export interface UniwindConfig {
|
||||
themes: readonly ['light', 'dark']
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
Reference in new issue
Block a user