forked from andre-felipe-hoffmann/barcode-scanner-expo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
35 lines (28 loc) · 788 Bytes
/
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
import React, {useState, useEffect} from 'react'
import { View, Text } from 'react-native';
import { Camera } from 'expo-camera';
import RootNavigator from './components/RootNavigator'
import styles from './styles';
const App: React.FC = () => {
const [hasPermission, setHasPermission] = useState<boolean | null>(null);
useEffect(() => {
(async () => {
const { status } = await Camera.requestPermissionsAsync();
setHasPermission(status === 'granted');
})();
}, []);
if (hasPermission === null) {
return <View />;
}
if (hasPermission === false) {
return (
<View style={styles.mainContainer}>
<Text>Sem acesso à camera</Text>
</View>
)
}
return (
<RootNavigator />
)
}
export default App