import React from 'react'; import { View, StyleSheet, TouchableOpacity, Platform, Dimensions } from 'react-native'; import { BottomTabBarProps } from '@react-navigation/bottom-tabs'; import { Ionicons } from '@expo/vector-icons'; import { LinearGradient } from 'expo-linear-gradient'; import { theme } from '../styles/theme'; import { Animated } from 'react-native'; const { width } = Dimensions.get('window'); export function CustomTabBar({ state, descriptors, navigation }: BottomTabBarProps) { return ( {state.routes.map((route, index) => { const { options } = descriptors[route.key]; const isFocused = state.index === index; const onPress = () => { const event = navigation.emit({ type: 'tabPress', target: route.key, canPreventDefault: true, }); if (!isFocused && !event.defaultPrevented) { navigation.navigate(route.name); } }; const getIconName = (routeName: string, focused: boolean): keyof typeof Ionicons.glyphMap => { switch (routeName) { case 'index': return focused ? 'home' : 'home-outline'; case 'goals': return focused ? 'trophy' : 'trophy-outline'; case 'attendance': return focused ? 'calendar' : 'calendar-outline'; case 'recommendations': return focused ? 'sparkles' : 'sparkles-outline'; case 'profile': return focused ? 'person' : 'person-outline'; default: return 'ellipse-outline'; } }; // Animation for scale const scaleValue = React.useRef(new Animated.Value(1)).current; React.useEffect(() => { Animated.spring(scaleValue, { toValue: isFocused ? 1.2 : 1, useNativeDriver: true, friction: 8, }).start(); }, [isFocused]); return ( {isFocused ? ( ) : ( )} ); })} ); } const styles = StyleSheet.create({ container: { position: 'absolute', bottom: 0, left: 0, right: 0, alignItems: 'center', paddingBottom: Platform.OS === 'ios' ? 30 : 20, pointerEvents: 'box-none', }, tabBar: { flexDirection: 'row', backgroundColor: 'rgba(255, 255, 255, 0.8)', borderRadius: 35, height: 70, width: width - 40, justifyContent: 'space-around', alignItems: 'center', borderWidth: 1, borderColor: 'rgba(255, 255, 255, 0.5)', paddingHorizontal: 10, }, tabItem: { flex: 1, alignItems: 'center', justifyContent: 'center', height: '100%', }, iconContainer: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', shadowColor: theme.colors.primary, shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.3, shadowRadius: 8, elevation: 4, }, });