MultipleDrawer.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @flow
  3. */
  4. import React from 'react';
  5. import { Platform, ScrollView, StyleSheet } from 'react-native';
  6. import { createDrawerNavigator } from 'react-navigation';
  7. import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
  8. import SampleText from './SampleText';
  9. import { Button } from './commonComponents/ButtonWithMargin';
  10. const MyNavScreen = ({ navigation, banner }) => (
  11. <ScrollView style={styles.container}>
  12. <SampleText>{banner}</SampleText>
  13. <Button onPress={() => navigation.openDrawer()} title="Open drawer" />
  14. <Button onPress={() => navigation.goBack(null)} title="Go back" />
  15. </ScrollView>
  16. );
  17. const InboxScreen = ({ navigation }) => (
  18. <MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
  19. );
  20. InboxScreen.navigationOptions = {
  21. drawerLabel: 'Inbox',
  22. drawerIcon: ({ tintColor }) => (
  23. <MaterialIcons
  24. name="move-to-inbox"
  25. size={24}
  26. style={{ color: tintColor }}
  27. />
  28. ),
  29. };
  30. const DraftsScreen = ({ navigation }) => (
  31. <MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
  32. );
  33. DraftsScreen.navigationOptions = {
  34. drawerLabel: 'Drafts',
  35. drawerIcon: ({ tintColor }) => (
  36. <MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
  37. ),
  38. };
  39. const DrawerExample = createDrawerNavigator(
  40. {
  41. Inbox: {
  42. path: '/',
  43. screen: InboxScreen,
  44. },
  45. Drafts: {
  46. path: '/sent',
  47. screen: DraftsScreen,
  48. },
  49. },
  50. {
  51. initialRouteName: 'Drafts',
  52. contentOptions: {
  53. activeTintColor: '#e91e63',
  54. },
  55. }
  56. );
  57. const MainDrawerExample = createDrawerNavigator({
  58. Drafts: {
  59. screen: DrawerExample,
  60. },
  61. });
  62. const styles = StyleSheet.create({
  63. container: {
  64. marginTop: Platform.OS === 'ios' ? 20 : 0,
  65. },
  66. });
  67. export default MainDrawerExample;