-
Notifications
You must be signed in to change notification settings - Fork 7
/
TabNavigationLayout.js
108 lines (94 loc) · 2.78 KB
/
TabNavigationLayout.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* @providesModule TabNavigationLayout
* @flow
*/
import React from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
import {
StackNavigation,
TabNavigation,
TabNavigationItem,
} from '@exponent/ex-navigation';
import { Ionicons } from '@exponent/vector-icons';
import { Font } from 'exponent';
import Colors from 'Colors';
import Router from 'Router';
const defaultRouteConfig = {
navigationBar: {
tintColor: Colors.navigationBarTintColor,
backgroundColor: Colors.navigationBarBackgroundColor,
titleStyle: Font.style('open-sans'),
},
};
type TabRenderFunction = (isSelected: bool) => ReactElement<any>;
export default class TabNavigationLayout extends React.Component {
render() {
return (
<TabNavigation
tabBarColor={Colors.tabBar}
tabBarHeight={56}
initialTab="about">
<TabNavigationItem
id="explore"
renderIcon={isSelected => this._renderIcon('Explore', 'ios-compass-outline', isSelected)}>
<StackNavigation
defaultRouteConfig={defaultRouteConfig}
initialRoute={Router.getRoute('explore')}
/>
</TabNavigationItem>
<TabNavigationItem
id="myApps"
renderIcon={isSelected => this._renderIcon('My Apps', 'ios-person-outline', isSelected)}>
<StackNavigation
defaultRouteConfig={defaultRouteConfig}
initialRoute={Router.getRoute('myApps')}
/>
</TabNavigationItem>
<TabNavigationItem
id="history"
renderIcon={isSelected => this._renderIcon('History', 'ios-clock-outline', isSelected)}>
<StackNavigation
defaultRouteConfig={defaultRouteConfig}
initialRoute={Router.getRoute('history')}
/>
</TabNavigationItem>
<TabNavigationItem
id="about"
renderIcon={isSelected => this._renderIcon('About', 'ios-help-circle-outline', isSelected)}>
<StackNavigation
defaultRouteConfig={defaultRouteConfig}
initialRoute={Router.getRoute('about')}
/>
</TabNavigationItem>
</TabNavigation>
);
}
_renderIcon(title: string, iconName: string, isSelected: bool): ReactElement<any> {
let color = isSelected ? Colors.tabIconSelected : Colors.tabIconDefault;
return (
<View style={styles.tabItemContainer}>
<Ionicons name={iconName} size={32} color={color} />
<Text style={[styles.tabTitleText, {color}]} numberOfLines={1}>
{title}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
tabItemContainer: {
alignItems: 'center',
justifyContent: 'center',
},
tabTitleText: {
fontSize: 11,
},
});