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,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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user