@react-navigation/drawer#DrawerContent JavaScript Examples

The following examples show how to use @react-navigation/drawer#DrawerContent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.native.jsx    From polaris with Apache License 2.0 6 votes vote down vote up
RouteNavigator = ({
  routes = presetRoutes,
  defaultPath = presetDefaultPath,
  LayoutComponent = Layout
}) => {
  const dimensions = useWindowDimensions()
  const { t } = useTranslation()

  const viewRoutes = routes.filter(isViewRoute)
  viewRoutes.sort(
    (a, b) =>
      getMenuIndexSortValue(a.menuIndex) - getMenuIndexSortValue(b.menuIndex)
  )
  const menuNames = viewRoutes.filter(isMenuRoute).map(route => route.path)

  return (
    <RoutesProvider routes={routes} defaultPath={defaultPath}>
      <Drawer.Navigator
        initialRouteName={defaultPath}
        drawerType={dimensions.width >= 768 ? 'permanent' : 'front'}
        drawerContent={withMenuFilter(DrawerContent, menuNames)}
      >
        {viewRoutes.map(route => (
          <Drawer.Screen
            name={route.path}
            component={withLayout(route.View, LayoutComponent)}
            options={({ route: { params } }) => ({
              title: replaceParams(t(route.name), params)
            })}
            key={route.path}
          />
        ))}
      </Drawer.Navigator>
    </RoutesProvider>
  )
}