index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Text, View, TouchableWithoutFeedback } from 'react-native';
  2. import { SvgProps } from 'react-native-svg';
  3. import { NAVIGATION_PAGES } from '../../types';
  4. import MapIcon from '../../../assets/icons/bottom-navigation/map.svg';
  5. import TravellersIcon from '../../../assets/icons/bottom-navigation/travellers.svg';
  6. import GlobeIcon from '../../../assets/icons/bottom-navigation/globe.svg';
  7. import ProfileIcon from '../../../assets/icons/bottom-navigation/profile.svg';
  8. import { Colors } from '../../theme';
  9. import { styles } from './style';
  10. const getTabIcon = (routeName: string) => {
  11. switch (routeName) {
  12. case NAVIGATION_PAGES.MAP_TAB:
  13. return MapIcon;
  14. case NAVIGATION_PAGES.TRAVELLERS_TAB:
  15. return TravellersIcon;
  16. case NAVIGATION_PAGES.TRAVELS_TAB:
  17. return GlobeIcon;
  18. case NAVIGATION_PAGES.PROFILE_TAB:
  19. return ProfileIcon;
  20. default:
  21. return null;
  22. }
  23. };
  24. const TabBarButton = ({
  25. label,
  26. onPress,
  27. focused,
  28. }: {
  29. label: string;
  30. onPress: () => void;
  31. focused: boolean;
  32. }) => {
  33. const IconComponent: React.FC<SvgProps> | null = getTabIcon(label);
  34. let currentColor = focused ? Colors.DARK_BLUE : Colors.LIGHT_GRAY;
  35. return (
  36. <TouchableWithoutFeedback onPress={onPress}>
  37. <View style={styles.buttonStyle}>
  38. {IconComponent && <IconComponent width={24} height={24} fill={currentColor} />}
  39. <Text style={[styles.labelStyle, { color: currentColor }]}>{label}</Text>
  40. </View>
  41. </TouchableWithoutFeedback>
  42. );
  43. };
  44. export default TabBarButton;