-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
97 lines (79 loc) · 2.83 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
//import { SafeAreaView } from 'react-native-safe-area-context';
import React, { useEffect, useState, useRef, useCallback } from 'react';
import { SafeAreaView, StyleSheet, Platform, LogBox } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import * as Sentry from '@sentry/react-native';
import { useFonts } from 'expo-font';
import * as Notifications from 'expo-notifications';
import * as SplashScreen from 'expo-splash-screen';
import { RecoilRoot } from 'recoil';
import RootStack from '~/screens/RootStack';
import { rHeight } from '~/styles/globalSizes';
import { TabContextProvider } from '~/context/TabContext';
if (!__DEV__) {
Sentry.init({
dsn: process.env.EXPO_PUBLIC_SENTRY_DSN,
//debug: true, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
tracesSampleRate: 1.0,
});
}
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
SplashScreen.preventAutoHideAsync();
function App() {
const [fontsLoaded, fontError] = useFonts({
NotoSans_100Thin: require('~/assets/fonts/NotoSansKR-Thin.otf'),
NotoSans_300Light: require('~/assets/fonts/NotoSansKR-Light.otf'),
NotoSans_400Regular: require('~/assets/fonts/NotoSansKR-Regular.otf'),
NotoSans_500Medium: require('~/assets/fonts/NotoSansKR-Medium.otf'),
NotoSans_700Bold: require('~/assets/fonts/NotoSansKR-Bold.otf'),
NotoSans_900Black: require('~/assets/fonts/NotoSansKR-Black.otf'),
});
const [notification, setNotification] = useState(false);
const notificationListener = useRef();
useEffect(() => {
notificationListener.current =
Notifications.addNotificationReceivedListener((notification) => {
setNotification(notification);
});
return () => {
Notifications.removeNotificationSubscription(
notificationListener.current,
);
};
}, []);
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded || fontError) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded, fontError]);
if (!fontsLoaded && !fontError) {
return null;
}
LogBox.ignoreAllLogs();
return (
<SafeAreaView style={styles.container} onLayout={onLayoutRootView}>
<RecoilRoot>
<TabContextProvider>
<NavigationContainer>
<RootStack />
</NavigationContainer>
</TabContextProvider>
</RecoilRoot>
</SafeAreaView>
);
}
const AppWrapper = __DEV__ ? App : Sentry.wrap(App);
export default AppWrapper;
const styles = StyleSheet.create({
container: {
flex: 1,
// paddingTop: Platform.OS === 'android' ? rHeight(45) : 0,
// paddingBottom: Platform.OS === 'android' ? rHeight(15) : 0,
},
});