_layout.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Stack } from 'expo-router/stack';
  2. import AuthProvider, { useAuth } from '../context/AuthProvider';
  3. import { EXPO_PUBLIC_NODE_ENV } from '@env';
  4. import { GestureHandlerRootView } from 'react-native-gesture-handler';
  5. import { useEffect, useState } from 'react';
  6. import { checkVersion } from '../component/checkVersion';
  7. import { authenticationService } from '../service/authService';
  8. import { usePushNotifications } from './hooks/usePushNotifications';
  9. export default function RootLayout() {
  10. const [isLoading, setIsLoading] = useState(true);
  11. const { user } = useAuth();
  12. const { expoPushToken, notification } = usePushNotifications();
  13. console.log('notification', notification);
  14. console.log('expoPushToken', expoPushToken);
  15. const data = JSON.stringify(notification, undefined, 2);
  16. useEffect(() => {
  17. const fetchVersion = async () => {
  18. const response = await authenticationService.getVersion();
  19. checkVersion(response);
  20. };
  21. fetchVersion();
  22. }, []);
  23. return (
  24. <GestureHandlerRootView style={{ flex: 1 }}>
  25. <AuthProvider>
  26. <Stack>
  27. <Stack.Screen name="(auth)/(tabs)" options={{ headerShown: false }} />
  28. <Stack.Screen name="(public)/login" options={{ headerShown: false }} />
  29. <Stack.Screen name="(public)/registerChooseVehiclesOne" options={{ headerShown: false }} />
  30. <Stack.Screen name="(public)/registerChooseVehiclesTwo" options={{ headerShown: false }} />
  31. {/* Testing Purpose */}
  32. {EXPO_PUBLIC_NODE_ENV == 'development' ? (
  33. <Stack.Screen
  34. name="(public)/test"
  35. options={{
  36. headerShown: false,
  37. title: 'Test Component Page'
  38. }}
  39. />
  40. ) : (
  41. <></>
  42. )}
  43. </Stack>
  44. </AuthProvider>
  45. </GestureHandlerRootView>
  46. );
  47. }