-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
App.tsx
55 lines (51 loc) · 1.71 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
import React from 'react';
import { LogBox, Platform, ToastAndroid } from 'react-native';
import { useSelector } from 'react-redux';
import { BusinessApp } from './business/BusinessApp';
import PreloadAssets from './common/app/PreloadAssets';
import { AppContext } from './common/app/context';
import ShowIf from './common/components/views/ShowIf';
import { getFlavor } from './common/store/config/selectors';
import { getExtra } from './common/utils/config';
import { getAppVersion } from './common/utils/version';
import ConsumerApp from './consumer/ConsumerApp';
import CourierApp from './courier/CourierApp';
// https://github.com/facebook/react-native/issues/12981#issuecomment-652745831
// https://reactnative.dev/docs/debugging#console-errors-and-warnings
// https://twitter.com/rickhanlonii/status/1255185060208226306
if (__DEV__) {
LogBox.ignoreLogs([
'Setting a timer',
'Sentry Logger',
'AsyncStorage has been extracted',
'You need to add `ACCESS_BACKGROUND_LOCATION`',
'ViewPropTypes will be removed',
]);
}
const App = () => {
const flavor = useSelector(getFlavor);
React.useEffect(() => {
// debug only
if (Platform.OS === 'android' && getExtra().environment !== 'live') {
ToastAndroid.show('Testing mode ' + getAppVersion(), ToastAndroid.LONG);
}
}, []);
return (
<>
<ShowIf test={flavor === 'consumer'}>{() => <ConsumerApp />}</ShowIf>
<ShowIf test={flavor === 'courier'}>{() => <CourierApp />}</ShowIf>
<ShowIf test={flavor === 'business'}>{() => <BusinessApp />}</ShowIf>
</>
);
};
export default () => {
return (
<PreloadAssets>
{() => (
<AppContext>
<App />
</AppContext>
)}
</PreloadAssets>
);
};