-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
68 lines (57 loc) · 1.72 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
import React, { useCallback, useEffect, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import ShareMenu from 'react-native-share-menu';
import { ShareHandler } from '~/components/ShareHandler';
import { YgtStatusBar } from '~/components/YgtStatusBar';
import MainNavigator from '~/navigation/MainNavigator';
import theme from '~/styles/theme';
import { Sentry } from '~/utils/sentry';
import 'react-native-gesture-handler';
function App() {
const [shareMenu, setShareMenu] = useState(false);
const [shareData, setShareData] = useState<string | null>(null);
const [shareMimeType, setShareMimeType] = useState<string | null>(null);
const handleShare = useCallback(item => {
if (!item) {
return;
}
const { mimeType, data } = item;
setShareMenu(true);
setShareData(data);
setShareMimeType(mimeType);
}, []);
const closeShareView = () => {
setShareMenu(false);
setShareData(null);
setShareMimeType(null);
};
useEffect(() => {
ShareMenu.getInitialShare(handleShare);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
const listener = ShareMenu.addNewShareListener(handleShare);
return () => {
listener.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (shareMenu && shareData && shareMimeType) {
return <ShareHandler data={shareData} mimeType={shareMimeType} handleClose={closeShareView} />;
}
return (
<>
<YgtStatusBar />
<View style={styles.root}>
<MainNavigator />
</View>
</>
);
}
export default Sentry.wrap(App);
const styles = StyleSheet.create({
root: {
flex: 1,
backgroundColor: theme.color.background,
},
});