forked from UNICEFECAR/parenting-app-bebbo-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
96 lines (92 loc) · 2.95 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* React Native App
* https://github.com/facebook/react-native
*
* @format
*/
// declare const global: {HermesInternal: null | {}};
import { ButtonPrimary, ButtonText } from '@components/shared/ButtonGlobal';
import crashlytics from '@react-native-firebase/crashlytics';
import { Action, ThunkAction } from '@reduxjs/toolkit';
import React from 'react';
import {
ActivityIndicator, StyleSheet, Text,
View
} from 'react-native';
import ErrorBoundary from 'react-native-error-boundary';
import 'react-native-gesture-handler';
import Orientation from 'react-native-orientation-locker';
import { MenuProvider } from 'react-native-popup-menu';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { enableScreens } from 'react-native-screens';
import {
Provider,
TypedUseSelectorHook,
useDispatch,
useSelector
} from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import persistStore from 'redux-persist/lib/persistStore';
import { ThemeProvider } from 'styled-components/native';
import './app/localization/initI18next';
import AppNavigation from './app/navigation/AppNavigation';
import configureAppStore from './app/redux/store';
import { googleAuth } from './app/services/googleAuth';
import { appTheme } from './app/styles/theme';
export const store = configureAppStore();
export const persistor = persistStore(store);
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
RootState,
unknown,
Action<string>
>;
enableScreens();
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
const styles=StyleSheet.create({
flex1:{ flex: 1 }
})
const CustomFallback = (props: { error: Error; resetError: Function }) => {
crashlytics().recordError(props.error);
return (
<View>
<Text>Something happened!</Text>
<Text>{props.error.toString()}</Text>
<ButtonPrimary
onPress={() => {
props.resetError();
}}>
<ButtonText>{('Try again')}</ButtonText>
</ButtonPrimary>
</View>
);
}
const App = () => {
React.useEffect(() => {
Orientation.lockToPortrait();
// SplashScreen.hide();
googleAuth.configure();
});
return (
<ErrorBoundary FallbackComponent={CustomFallback}>
<ThemeProvider theme={appTheme}>
<MenuProvider>
<Provider store={store}>
<PersistGate
loading={<><ActivityIndicator size="large" color="#0000ff" /></>}
persistor={persistor}>
<SafeAreaProvider style={styles.flex1}>
<AppNavigation />
</SafeAreaProvider>
</PersistGate>
</Provider>
</MenuProvider>
</ThemeProvider>
</ErrorBoundary>
);
};
export default App;