-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
65 lines (55 loc) · 1.6 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
import { requestAndroidLocationPermissions } from "@vietmap/vietmap-gl-react-native";
import { useEffect, useState } from "react";
import { LogBox, Platform, StyleSheet, Text, View } from "react-native";
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
import "react-native-gesture-handler";
import { Home } from "./Examples";
import { sheet } from "./styles/sheet";
LogBox.ignoreLogs([
"Warning: isMounted(...) is deprecated",
"Module RCTImageLoader",
]);
const styles = StyleSheet.create({
noPermissionsText: {
fontSize: 18,
fontWeight: "bold",
},
});
const IS_ANDROID = Platform.OS === "android";
export default function App() {
const [isFetchingAndroidPermission, setIsFetchingAndroidPermission] =
useState(IS_ANDROID);
const [isAndroidPermissionGranted, setIsAndroidPermissionGranted] =
useState(false);
useEffect(() => {
(async () => {
if (IS_ANDROID) {
const isGranted = await requestAndroidLocationPermissions();
setIsAndroidPermissionGranted(isGranted);
setIsFetchingAndroidPermission(false);
}
})();
}, []);
if (IS_ANDROID && !isAndroidPermissionGranted) {
if (isFetchingAndroidPermission) {
return null;
}
return (
<SafeAreaProvider>
<SafeAreaView style={sheet.matchParent}>
<View style={sheet.matchParent}>
<Text style={styles.noPermissionsText}>
You need to accept location permissions in order to use this
example applications
</Text>
</View>
</SafeAreaView>
</SafeAreaProvider>
);
}
return (
<SafeAreaProvider>
<Home />
</SafeAreaProvider>
);
}