123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- * @flow
- */
- import React from 'react';
- import { Platform, ScrollView, StatusBar } from 'react-native';
- import {
- createStackNavigator,
- createDrawerNavigator,
- SafeAreaView,
- } from 'react-navigation';
- import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
- import SampleText from './SampleText';
- import { Button } from './commonComponents/ButtonWithMargin';
- const MyNavScreen = ({ navigation, banner }) => (
- <ScrollView>
- <SafeAreaView forceInset={{ top: 'always' }}>
- <SampleText>{banner}</SampleText>
- <Button onPress={() => navigation.openDrawer()} title="Open drawer" />
- <Button
- onPress={() => navigation.navigate('Email')}
- title="Open other screen"
- />
- <Button onPress={() => navigation.goBack(null)} title="Go back" />
- </SafeAreaView>
- <StatusBar barStyle="default" />
- </ScrollView>
- );
- const InboxScreen = ({ navigation }) => (
- <MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
- );
- InboxScreen.navigationOptions = {
- headerTitle: 'Inbox',
- };
- const EmailScreen = ({ navigation }) => (
- <MyNavScreen banner={'Email Screen'} navigation={navigation} />
- );
- const DraftsScreen = ({ navigation }) => (
- <MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
- );
- DraftsScreen.navigationOptions = {
- headerTitle: 'Drafts',
- };
- const InboxStack = createStackNavigator({
- Inbox: { screen: InboxScreen },
- Email: { screen: EmailScreen },
- });
- InboxStack.navigationOptions = {
- drawerLabel: 'Inbox',
- drawerIcon: ({ tintColor }) => (
- <MaterialIcons
- name="move-to-inbox"
- size={24}
- style={{ color: tintColor }}
- />
- ),
- };
- const DraftsStack = createStackNavigator({
- Drafts: { screen: DraftsScreen },
- Email: { screen: EmailScreen },
- });
- DraftsStack.navigationOptions = {
- drawerLabel: 'Drafts',
- drawerIcon: ({ tintColor }) => (
- <MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
- ),
- };
- const DrawerExample = createDrawerNavigator(
- {
- Inbox: {
- path: '/',
- screen: InboxStack,
- },
- Drafts: {
- path: '/sent',
- screen: DraftsStack,
- },
- },
- {
- initialRouteName: 'Drafts',
- contentOptions: {
- activeTintColor: '#e91e63',
- },
- }
- );
- export default DrawerExample;
|