import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; import React, {Fragment, useEffect, useState} from 'react'; import {useSelector} from 'react-redux'; import {NavigationIcon} from '../../components'; import {NO_NOTIFICATIONS} from '../../store/initialStates'; import {RootState} from '../../store/rootReducer'; import {setNotificationsReadDate} from '../../services'; import {ScreenType} from '../../types'; import {haveUnreadNotifications, isIPhoneX} from '../../utils'; import MainStackScreen from '../main/MainStackScreen'; import {NotificationPill} from '../../components/notifications'; const Tabs = createBottomTabNavigator(); const NavigationBar: React.FC = () => { const {isOnboardedUser, newNotificationReceived} = useSelector( (state: RootState) => state.user, ); const {notifications: {notifications} = NO_NOTIFICATIONS} = useSelector( (state: RootState) => state, ); // Triggered if user clicks on Notifications page to close the pill const [showIcon, setShowIcon] = useState(true); const [unreadNotificationsPresent, setUnreadNotificationsPresent] = useState(false); // Prior to pill inclusion, determines if notification bell // should have purple dot useEffect(() => { const determine = async () => { setUnreadNotificationsPresent( await haveUnreadNotifications(notifications), ); }; determine(); }, [notifications]); return ( <> ({ tabBarIcon: ({focused}) => { switch (route.name) { case 'Home': return ; case 'Chat': return ; case 'Upload': return ( ); case 'Notifications': return ( ); case 'ProfileTab': return ; case 'SuggestedPeople': return ( ); default: return ; } }, })} initialRouteName={isOnboardedUser ? 'Profile' : 'SuggestedPeople'} tabBarOptions={{ showLabel: false, style: { backgroundColor: 'transparent', position: 'absolute', borderTopWidth: 0, height: isIPhoneX() ? 85 : 55, }, }}> { // Closes the pill once this screen has been opened setShowIcon(false); // Updates backend's date of reading notifications setNotificationsReadDate(); }, }} /> ); }; export default NavigationBar;