diff --git a/docs/buildingDrawerNavigation.md b/docs/buildingDrawerNavigation.md index aa78a13c7..75fd6fe20 100644 --- a/docs/buildingDrawerNavigation.md +++ b/docs/buildingDrawerNavigation.md @@ -9,16 +9,14 @@ Common pattern in navigation is to use drawer from left (sometimes right) side f Here is an example to show how easily and quickly we can use React Native's [DrawerNavigation](https://reactnavigation.org/docs/drawer-based-navigation/) in NB. -```SnackPlayer name=Drawer-Navigation dependencies=@react-navigation/stack@5.1.0,@react-navigation/drawer,@react-navigation/native@5.0.8,react-native-vector-icons,react-native-gesture-handler@1.10.2,react-native-linear-gradient,@react-native-community/masked-view@0.1.10,react-native-screens@3.0.0,react-native-reanimated@2.1.0 +```SnackPlayer name=Drawer-Navigation dependencies=@react-navigation/stack@6.0.2,@react-navigation/drawer@6.1.3,@react-navigation/native@6.0.2,react-native-vector-icons,react-native-gesture-handler@~1.10.2,react-native-linear-gradient,@react-native-community/masked-view@0.1.10,react-native-screens@~3.4.0,react-native-reanimated@~2.2.0 import * as React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createDrawerNavigator, DrawerContentScrollView, } from '@react-navigation/drawer'; -import { - MaterialCommunityIcons -} from '@expo/vector-icons'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; import { NativeBaseProvider, Button, @@ -31,110 +29,122 @@ import { Center, HStack, Divider, - Icon + Icon, } from 'native-base'; const Drawer = createDrawerNavigator(); function Component(props) { return ( - - props.navigation.toggleDrawer()} position="absolute" ml="2" zIndex="1"> - - -
- {props.route.name} -
-
+
+ {props.route.name} Screen + +
); } const getIcon = (screenName) => { switch (screenName) { case 'Inbox': - return "email" + return 'email'; case 'Outbox': - return 'send' + return 'send'; case 'Favorites': - return 'heart' + return 'heart'; case 'Archive': - return 'archive' + return 'archive'; case 'Trash': - return 'trash-can' + return 'trash-can'; case 'Spam': - return 'alert-circle' + return 'alert-circle'; default: - return undefined + return undefined; } -} +}; function CustomDrawerContent(props) { return ( - - - Mail - john_doe@gmail.com - - } space="4"> - - {props.state.routeNames.map((name, index) => ( - { - props.navigation.navigate(name); - }} - > + + + + Mail + + + john_doe@gmail.com + + + } space="4"> + + {props.state.routeNames.map((name, index) => ( + { + props.navigation.navigate(name); + }}> } /> - - {name} + color={ + index === props.state.index ? 'primary.500' : 'gray.500' + } + size="5" + as={} + /> + + {name} ))} - Labels + + Labels + - + } /> - + color="gray.500" + size="5" + as={} + /> + Family - + } /> - + color="gray.500" + size="5" + as={} + /> + Friends - + } /> - + color="gray.500" + size="5" + as={} + /> + Work @@ -148,17 +158,16 @@ function CustomDrawerContent(props) { } function MyDrawer() { return ( - - } - > - - - - - - - + + }> + + + + + + + ); }