import * as React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Image, DeviceEventEmitter } from 'react-native'; import ImagePicker from 'react-native-image-crop-picker'; import { size, px2dp, colors, onePx, isIos } from './../../utils'; const tabIcon1 = require('./../../assets/icons/tab-icon-1.png'); const tabIcon1Active = require('./../../assets/icons/tab-icon-1-active.png'); const tabIcon2 = require('./../../assets/icons/tab-icon-2.png'); const tabIcon2Active = require('./../../assets/icons/tab-icon-2-active.png'); const tabIcon3 = require('./../../assets/icons/tab-icon-3.png'); const tabIcon3Active = require('./../../assets/icons/tab-icon-3-active.png'); const tabIcon4 = require('./../../assets/icons/tab-icon-4.png'); const tabIcon4Active = require('./../../assets/icons/tab-icon-4-active.png'); // import { BlurView } from "@react-native-community/blur"; // import { isIphoneX, getBottomSpace } from 'react-native-iphone-x-helper'; import TabItem from './TabItem'; import { navigate } from '../../NavigationService'; // import EVENT_KEY from '../../utils/EVENT_KEY'; import { getBottomSpace } from 'react-native-iphone-x-helper'; const BottomNavigationBar = ({ state, descriptors, navigation }) => { React.useEffect(() => { // alert() }, []); const showCenterActionButtons = () => { // DeviceEventEmitter.emit(EVENT_KEY.onPressCenterTab, {}); navigate('FastRecordSelectPage') }; return ( {state.routes.map((route: any, 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; let icon; switch (index) { case 0: if (isFocused) { icon = tabIcon1Active; } else { icon = tabIcon1; } break; case 1: if (isFocused) { icon = tabIcon2Active; } else { icon = tabIcon2; } break; case 2: if (isFocused) { icon = tabIcon3Active; } else { icon = tabIcon3; } break; case 3: if (isFocused) { icon = tabIcon4Active; } else { icon = tabIcon4; } break; default: return false } const onPress = () => { const event = navigation.emit({ type: 'tabPress', target: route.key, }); if (!isFocused && !event.defaultPrevented) { navigation.navigate(route.name); } }; const onLongPress = () => { navigation.emit({ type: 'tabLongPress', target: route.key, }); }; return ( {/* } */} ) })} ) }; const styles = StyleSheet.create({ container: { position: 'absolute', bottom: 0, left: 0, right: 0, zIndex: 9999, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', width: '100%', height: size.tab_height, borderTopColor: '#eee', borderTopWidth: onePx, // backgroundColor: 'red', // opacity: 0.6 }, cameraTab: { width: px2dp(40), height: px2dp(40), borderRadius: px2dp(20), justifyContent: 'center', alignItems: 'center', backgroundColor: colors.themeColor, marginBottom: px2dp(2) }, centerTabLable: { fontSize: 12, color: '#909399', fontWeight: 'bold', marginTop: px2dp(2) }, content: { position: 'relative', width: '100%', height: '100%', borderTopColor: '#eee', borderTopWidth: onePx, justifyContent: 'flex-start', alignItems: 'center' }, backgroundView: { position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, width: '100%', height: '100%', zIndex: 998 }, backgroundViewAndroid: { width: '100%', height: '100%', backgroundColor: '#fff' }, contentView: { position: 'absolute', top: 0, left: 0, width: '100%', height: size.tab_height, zIndex: 999, flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }, tabLarge: { position: 'relative', width: px2dp(375 / 5 * 2), flexDirection: 'row', height: '100%', justifyContent: 'center', alignItems: 'center', // backgroundColor: 'red' }, tab: { position: 'relative', width: px2dp(375 / 5), height: '100%', justifyContent: 'center', alignItems: 'center', }, centerIcon: { width: px2dp(24), height: px2dp(24), tintColor: '#fff' }, tabContent: { position: 'relative', justifyContent: 'center', alignItems: 'center' }, tabIcon: { width: px2dp(22), height: px2dp(22), }, label: { fontSize: 12, color: '#333', marginTop: px2dp(2) }, pointShow: { position: 'absolute', top: px2dp(-4), right: px2dp(-5), minWidth: px2dp(18), paddingHorizontal: px2dp(4), height: px2dp(18), borderRadius: px2dp(9), backgroundColor: colors.red, justifyContent: 'center', alignItems: 'center', opacity: 0.9, } }) export default BottomNavigationBar;