import React from 'react'; import _ from 'lodash'; import {SCAN} from '@constants/navigation/app-bottom-tab'; import { Container, Tab, Title, IconWrapper, Highlighter, } from '@styles/components/app-bottom-tab'; const AppBottomTab = ({state, descriptors, navigation}: any) => ( {state.routes.map((route: {name: string; key: string}, index: any) => { const {options} = descriptors[route.key]; const label = options.tabBarLabel !== undefined ? options.tabBarLabel : options.title !== undefined ? options.title : route.name; const isFocused = state.index === index; const onPress = () => { const event = navigation.emit({ type: 'tabPress', target: route.key, canPreventDefault: true, }); if (!isFocused && !event.defaultPrevented) { // The `merge: true` option makes sure that the params inside the tab screen are preserved navigation.navigate({name: route.name, merge: true}); } }; const onLongPress = () => { navigation.emit({ type: 'tabLongPress', target: route.key, }); }; const Icon = _.isFunction(options?.tabBarIcon) ? options?.tabBarIcon() : null; const isScan = route.name === SCAN.SCREEN; return ( {isFocused && } {Icon && ( )} {label} ); })} ); export default AppBottomTab;