Created
June 8, 2018 22:23
-
-
Save nazrdogan/215524eb5e6df4a22e0a43df28dc94d9 to your computer and use it in GitHub Desktop.
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 { StyleSheet, Text, View } from 'react-native'; | |
import { createBottomTabNavigator,createDrawerNavigator } from 'react-navigation'; | |
import { NavigationActions } from 'react-navigation'; | |
class HomeScreen extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> | |
<Text>Home!</Text> | |
</View> | |
); | |
} | |
} | |
class SettingsScreen extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> | |
<Text>Settings!</Text> | |
</View> | |
); | |
} | |
} | |
const Appp = createBottomTabNavigator( | |
{ | |
Home: HomeScreen, | |
Settings: SettingsScreen, | |
Drawer: SettingsScreen, | |
}, | |
{ | |
navigationOptions: ({ navigation }) => ({ | |
tabBarOnPress: (nav, dh) => { | |
let navi = nav.navigation.state.routeName; | |
if (navi === 'Drawer') { | |
navigation.toggleDrawer(); | |
} else { | |
const navigateAction = NavigationActions.navigate({ | |
routeName: navi, | |
}); | |
navigation.dispatch(navigateAction); | |
} | |
}, | |
}), | |
tabBarOptions: { | |
activeTintColor: 'tomato', | |
inactiveTintColor: 'gray', | |
}, | |
} | |
); | |
const MyApp = createDrawerNavigator({ | |
Home: { | |
screen: Appp, | |
}, | |
Notifications: { | |
screen: Appp, | |
}, | |
}); | |
export default class App extends React.Component { | |
render() { | |
return <MyApp />; | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment