62 lines
3.1 KiB
TypeScript
62 lines
3.1 KiB
TypeScript
import type { BottomTabBarProps } from 'expo-router/tabs';
|
|
import { LinearGradient } from 'expo-linear-gradient';
|
|
import { Pressable, View } from 'react-native';
|
|
import { Text } from '@/components/text';
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
import { useCSSVariable } from 'uniwind';
|
|
|
|
import { TabIcon, type TabName } from '@/components/svg';
|
|
import { useSky } from '@/lib/sky';
|
|
|
|
const LABELS: Record<string, [TabName, string]> = {
|
|
sky: ['sky', '노을'],
|
|
gak: ['gak', '각'],
|
|
index: ['today', '오늘'],
|
|
week: ['week', '주말·행사'],
|
|
season: ['season', '계절·상식'],
|
|
};
|
|
|
|
/** 아래 탭 막대. 가운데 오늘 탭은 막대 위로 솟은 큰 주황 동그라미 */
|
|
export function TabBar({ state, navigation }: BottomTabBarProps) {
|
|
const { bottom } = useSafeAreaInsets();
|
|
const { kind } = useSky();
|
|
const [ink, ink3, orange] = useCSSVariable(['--color-ink', '--color-ink3', '--color-orange']).map(String);
|
|
const night = kind === 'night';
|
|
return (
|
|
<View
|
|
className="flex-row border-t px-1 pt-[7px]"
|
|
style={{ paddingBottom: 8 + bottom, backgroundColor: night ? 'rgb(18 24 60 / 0.92)' : 'rgb(255 255 255 / 0.85)', borderColor: night ? 'rgb(255 255 255 / 0.08)' : 'rgb(255 255 255 / 0.4)' }}
|
|
>
|
|
{state.routes.map((route, i) => {
|
|
const [icon, label] = LABELS[route.name] ?? ['today', route.name];
|
|
const focused = state.index === i;
|
|
const onPress = () => {
|
|
const event = navigation.emit({ type: 'tabPress', target: route.key, canPreventDefault: true });
|
|
if (!focused && !event.defaultPrevented) navigation.navigate(route.name);
|
|
};
|
|
if (icon === 'today')
|
|
return (
|
|
<Pressable key={route.key} onPress={onPress} accessibilityRole="tab" accessibilityState={{ selected: focused }} className="-mt-6 flex-1 items-center gap-1">
|
|
<View className="size-[68px] items-center justify-center rounded-full" style={{ backgroundColor: night ? 'rgb(18 24 60 / 0.9)' : 'rgb(255 255 255 / 0.85)' }}>
|
|
<LinearGradient colors={['#ffb067', '#ff7a45', '#d4552a']} locations={[0, 0.55, 1]} start={{ x: 0.3, y: 0 }} end={{ x: 0.7, y: 1 }} style={{ width: 60, height: 60, borderRadius: 30, alignItems: 'center', justifyContent: 'center', boxShadow: '0 8px 18px rgb(255 122 69 / 0.45)' }}>
|
|
<TabIcon name="today" size={30} color="#fff" strokeWidth={2.6} />
|
|
</LinearGradient>
|
|
</View>
|
|
<Text className="text-[12px] font-extrabold" style={{ color: focused ? orange : ink3 }}>
|
|
{label}
|
|
</Text>
|
|
</Pressable>
|
|
);
|
|
return (
|
|
<Pressable key={route.key} onPress={onPress} accessibilityRole="tab" accessibilityState={{ selected: focused }} className="flex-1 items-center gap-0.5">
|
|
<TabIcon name={icon} size={25} color={focused ? ink : ink3} strokeWidth={focused ? 2.4 : 1.9} />
|
|
<Text className="text-[11px] font-extrabold" style={{ color: focused ? ink : ink3 }}>
|
|
{label}
|
|
</Text>
|
|
</Pressable>
|
|
);
|
|
})}
|
|
</View>
|
|
);
|
|
}
|