-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
57 lines (50 loc) · 1.51 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState, useEffect } from "react";
import { NavigationContainer } from "@react-navigation/native";
import TabNavigator from "./navigator/navigator";
import { Provider } from "react-redux";
import { combineReducers, createStore } from "redux";
import { travelReducer } from "./store/reducers/travel";
import { locationReducer } from "./store/reducers/locations";
import LoadingScreen from "./screens/loadingScreen";
import { Alert } from "react-native";
import * as Location from "expo-location";
const rootReducer = combineReducers({
travel: travelReducer,
location: locationReducer,
});
const store = createStore(rootReducer);
export default function App() {
const fetchLocation = async () => {
try {
let { status } = await Location.requestPermissionsAsync();
console.log(status);
if (status !== "granted") {
return Alert.alert("permission denied.", "enable permissions");
}
const stat = await Location.hasServicesEnabledAsync();
if (!stat) {
Alert.alert("location", "enable location");
}
} catch (er) {
console.log(er);
Alert.alert("error fetching location", "enable location");
}
};
useEffect(() => {
fetchLocation();
}, []);
const [loading, setLoading] = useState(true);
setTimeout(() => {
setLoading(false);
}, 3000);
if (loading) {
return <LoadingScreen />;
}
return (
<Provider store={store}>
<NavigationContainer>
<TabNavigator />
</NavigationContainer>
</Provider>
);
}