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 { useSheet } from '@/lib/sheet';
import { useSky } from '@/lib/sky';
const CARD = 'overflow-hidden rounded-[22px] border-b-[5px] border-shade bg-card';
/** 오늘의 각 순위: 동그라미 + 이름 + 점수. 지금 시간대가 아닌 각은 흐리게 */
export function Stories({ items }: { items: TopIndex[] }) {
const { open } = useSheet();
return (
{items.map((g, i) => (
open({ type: 'gak', indexId: 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'}`}>
{!g.active || g.score < 50 ? (
) : (
)}
{i < 3 && g.active && }
{g.name}
{g.active ? {g.score} : 지금 아님}
))}
);
}
const SKELS = Array.from({ length: 6 }, (_, i) => i);
export function StoriesSkel() {
return (
{SKELS.map((i) => (
))}
);
}
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: Href; children: ReactNode }) {
const { kind } = useSky();
return (
{children}
);
}
function useCardBg() {
const { kind } = useSky();
return CARD_BG[kind === 'night' ? 'night' : 'day'];
}
export function EventsBand({ events }: { events: BandEvent[] }) {
const bg = useCardBg();
return (
{events.map((e, i) => (
{e.status_label}
{e.name}
))}
);
}
export function TopBand({ items, sub }: { items: TopIndex[]; sub: string }) {
const { open } = useSheet();
return (
{items.slice(0, 5).map((g, i) => (
open({ type: 'gak', indexId: g.index_id })} className="w-[138px] gap-1 rounded-[22px] border-b-[5px] border-shade bg-card p-3">
{i < 3 ? : {i + 1}위}
{g.name}
{g.score}
{g.summary && {g.summary}}
))}
);
}
export function SeasonBand({ news }: { news: BandArticle[] }) {
const bg = useCardBg();
const { open } = useSheet();
return (
{news.map((a) => (
open({ type: 'article', articleId: a.article_id })} className={`w-[200px] ${CARD}`}>
{a.title}
{a.meta}
))}
);
}