about summary refs log tree commit diff
path: root/src/lib/hooks/useNavigationTabState.web.ts
blob: 03dcbbb038cc2fc4d28449e582a5a6713583531c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import {useNavigationState} from '@react-navigation/native'

import {getCurrentRoute} from '#/lib/routes/helpers'

export function useNavigationTabState() {
  return useNavigationState(state => {
    let currentRoute = state ? getCurrentRoute(state).name : 'Home'
    return {
      isAtHome: currentRoute === 'Home',
      isAtSearch: currentRoute === 'Search',
      isAtNotifications: currentRoute === 'Notifications',
      isAtMyProfile: currentRoute === 'MyProfile',
      isAtMessages: currentRoute === 'Messages',
    }
  })
}