-
Notifications
You must be signed in to change notification settings - Fork 375
/
Main.js
145 lines (135 loc) · 3.56 KB
/
Main.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { Animated, Easing, Platform } from 'react-native'
import { createStackNavigator, createBottomTabNavigator } from 'react-navigation'
import React from 'react'
import { EventListFilterModal } from './Settings/Devtools/EventList'
import { Icon } from '../Library'
import { colors } from '../../constants'
import Chats from './Chats'
import Contacts from './Contacts'
import Settings from './Settings'
import ContactCardModal from './Contacts/ContactCardModal'
import { ViewExportComponent } from '../../helpers/saveViewToCamera'
import I18n from 'i18next'
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}
/>
)
}
export const tabs = createBottomTabNavigator(
{
contacts: {
screen: Contacts,
navigationOptions: () => ({
title: I18n.t('contacts.title'),
}),
},
chats: {
screen: Chats,
navigationOptions: () => ({
title: I18n.t('chats.title'),
}),
},
settings: {
screen: Settings,
navigationOptions: () => ({
title: I18n.t('settings.title'),
}),
},
},
{
initialRouteName: 'chats',
swipeEnabled: false,
animationEnabled: true,
navigationOptions: ({ navigation, screenProps }) => {
let badge = null
if (
navigation.state.routeName === 'settings' &&
screenProps.availableUpdate
) {
badge = '!'
}
return {
tabBarIcon: ({ tintColor }) =>
TabBarIcon(tintColor, navigation.state.routeName, badge),
}
},
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 }),
},
],
},
}
)
// Navigator handling modals
export default createStackNavigator(
{
tabs: tabs,
'modal/devtools/event/list/filters': {
screen: EventListFilterModal,
},
'modal/contacts/card': {
screen: ContactCardModal,
},
'virtual/view-export': {
screen: ViewExportComponent,
},
},
{
mode: 'card',
headerMode: 'none',
transparentCard: true,
navigationOptions: {
gesturesEnabled: false,
},
transitionConfig: () => ({
transitionSpec: {
duration: 300,
easing: Easing.out(Easing.poly(4)),
timing: Animated.timing,
},
screenInterpolator: sceneProps => {
const { layout, position, scene } = sceneProps
const { index } = scene
const height = layout.initHeight
const translateY = position.interpolate({
inputRange: [index - 1, index, index + 1],
outputRange: [height, 0, 0],
})
const opacity = position.interpolate({
inputRange: [index - 1, index - 0.99, index],
outputRange: [0, 1, 1],
})
return { opacity, transform: [{ translateY }] }
},
}),
}
)