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 { Pressable, View } from 'react-native'; import { Text } from '@/components/text'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useCSSVariable } from 'uniwind'; import { PinIcon } from '@/components/svg'; import { Avatar, Ic, Skel } from '@/components/ui'; import { useAuth } from '@/lib/auth'; import { useRegion } from '@/lib/region'; import { useSheet } from '@/lib/sheet'; import { useSky } from '@/lib/sky'; const TITLES: Record = { '/sky': '노을', '/gak': '오늘의 각', '/week': '주말·행사', '/season': '계절·상식' }; /** 로고 옆 계절 칩: 계절 이름과 지금 절기. 누르면 이번 주 절기 창 */ function SeasonChip() { const { open } = useSheet(); const week = useQuery(getSeasonWeekOptions()); const [month] = useState(() => kst(new Date()).mo); const [name, icon] = seasonOf(month); const term = week.data?.term_now?.name; return ( open({ type: 'seasonWeek' })} accessibilityLabel={`지금 ${name}${term ? `, ${term}` : ''}. 이번 주 절기 보기`} className="shrink flex-row items-center gap-1 rounded-full bg-card/70 py-1 pr-2.5 pl-1.5"> {name} {term && · {term}} ); } /** 오른쪽 끝: 내 정보(아바타) 또는 로그인 버튼 */ function Account() { const { open } = useSheet(); const { me, mePending } = useAuth(); if (mePending) return ; if (me) return ( open({ type: 'me' })} accessibilityLabel={`내 정보, ${me.nickname}`} className="shrink-0 rounded-full" style={{ boxShadow: '0 6px 12px rgb(40 48 74 / 0.12)' }}> ); return ( open({ type: 'login' })} className="shrink-0 rounded-full bg-ink-btn px-3 py-1.5"> 로그인 ); } export function TopBar() { const pathname = usePathname(); const { region, locateStatus } = useRegion(); const { open } = useSheet(); const { kind } = useSky(); const { top } = useSafeAreaInsets(); const ink = String(useCSSVariable('--color-ink')); const title = TITLES[pathname]; return ( {title ? {title} : 날씨각} open({ type: 'region' })} accessibilityLabel={`위치 바꾸기, 지금 ${region.name}`} 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"> {locateStatus === 'locating' ? ( ) : ( {region.name.split(' ').at(-1)} )} ); }