-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_layout.tsx
More file actions
73 lines (69 loc) · 3.03 KB
/
Copy path_layout.tsx
File metadata and controls
73 lines (69 loc) · 3.03 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
import FontAwesome from '@expo/vector-icons/FontAwesome';
import { Tabs, usePathname, useRouter } from 'expo-router';
// You can explore the built-in icon families and icons on the web at https://icons.expo.fyi/
function TabBarIcon(props: { name: React.ComponentProps<typeof FontAwesome>['name']; color: string }) {
return <FontAwesome size={28} style={{ marginBottom: -3 }} {...props} />;
}
export default function TabLayout() {
const pathname = usePathname();
const router = useRouter();
return (
<Tabs
screenOptions={{
//tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
// Force header to be completely hidden for all tabs
headerShown: false,
}}
>
<Tabs.Screen
name="index"
options={{
title: 'Home',
// We'll handle headers manually in each screen component
tabBarIcon: ({ color }: { color: string }) => <TabBarIcon name="code" color={color} />,
}}
/>
<Tabs.Screen
name="jobs"
options={{
title: 'Jobs',
tabBarIcon: ({ color }: { color: string }) => <TabBarIcon name="briefcase" color={color} />,
}}
/>
<Tabs.Screen
name="settings"
options={{
title: 'Settings',
tabBarIcon: ({ color }: { color: string }) => <TabBarIcon name="cog" color={color} />,
}}
/>
<Tabs.Screen
name="profile"
options={{
title: 'Profile',
tabBarIcon: ({ color }: { color: string }) => <TabBarIcon name="user" color={color} />,
}}
/>
<Tabs.Screen
name="permissions"
options={{
title: 'Permissions',
tabBarIcon: ({ color }: { color: string }) => <TabBarIcon name="shield" color={color} />,
}}
listeners={{
tabPress: (e: { preventDefault: () => void }) => {
// If already on a permissions sub-page (not the index), navigate to permissions index
const isOnPermissionsSubPage = pathname.startsWith('/permissions/') && pathname !== '/permissions';
const isOnPermissionsIndex = pathname === '/permissions' || pathname === '/(tabs)/permissions';
if (isOnPermissionsSubPage || isOnPermissionsIndex) {
// Prevent default tab behavior
e.preventDefault();
// Navigate to permissions index, replacing the current route to reset the stack
router.replace('/(tabs)/permissions');
}
},
}}
/>
</Tabs>
);
}