-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
78 lines (66 loc) · 2.09 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
/* eslint-disable prettier/prettier */
// ** React Imports
import React, {forwardRef, useEffect} from 'react';
import {StatusBar, StyleSheet, View} from 'react-native';
// ** Third Party Imports
import {Provider} from 'react-redux';
import SplashScreen from 'react-native-splash-screen';
import Toast, {ToastProps} from 'react-native-toast-message';
import {NavigationContainer} from '@react-navigation/native';
// ** Component Imports
import {store} from './src/redux/store';
import StackNavigation from './src/navigation/Stack';
import {AuthProvider} from './src/context/AuthContext';
import {NotificationServices} from './src/configs/PushNotifications';
import NavigationService from './src/configs/NavigationService';
import notifee, {EventType} from '@notifee/react-native';
interface ToastWithRefProps extends ToastProps {
ref?: React.Ref<HTMLDivElement>;
}
const ToastWithRef = forwardRef<HTMLDivElement, ToastWithRefProps>(
(props, ref) => <Toast ref={ref} {...props} />,
);
const App = () => {
useEffect(() => {
SplashScreen.hide();
createNotificationChannel();
NotificationServices();
}, []);
async function createNotificationChannel() {
try {
await notifee.createChannel({
id: 'download-progress',
name: 'Download Progress',
lights: false,
vibration: false,
});
} catch (error) {
console.error('Error creating notification channel:', error);
}
}
return (
<View style={styles.main_container}>
{/* Status bar */}
<StatusBar barStyle={'light-content'} backgroundColor={'#CADB29'} />
{/* Redux Provider */}
<Provider store={store}>
{/* Context Provider */}
<AuthProvider>
{/* Navigation */}
<NavigationContainer
ref={ref => NavigationService.setTopLevelNavigator(ref)}>
<StackNavigation />
</NavigationContainer>
</AuthProvider>
</Provider>
{/* Toast */}
<ToastWithRef position="top" />
</View>
);
};
export default App;
const styles = StyleSheet.create({
main_container: {
flex: 1,
},
});