-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
37 lines (32 loc) · 1.11 KB
/
App.js
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
import { useState, useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { Center, NativeBaseProvider } from 'native-base';
import * as Location from 'expo-location';
import AskLocationPermission from './screens/AskLocationPermission';
import CoordDistanceForm from './screens/CoordDistanceForm';
export default function App() {
const [locationGranted, setLocationGranted] = useState(false);
useEffect(() => {
const checkLocationPermission = async () => {
const { granted } = await Location.getForegroundPermissionsAsync();
setLocationGranted(granted);
};
checkLocationPermission();
}, []);
const inset = {
frame: { x: 0, y: 0, width: 0, height: 0 },
insets: { top: 0, left: 0, right: 0, bottom: 0 },
};
return (
<NativeBaseProvider initialWindowMetrics={inset}>
<Center flex={1} backgroundColor='#e0e0e0'>
{locationGranted ? (
<CoordDistanceForm />
) : (
<AskLocationPermission setLocationGranted={setLocationGranted} />
)}
</Center>
<StatusBar style='auto' />
</NativeBaseProvider>
);
}