Skip to content

Instantly share code, notes, and snippets.

@streetsmartdev
Created September 3, 2017 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save streetsmartdev/c61ce9281a55c267334009750c74cae0 to your computer and use it in GitHub Desktop.
Save streetsmartdev/c61ce9281a55c267334009750c74cae0 to your computer and use it in GitHub Desktop.
RN-RNav- 7 - Implementing DrawerNavigator for Android
import React from "react";
import {Text, TouchableOpacity} from "react-native";
import {DrawerNavigator} from "react-navigation";
import HomeScreen from "./Home";
import AboutScreen from "./About";
import {Ionicons} from '@expo/vector-icons';
const Internal = DrawerNavigator(
{
Home: {screen: HomeScreen},
About: {screen: AboutScreen}
},
{
initialRouteName: "Home"
}
);
Internal.navigationOptions = ({navigation}) => ({
headerLeft: (
<TouchableOpacity
style={{paddingHorizontal: 20}}
onPress={() => {
//https://reactnavigation.org/docs/navigators/drawer
//Index is 0 when drawer closed -> https://stackoverflow.com/a/45122848
if (navigation.state.index === 0) {
navigation.navigate("DrawerOpen");
} else {
navigation.navigate("DrawerClose");
}
}}
>
<Ionicons name="md-menu" size={32}/>
</TouchableOpacity>
)
});
export default Internal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment