-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
104 lines (95 loc) · 2.59 KB
/
App.js
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
97
98
99
100
101
102
103
104
import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {RootStack} from './src/navigation/RootStack';
import {
SafeAreaConsumer,
SafeAreaProvider,
} from 'react-native-safe-area-context';
import {Text, View} from 'react-native';
import Globals from './src/utils/Globals';
import {useColorScheme} from 'react-native';
import AppConfig from './branding/App_config';
import Toast, {BaseToast, ErrorToast} from 'react-native-toast-message';
import CodePush from 'react-native-code-push';
const lightColors = AppConfig.lightColors.default;
const darkColors = AppConfig.darkColors.default;
const DarkTheme = {
dark: true,
colors: darkColors,
};
const LightTheme = {
dark: false,
colors: lightColors,
};
const App = props => {
const scheme = useColorScheme();
const toastConfig = {
/*
Overwrite 'success' type,
by modifying the existing `BaseToast` component
*/
success: props => (
<BaseToast
{...props}
style={{borderLeftColor: 'green', width: '100%'}}
contentContainerStyle={{paddingHorizontal: 15}}
text1Style={{
fontSize: 20,
fontWeight: '400',
}}
/>
),
/*
Overwrite 'error' type,
by modifying the existing `ErrorToast` component
*/
error: props => (
<ErrorToast
{...props}
style={{
borderLeftColor: 'red',
width: '100%',
}}
text1Style={{
fontSize: 20,
}}
text2Style={{
fontSize: 15,
}}
/>
),
/*
Or create a completely new type - `tomatoToast`,
building the layout from scratch.
I can consume any custom `props` I want.
They will be passed when calling the `show` method (see below)
*/
tomatoToast: ({text1, props}) => (
<View style={{height: 60, width: '100%', backgroundColor: 'tomato'}}>
<Text>{text1}</Text>
<Text>{props.uuid}</Text>
</View>
),
};
return (
<>
<NavigationContainer theme={scheme === 'dark' ? DarkTheme : LightTheme}>
<SafeAreaProvider>
<SafeAreaConsumer>
{insets => {
Globals.SAFE_AREA_INSET = insets;
return <RootStack />;
}}
</SafeAreaConsumer>
</SafeAreaProvider>
</NavigationContainer>
<Toast config={toastConfig} />
</>
);
};
let codePushOptions = {
checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
installMode: CodePush.InstallMode.ON_NEXT_RESUME,
};
const HotPushApp = CodePush(codePushOptions)(App);
export default HotPushApp;