-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
43 lines (39 loc) · 1.47 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
import React, { useEffect, useState } from 'react';
import { Platform, SafeAreaView, StatusBar } from 'react-native';
import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker';
import { usePermission } from './src/hooks';
import { Camera } from './src/components';
import { RequestPermission } from './src/components';
import { CameraContextProvider } from './src/store';
function App(): React.JSX.Element {
const { requestPermission, cameraPermission, microphonePermission, libraryPermission } =
usePermission();
const [orientation, setOrientation] = useState<string>('portrait');
useEffect(() => {
requestPermission();
}, []);
return (
<SafeAreaView style={{ flex: 1, marginTop: Platform.OS === 'ios' ? 70 : 0 }}>
<StatusBar barStyle={'dark-content'} backgroundColor={'black'} />
<OrientationLocker
orientation={PORTRAIT}
onDeviceChange={(orientation) => setOrientation(orientation)}
/>
{!cameraPermission ||
!microphonePermission ||
(Platform.OS === 'android' && !libraryPermission) ? (
<RequestPermission
requestPermission={requestPermission}
cameraPermission={cameraPermission}
microphonePermission={microphonePermission}
libraryPermission={libraryPermission}
/>
) : (
<CameraContextProvider>
<Camera orientation={orientation} />
</CameraContextProvider>
)}
</SafeAreaView>
);
}
export default App;