forked from callstack/react-native-bottom-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBottomAccessoryView.tsx
More file actions
71 lines (65 loc) · 1.84 KB
/
BottomAccessoryView.tsx
File metadata and controls
71 lines (65 loc) · 1.84 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
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 { Text, View, type TextStyle, type ViewStyle } from 'react-native';
const bottomAccessoryViewStyle: ViewStyle = {
width: '100%',
height: '100%',
justifyContent: 'center',
alignItems: 'center',
};
const textStyle: TextStyle = { textAlign: 'center' };
const renderScene = SceneMap({
article: Article,
albums: Albums,
contacts: Contacts,
});
export default function BottomAccessoryView() {
const [index, setIndex] = useState(0);
const [routes] = useState([
{
key: 'article',
title: 'Article',
focusedIcon: require('../../assets/icons/article_dark.png'),
badge: '!',
},
{
key: 'albums',
title: 'Albums',
focusedIcon: require('../../assets/icons/grid_dark.png'),
badge: '5',
},
{
key: 'contacts',
focusedIcon: require('../../assets/icons/person_dark.png'),
title: 'Contacts',
role: 'search',
},
]);
const [bottomAccessoryDimensions, setBottomAccessoryDimensions] = useState({
width: 0,
height: 0,
});
return (
<TabView
sidebarAdaptable
minimizeBehavior="onScrollDown"
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
renderBottomAccessoryView={({ placement }) => (
<View
style={bottomAccessoryViewStyle}
onLayout={(e) => setBottomAccessoryDimensions(e.nativeEvent.layout)}
>
<Text style={textStyle}>
Placement: {placement}. Dimensions:{' '}
{bottomAccessoryDimensions.width}x{bottomAccessoryDimensions.height}
</Text>
</View>
)}
/>
);
}