import { Tabs, router } from "expo-router"; import { Ionicons } from "@expo/vector-icons"; import { Alert, Platform } from "react-native"; import { AuthColors } from "@/features/auth/constants/colors"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useAuthStore } from "@/store/auth.store"; export default function TabsLayout() { const insets = useSafeAreaInsets(); const isWeb = Platform.OS === "web"; const bottomPadding = insets.bottom > 0 ? insets.bottom : (isWeb ? 8 : 8); const tabBarHeight = (isWeb ? 66 : 60) + (insets.bottom > 0 ? insets.bottom : 0); const { accessToken, logout } = useAuthStore(); const isAuthenticated = !!accessToken; const handleAuthAction = () => { if (isAuthenticated) { const doLogout = () => { logout(); router.replace("/login"); }; if (Platform.OS === "web") { const confirmed = typeof window !== "undefined" ? window.confirm("Are you sure you want to logout?") : true; if (confirmed) { doLogout(); } } else { Alert.alert( "Logout", "Are you sure you want to logout?", [ { text: "Cancel", style: "cancel" }, { text: "Yes", style: "destructive", onPress: doLogout, }, ], { cancelable: true } ); } } else { router.push("/login"); } }; return ( ( ), }} /> ( ), }} /> ( ), }} /> ( ), }} listeners={{ tabPress: (e) => { e.preventDefault(); handleAuthAction(); }, }} /> ); }