import type { BestTime, SkyPlanData } from '@nalssigak/shared/api/client/types.gen'; import { clockShort } from '@nalssigak/shared/lib'; import { LinearGradient } from 'expo-linear-gradient'; import { useState, type ReactNode } from 'react'; import { Pressable, View } from 'react-native'; import { Text } from '@/components/text'; import { useCSSVariable } from 'uniwind'; import { RAIL, skyOf } from '@/components/sky/colors'; import { SitSun, Skyline } from '@/components/sky/skyline'; import { MapLink, Skel } from '@/components/ui'; const SHADOW = { textShadowColor: 'rgb(50 25 70 / 0.35)', textShadowOffset: { width: 0, height: 2 }, textShadowRadius: 10 }; const FOUR = [0, 1, 2, 3]; /** 히어로엔 답만: 노을 피크 시각과 어떻게 물드는지. 상자는 불러오는 중·실패·빈 값 모두 같은 크기 */ export function SkyHero({ plan, children }: { plan?: SkyPlanData; children?: ReactNode }) { const g = skyOf(plan?.grade_label).hero; return ( {children ?? ( {plan ? ( {plan.title} ) : ( )} {!plan ? ( ) : plan.situation_label ? ( {plan.situation_label} ) : null} )} ); } /** 오늘·내일·모레를 그날 예상 하늘색 타일로. 누르면 그날로 */ export function DayTiles({ plans, day, onPick }: { plans: SkyPlanData[]; day?: string; onPick: (day: string) => void }) { const ink = String(useCSSVariable('--color-ink')); return ( {plans.map((p) => { const g = skyOf(p.grade_label).tile; const on = p.day === day; return ( onPick(p.day)} className="flex-1 rounded-[18px] p-[2px]" style={{ borderWidth: 3, borderColor: on ? ink : 'transparent' }}> {p.when} {p.best_at ? clockShort(p.best_at) : '–'} {p.grade_label} {p.score} ); })} ); } function Toggle({ label, children, end }: { label: ReactNode; children: ReactNode; end?: boolean }) { const [open, setOpen] = useState(false); return ( setOpen(!open)} accessibilityState={{ expanded: open }} className={`flex-row items-center gap-1.5 ${end ? 'justify-between' : ''}`}> {label} {open && children} ); } const Q = ({ className = 'bg-card/80' }: { className?: string }) => ( ? ); /** 노을 점수 뜻. 지금 하늘이 아니라 해 질(뜰) 무렵 예보라는 것도 */ export function ScoreHelp({ plan }: { plan: SkyPlanData }) { const sunAt = plan.timeline?.find((t) => t.kind === 'sun')?.at; const rise = plan.kind === 'sunrise'; return ( 노을 점수 100점 만점 · 높을수록 붉어요 } > 80점 넘으면 붉게, 60점 넘으면 곱게, 40점 넘으면 은은하게 물들어요. {sunAt && ` 해 ${rise ? '뜰' : '질'} 무렵(${new Date(sunAt).getHours()}시) 날씨 예보로 계산했고, 노을 피크 시각은 해 ${rise ? '뜨기 10~20분 전' : '지고 10~20분 뒤'}로 어림한 거라 실제와 다를 수 있어요.`} ); } /** 언제 보면 좋을까: 왼쪽 세로 줄 색이 그 시각 하늘색, 노을 피크만 강조 */ export function Timeline({ rows, kind = 'sunset' }: { rows?: BestTime[]; kind?: SkyPlanData['kind'] }) { const rail = RAIL[kind === 'sunrise' ? 'sunrise' : 'sunset']; const list = rows ?? FOUR.map(() => undefined); return ( {list.map((t, i) => { const peak = t?.kind === 'peak'; return ( {t ? {t.end ? `${clockShort(t.at)}~${clockShort(t.end)}` : clockShort(t.at)} : } {t ? {t.label} : } ); })} {rows && ( 골든아워·블루아워가 뭐예요 } > 골든아워 해가 {kind === 'sunrise' ? '뜬 뒤' : '지기 전'}, 햇빛이 금빛으로 물드는 시간{'\n'} 블루아워 해가 {kind === 'sunrise' ? '뜨기 전' : '진 뒤'}, 하늘이 짙은 파랑으로 남는 시간 )} ); } const ROW = 'flex-row items-center gap-2.5 px-1 py-3'; export function LiSkel({ ghost = false, last = false }: { ghost?: boolean; last?: boolean }) { return ( ); } /** 번호 · 이름(+설명) · 오른쪽 값 한 줄 */ export function Li({ no, title, sub, right, mine = false, place, last = false }: { no: number; title: string; sub?: string | null; right: string; mine?: boolean; place?: string; last?: boolean }) { return ( {no} {place ? {title} : title} {mine && 내 지역} {sub || ' '} {right} ); }