Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import React from 'react';
  2. import {Text, View, StatusBar, StyleSheet, Button} from 'react-native';
  3. import {createDrawerNavigator} from 'react-navigation-drawer';
  4. import {createStackNavigator} from 'react-navigation-stack';
  5. import {createAppContainer} from 'react-navigation';
  6.  
  7. const Sidebar = ({navigation}) => (
  8. <View style={styles.container}>
  9. <Text style={styles.text}>Sidebar</Text>
  10. <Button title="Close Sidebar" onPress={() => navigation.closeDrawer()} />
  11. </View>
  12. );
  13.  
  14. const Home = ({navigation}) => {
  15. return (
  16. <View style={styles.container}>
  17. <Button title="Open Sidebar" onPress={() => navigation.openDrawer()} />
  18. </View>
  19. );
  20. };
  21.  
  22. const Routes = createStackNavigator({Home: {screen: Home}}, {mode: 'card', headerMode: 'none'});
  23.  
  24. const Drawer = createDrawerNavigator(
  25. {DefaultRoutes: Routes},
  26. {
  27. contentComponent: Sidebar,
  28. drawerType: 'slide',
  29. drawerWidth: 300,
  30. },
  31. );
  32.  
  33. const AppContainer = createAppContainer(Drawer);
  34.  
  35. const App = () => {
  36. return (
  37. <>
  38. <StatusBar backgroundColor="#121212" barStyle="light-content" />
  39. <AppContainer />
  40. </>
  41. );
  42. };
  43.  
  44. const styles = StyleSheet.create({
  45. container: {
  46. flex: 1,
  47. justifyContent: 'center',
  48. alignItems: 'center',
  49. backgroundColor: '#121212',
  50. },
  51. text: {
  52. fontSize: 18,
  53. color: '#eeeeee',
  54. marginBottom: 14,
  55. },
  56. });
  57.  
  58. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement