Created
April 10, 2018 14:13
-
-
Save Ayyagaries/590cd3eaa82f7f1371c6dca70a0f7e55 to your computer and use it in GitHub Desktop.
Using react navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Button, Icon } from 'native-base'; | |
import { StackNavigator, DrawerNavigator } from 'react-navigation'; | |
import { Animated, Easing } from 'react-native'; | |
// import NewPassword from '../screens/NewPassword'; | |
import Login from '../screens/Login'; | |
import Home from '../screens/HomeScreen'; | |
import DrawerContainer from '../components/Drawer/DrawerComponent'; | |
import ForgotPassword from '../screens/ForgotPassword'; | |
import ResetPassword from '../screens/ResetPassword'; | |
import { mylogo } from '../components/Logo'; | |
import RepSearch from '../screens/REPSearch'; | |
import Info from '../screens/Info'; | |
import PickFacility from '../screens/PickFacility'; | |
const noTransitionConfig = () => ({ | |
transitionSpec: { | |
duration: 0, | |
timing: Animated.timing, | |
easing: Easing.step0, | |
}, | |
}); | |
const loginStack = StackNavigator( | |
{ | |
loginScreen: { screen: Login }, | |
forgotPassword: { screen: ForgotPassword }, | |
info: { screen: Info }, | |
resetPassword: { screen: ResetPassword }, | |
}, | |
{ | |
headerMode: 'none', | |
}, | |
); | |
const DrawerStack = DrawerNavigator( | |
{ | |
PickFacility: { screen: PickFacility }, | |
Home: { screen: Home }, | |
RepSearch: { screen: RepSearch }, | |
}, | |
{ | |
gesturesEnabled: false, | |
contentComponent: DrawerContainer, | |
}, | |
); | |
const DrawerNavigation = StackNavigator( | |
{ | |
DrawerStack: { screen: DrawerStack }, | |
}, | |
{ | |
headerMode: 'float', | |
navigationOptions: ({ navigation }) => ({ | |
gesturesEnabled: false, | |
headerStyle: { backgroundColor: '#769654' }, | |
headerTintColor: 'white', | |
headerLeft: ( | |
<Button | |
transparent | |
onPress={() => { | |
if (navigation.state.index === 0) { | |
navigation.navigate('DrawerOpen'); | |
} else { | |
navigation.navigate('DrawerClose'); | |
} | |
}} | |
> | |
<Icon name="ios-menu" color="#FFF" /> | |
</Button> | |
), | |
headerRight: <mylogo />, | |
}), | |
}, | |
); | |
const PrimaryNav = StackNavigator( | |
{ | |
loginStack: { screen: loginStack }, | |
drawerStack: { screen: DrawerNavigation }, | |
}, | |
{ | |
headerMode: 'none', | |
initialRouteName: 'loginStack', | |
transitionConfig: noTransitionConfig, | |
}, | |
); | |
export default PrimaryNav; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment