forked from callstack/react-native-bottom-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeBottomTabs.tsx
More file actions
97 lines (94 loc) · 2.69 KB
/
NativeBottomTabs.tsx
File metadata and controls
97 lines (94 loc) · 2.69 KB
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
import { Article } from '../Screens/Article';
import { Albums } from '../Screens/Albums';
import { Contacts } from '../Screens/Contacts';
import { Chat } from '../Screens/Chat';
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
import { Platform } from 'react-native';
import { useState } from 'react';
const Tab = createNativeBottomTabNavigator();
function NativeBottomTabs() {
const [label, setLabel] = useState('Article');
return (
<Tab.Navigator
initialRouteName="Chat"
labeled={true}
hapticFeedbackEnabled={false}
layoutDirection="ltr"
tabBarInactiveTintColor="#C57B57"
tabBarActiveTintColor="#F7DBA7"
tabBarStyle={{
backgroundColor: '#1E2D2F',
}}
rippleColor="#F7DBA7"
tabLabelStyle={{
fontFamily: 'Avenir',
fontSize: 15,
}}
activeIndicatorColor="#041F1E"
screenListeners={{
tabLongPress: (data) => {
console.log(
`${Platform.OS}: Long press detected on tab with key ${data.target} at the navigator level.`
);
},
}}
>
<Tab.Screen
name="Article"
component={Article}
listeners={{
tabLongPress: (data) => {
console.log(
`${Platform.OS}: Long press detected on tab with key ${data.target} at the screen level.`
);
setLabel('New Article');
},
}}
options={{
tabBarButtonTestID: 'articleTestID',
tabBarBadge: '10',
tabBarLabel: label,
tabBarIcon: ({ focused }) =>
focused
? require('../../assets/icons/person_dark.png')
: require('../../assets/icons/article_dark.png'),
}}
/>
<Tab.Screen
name="Albums"
component={Albums}
options={{
tabBarIcon: () => require('../../assets/icons/grid_dark.png'),
}}
/>
<Tab.Screen
name="Contacts"
component={Contacts}
listeners={{
tabPress: () => {
console.log('Contacts tab press prevented');
},
}}
options={{
tabBarIcon: () => require('../../assets/icons/person_dark.png'),
tabBarActiveTintColor: 'yellow',
preventsDefault: true,
}}
/>
<Tab.Screen
name="Chat"
component={Chat}
listeners={{
tabPress: () => {
console.log('Chat tab pressed');
},
}}
options={{
tabBarIcon: () => require('../../assets/icons/chat_dark.png'),
tabBarActiveTintColor: 'white',
}}
/>
</Tab.Navigator>
);
}
export default NativeBottomTabs;