-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
65 lines (58 loc) · 1.85 KB
/
App.js
File metadata and controls
65 lines (58 loc) · 1.85 KB
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
import React, { useEffect, useState } from "react";
import { Provider as PaperProvider } from "react-native-paper";
import { Camera } from "expo-camera";
import * as Location from "expo-location";
import { Provider } from "react-redux";
import { store, persistor } from "./redux/store";
import MainContent from "./screens/MainContent";
import { PersistGate } from "redux-persist/lib/integration/react";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { Text, StyleSheet, SafeAreaView } from "react-native";
const App = () => {
const [cameraPermission, setCameraPermission] = useState(null);
const [locationPermission, setLocationPermission] = useState(null);
useEffect(() => {
(async () => {
await Camera.requestCameraPermissionsAsync().then((res) => {
setCameraPermission(res.status === "granted");
});
await Location.requestForegroundPermissionsAsync().then((res) => {
setLocationPermission(res.status === "granted");
});
})();
}, []);
if (cameraPermission === false) {
var errorText =
"This application need Camera access. Please allow it in your phone settings.";
return (
<SafeAreaView style={styles.errorContainer}>
<Text style={styles.errorText}>{errorText}</Text>
</SafeAreaView>
);
}
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<GestureHandlerRootView style={{ flex: 1 }}>
<PaperProvider>
<MainContent />
</PaperProvider>
</GestureHandlerRootView>
</PersistGate>
</Provider>
);
};
const styles = StyleSheet.create({
errorContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center",
margin: 20,
},
errorText: {
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
},
});
export default App;