Files
2026-08-31 16:50:53 +02:00

110 lines
2.8 KiB
TypeScript

import { Redirect, Tabs } from 'expo-router';
import { Home, Clock, ShoppingBag, CircleCheckBig, CalendarRange } from 'lucide-react-native';
import { useContext } from 'react';
import { AuthContext } from '@/utils/authContext';
import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function ProtectedLayout() {
const authState = useContext(AuthContext);
const insets = useSafeAreaInsets();
if (!authState.isReady) {
return null;
}
if (!authState.isAuthenticated) {
return <Redirect href="/login" />;
}
return (
<Tabs
screenOptions={{
headerShown: false,
tabBarStyle: {
backgroundColor: '#ffffff',
borderTopWidth: 1,
borderTopColor: '#f1f5f9',
height: 70 + insets.bottom,
paddingBottom: insets.bottom,
paddingTop: 10,
paddingHorizontal: 10,
},
tabBarActiveTintColor: '#1071C2',
tabBarInactiveTintColor: '#94a3b8',
tabBarLabelStyle: {
fontSize: 12,
fontWeight: '600',
marginTop: 4
}
}}
backBehavior='history'
>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color, size }) => <Home pointerEvents="none" color={color} size={28} />,
}}
/>
<Tabs.Screen
name="activity"
options={{
title: 'Attività',
tabBarIcon: ({ color, size }) => <ShoppingBag pointerEvents="none" color={color} size={28} />,
}}
/>
<Tabs.Screen
name="attendance/index"
options={{
title: 'Presenze',
tabBarIcon: ({ color, size }) => <Clock pointerEvents="none" color={color} size={28} />,
}}
/>
<Tabs.Screen
name="quality"
options={{
title: 'Qualità',
tabBarIcon: ({ color, size }) => <CircleCheckBig pointerEvents="none" color={color} size={28} />,
}}
/>
<Tabs.Screen
name="permits/index"
options={{
title: 'Ferie',
tabBarIcon: ({ color, size }) => <CalendarRange pointerEvents="none" color={color} size={28} />,
}}
/>
<Tabs.Screen
name="invoice"
options={{
title: 'Fatture',
href: null,
}}
/>
<Tabs.Screen
name="profile"
options={{
href: null,
title: 'Profilo',
tabBarStyle: { display: 'none' },
}}
/>
<Tabs.Screen
name="dashboard/index"
options={{
href: null,
title: 'Dashboard',
}}
/>
<Tabs.Screen
name="construction-site"
options={{
href: null,
headerShown: false,
tabBarStyle: { display: 'none' },
}}
/>
</Tabs>
);
}