-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathFourTabs.tsx
More file actions
85 lines (80 loc) · 2.28 KB
/
FourTabs.tsx
File metadata and controls
85 lines (80 loc) · 2.28 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
import TabView, { SceneMap } from 'react-native-bottom-tabs';
import { useState } from 'react';
import { Article } from '../Screens/Article';
import { Albums } from '../Screens/Albums';
import { Contacts } from '../Screens/Contacts';
import { Chat } from '../Screens/Chat';
import { Platform, type ColorValue } from 'react-native';
interface Props {
disablePageAnimations?: boolean;
scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent';
backgroundColor?: ColorValue;
translucent?: boolean;
hideOneTab?: boolean;
rippleColor?: ColorValue;
activeIndicatorColor?: ColorValue;
}
const renderScene = SceneMap({
article: Article,
albums: Albums,
contacts: Contacts,
chat: Chat,
});
export default function FourTabs({
disablePageAnimations = false,
scrollEdgeAppearance = 'default',
backgroundColor,
translucent = true,
hideOneTab = false,
rippleColor,
activeIndicatorColor,
}: Props) {
const [index, setIndex] = useState(0);
const [routes] = useState([
{
key: 'article',
title: 'Article',
focusedIcon: require('../../assets/icons/article_dark.png'),
unfocusedIcon: require('../../assets/icons/chat_dark.png'),
badge: '!',
},
{
key: 'albums',
title: 'Albums',
focusedIcon: require('../../assets/icons/grid_dark.png'),
badge: '5',
hidden: hideOneTab,
},
{
key: 'chat',
focusedIcon: require('../../assets/icons/chat_dark.png'),
title: 'Chat',
},
{
key: 'contacts',
focusedIcon: require('../../assets/icons/person_dark.png'),
title: 'Contacts',
badge: ' ',
role: 'search',
searchable: true,
navigationBarToolbarStyle:
Platform.Version === '26.0' ? 'hidden' : 'visible',
},
]);
return (
<TabView
onSearchFocusChange={(isFocused) => console.log('isFocused', isFocused)}
sidebarAdaptable
onSearchTextChange={(text) => console.log(text)}
disablePageAnimations={disablePageAnimations}
scrollEdgeAppearance={scrollEdgeAppearance}
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
tabBarStyle={{ backgroundColor }}
translucent={translucent}
rippleColor={rippleColor}
activeIndicatorColor={activeIndicatorColor}
/>
);
}