App.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React, { useState } from 'react';
  2. import { LogBox, StatusBar } from 'react-native';
  3. import 'react-native-gesture-handler';
  4. import { SafeAreaProvider } from 'react-native-safe-area-context';
  5. import { Asset } from 'expo-asset';
  6. import AppLoading from 'expo-app-loading';
  7. import * as Updates from "expo-updates";
  8. import { NavigationContainer } from '@react-navigation/native';
  9. import { QueryClient, QueryClientProvider } from 'react-query';
  10. import { AuthProvider } from './src/lib/auth/AuthContext';
  11. import MainTabsNavigator from './src/navigation/MainTabsNavigator';
  12. import { NotifProvider } from './src/lib/auth/NotificationContext';
  13. /**
  14. * The root app component.
  15. * @component
  16. */
  17. const App: React.FC = () => {
  18. LogBox.ignoreAllLogs();
  19. const queryClient = new QueryClient();
  20. const [loading, setLoading] = useState(false);
  21. const _cacheResourcesAsync = async () => {
  22. const images = [
  23. require('./assets/logo-white.png'),
  24. require('./assets/cover-dark.png'),
  25. require('./assets/cover.jpg'),
  26. require('./assets/default-pfp.png'),
  27. require('./assets/pothole.png'),
  28. require('./assets/roadblock.png'),
  29. require('./assets/barrier.png'),
  30. require('./assets/bump.png'),
  31. require('./assets/information.png'),
  32. require('./assets/washroom.png'),
  33. require('./assets/park.png'),
  34. ];
  35. const cacheImages = images.map(image => {
  36. return Asset.fromModule(image).downloadAsync();
  37. });
  38. Promise.all(cacheImages);
  39. }
  40. if (loading) {
  41. return (
  42. <AppLoading
  43. startAsync={_cacheResourcesAsync}
  44. onFinish={() => setLoading(false)}
  45. onError={console.warn}
  46. />
  47. );
  48. }
  49. return <SafeAreaProvider>
  50. <QueryClientProvider client={queryClient}>
  51. <AuthProvider>
  52. <NotifProvider>
  53. <NavigationContainer>
  54. <StatusBar />
  55. <MainTabsNavigator />
  56. </NavigationContainer>
  57. </NotifProvider>
  58. </AuthProvider>
  59. </QueryClientProvider>
  60. </SafeAreaProvider>
  61. }
  62. export default App;