import { Tabs, useSegments } from "expo-router"; import { HapticTab } from "@/components/haptic-tab"; import { IconSymbol } from "@/components/ui/icon-symbol"; import { Colors } from "@/constants/theme"; import { useI18n } from "@/hooks/use-i18n"; import { useColorScheme } from "@/hooks/use-theme-context"; import { useEffect, useRef } from "react"; export default function TabLayout() { const colorScheme = useColorScheme(); const segments = useSegments() as string[]; const prev = useRef(null); const currentSegment = segments[1] ?? segments[segments.length - 1] ?? null; const { t, locale } = useI18n(); useEffect(() => { if (prev.current !== currentSegment) { // console.log("Tab changed ->", { from: prev.current, to: currentSegment }); // TODO: xử lý khi chuyển tab ở đây if (prev.current === "(tabs)" && currentSegment !== "(tabs)") { // stopEvents(); // console.log("Stop events"); } else if (prev.current !== "(tabs)" && currentSegment === "(tabs)") { // we came back into the tabs group — restart polling // startEvents(); // console.log("start events"); } prev.current = currentSegment; } }, [currentSegment]); return ( ( ), }} /> ( ), }} /> ( ), }} /> ( ), }} /> ( ), }} /> ); }