Files
o2o-weather/mobile/src/components/screen-header.tsx
T

32 lines
1.5 KiB
TypeScript

import { router } from 'expo-router';
import { Pressable, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Svg, { Path } from 'react-native-svg';
import { useCSSVariable } from 'uniwind';
import { Text } from '@/components/text';
import { useSky } from '@/lib/sky';
/** 탭 밖 화면(사주·이야기·게임 등) 머리줄: 뒤로 가기와 제목. 뒤로 갈 곳이 없으면(링크로 바로 열림) 오늘 탭으로 */
export function ScreenHeader({ title, right }: { title: string; right?: React.ReactNode }) {
const { top } = useSafeAreaInsets();
const { kind } = useSky();
const ink = String(useCSSVariable('--color-ink'));
const back = () => (router.canGoBack() ? router.back() : router.replace('/'));
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-1 px-2">
<Pressable onPress={back} hitSlop={8} accessibilityRole="button" accessibilityLabel="뒤로" className="size-10 items-center justify-center">
<Svg viewBox="0 0 24 24" width={24} height={24} fill="none" stroke={ink} strokeWidth={2.2} strokeLinecap="round" strokeLinejoin="round">
<Path d="M15 5l-7 7 7 7" />
</Svg>
</Pressable>
<Text numberOfLines={1} className="flex-1 font-jua text-[21px] text-ink">
{title}
</Text>
{right}
</View>
</View>
);
}