-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
85 lines (81 loc) · 2.35 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React from 'react';
import {
DrawerNavigator,
StackNavigator,
TabNavigator
} from 'react-navigation';
import Icon from 'react-native-vector-icons/Ionicons';
import Home from './src/tabs/Home';
import Settings from './src/tabs/Settings';
import Profile from './src/screens/Profile';
import Modal from './src/screens/Modal';
import Drawer from './src/components/Drawer';
// Stack navigation for Settings and Profile screens
const SettingsTab = StackNavigator({
Settings: {
screen: Settings,
navigationOptions: {
header: null, // Hide the header
headerBackTitle: 'Back', // Title back button Back when we navigate to Profile from Settings
},
},
Profile: {
screen: Profile,
navigationOptions: ({ navigation }) => ({
// Customize header's title with user name passed to navigate()
// You can pass any props you'd like. For instance: navigate('Profile', { user: 'Tom' }
title: `${navigation.state.params.user}'s Profile`,
}),
},
}, {
headerMode: 'screen',
});
// Tab navigation for Home and Settings screens
const TabNavigation = TabNavigator({
Home: {
screen: Home,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor, focused }) => <Icon
name={focused ? 'ios-home' : 'ios-home-outline'}
size={26}
style={{ color: tintColor }}
/>
},
},
Settings: {
screen: SettingsTab,
navigationOptions: {
tabBarLabel: 'Settings',
tabBarIcon: ({ tintColor, focused }) => <Icon
name={focused ? 'ios-settings' : 'ios-settings-outline'}
size={26}
style={{ color: tintColor }}
/>
},
},
});
// Wrap tab navigation into drawer navigation
const TabsWithDrawerNavigation = DrawerNavigator({
Tabs: {
screen: TabNavigation,
}
}, {
// Register custom drawer component
contentComponent: props => <Drawer {...props} />
});
// And lastly stack together drawer with tabs and modal navigation
// because we want to be able to call Modal screen from any other screen
export default StackNavigator({
TabsWithDrawer: {
screen: TabsWithDrawerNavigation,
},
Modal: {
screen: Modal
},
}, {
// In modal mode screen slides up from the bottom
mode: 'modal',
// No headers for modals. Otherwise we'd have two headers on the screen, one for stack, one for modal.
headerMode: 'none',
});