forked from callstack/react-native-bottom-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeBottomTabsTabBarHidden.tsx
More file actions
93 lines (87 loc) · 2.23 KB
/
Copy pathNativeBottomTabsTabBarHidden.tsx
File metadata and controls
93 lines (87 loc) · 2.23 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
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
import { useState } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
const Tab = createNativeBottomTabNavigator();
type TabBarHiddenScreenProps = {
title: string;
tabBarHidden: boolean;
onToggleTabBarHidden: () => void;
};
function TabBarHiddenScreen({
title,
tabBarHidden,
onToggleTabBarHidden,
}: TabBarHiddenScreenProps) {
return (
<View style={styles.screen}>
<Text style={styles.title}>{title}</Text>
<Button
title={`${tabBarHidden ? 'Show' : 'Hide'} Tab Bar`}
onPress={onToggleTabBarHidden}
/>
</View>
);
}
export default function NativeBottomTabsTabBarHidden() {
const [tabBarHidden, setTabBarHidden] = useState(false);
const toggleTabBarHidden = () => setTabBarHidden((value) => !value);
return (
<Tab.Navigator sidebarAdaptable tabBarHidden={tabBarHidden}>
<Tab.Screen
name="Article"
options={{
tabBarIcon: () => require('../../assets/icons/article_dark.png'),
}}
>
{() => (
<TabBarHiddenScreen
title="Article"
tabBarHidden={tabBarHidden}
onToggleTabBarHidden={toggleTabBarHidden}
/>
)}
</Tab.Screen>
<Tab.Screen
name="Albums"
options={{
tabBarIcon: () => require('../../assets/icons/grid_dark.png'),
}}
>
{() => (
<TabBarHiddenScreen
title="Albums"
tabBarHidden={tabBarHidden}
onToggleTabBarHidden={toggleTabBarHidden}
/>
)}
</Tab.Screen>
<Tab.Screen
name="Contacts"
options={{
tabBarIcon: () => require('../../assets/icons/person_dark.png'),
}}
>
{() => (
<TabBarHiddenScreen
title="Contacts"
tabBarHidden={tabBarHidden}
onToggleTabBarHidden={toggleTabBarHidden}
/>
)}
</Tab.Screen>
</Tab.Navigator>
);
}
const styles = StyleSheet.create({
screen: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 16,
padding: 24,
},
title: {
fontSize: 24,
fontWeight: '600',
},
});