/
BottomNavigator.js
96 lines (90 loc) · 2.34 KB
/
BottomNavigator.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
import ContactNavigator from './ContactNavigator'
import ChatNavigator from './ChatNavigator'
import SettingsNavigator from './SettingsNavigator'
import { createBottomTabNavigator } from 'react-navigation'
import { colors } from '../../constants'
import { Platform } from 'react-native'
import I18n from 'i18next'
import React from 'react'
import { Icon } from '../Library'
const TabBarIcon = (tintColor, routeName, badgeValue) => {
let iconName = {
contacts: 'users',
chats: 'message-circle',
settings: 'settings',
}[routeName]
return (
<Icon.Badge
name={iconName}
size={24}
color={tintColor}
badge={badgeValue}
/>
)
}
const handleBothNavigationsOptions = ({ navigation, screenProps }) => {
let badge = null
if (
navigation.state.routeName === 'settings' &&
screenProps.availableUpdate
) {
badge = '!'
}
return {
tabBarIcon: ({ tintColor }) =>
TabBarIcon(tintColor, navigation.state.routeName, badge),
}
}
export default createBottomTabNavigator(
{
contacts: {
screen: ContactNavigator,
navigationOptions: () => ({
title: I18n.t('contacts.title'),
}),
},
chats: {
screen: ChatNavigator,
navigationOptions: () => ({
title: I18n.t('chats.title'),
}),
},
settings: {
screen: SettingsNavigator,
navigationOptions: () => ({
title: I18n.t('settings.title'),
}),
},
},
{
initialRouteName: 'chats',
swipeEnabled: false,
// animationEnabled: true,
navigationOptions: handleBothNavigationsOptions,
defaultNavigationOptions: handleBothNavigationsOptions,
tabBarOptions: {
showIcon: true,
showLabel: true,
upperCaseLabel: false,
activeTintColor: colors.fakeBlack,
inactiveTintColor: colors.lightGrey,
indicatorStyle: {
backgroundColor: colors.fakeBlack,
},
style: [
{
backgroundColor: colors.white,
borderTopWidth: 0.5,
borderTopColor: colors.borderGrey,
shadowColor: colors.shadowGrey,
shadowOffset: { height: -5, width: 0 },
shadowOpacity: 0.2,
shadowRadius: 5,
...(Platform.OS === 'android'
? { height: 68, paddingTop: 3 }
: { height: 64, paddingTop: 5, paddingBottom: 6 }),
},
],
},
}
)