|
@ -1,12 +1,10 @@ |
|
|
import React, { useState } from "react"; |
|
|
|
|
|
|
|
|
import React, { useState, useEffect} from "react"; |
|
|
import { NavigationContainer } from "@react-navigation/native"; |
|
|
import { NavigationContainer } from "@react-navigation/native"; |
|
|
|
|
|
|
|
|
import navigationTheme from "./app/navigation/navigationTheme"; |
|
|
import navigationTheme from "./app/navigation/navigationTheme"; |
|
|
import "./app/config/globals.js"; |
|
|
import "./app/config/globals.js"; |
|
|
import openDatabase from "./app/database/database-connection"; |
|
|
|
|
|
import { AppLoading } from "expo"; |
|
|
import { AppLoading } from "expo"; |
|
|
|
|
|
|
|
|
import initDatabase from "./app/database/database-init"; |
|
|
|
|
|
import FlashMessage from "react-native-flash-message"; |
|
|
import FlashMessage from "react-native-flash-message"; |
|
|
import AppNavigator from "./app/navigation/AppNavigator"; |
|
|
import AppNavigator from "./app/navigation/AppNavigator"; |
|
|
import EventLocationProvider from "./app/context/EventLocationContext"; |
|
|
import EventLocationProvider from "./app/context/EventLocationContext"; |
|
@ -26,10 +24,16 @@ export default function App() { |
|
|
|
|
|
|
|
|
const netInfo = useNetInfo(); |
|
|
const netInfo = useNetInfo(); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
user && authStorage.setUser(user) |
|
|
|
|
|
}, [user]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const restoreUser = async () => { |
|
|
const restoreUser = async () => { |
|
|
const user = await authStorage.getUser(); |
|
|
|
|
|
|
|
|
const storageUser = await authStorage.getUser(); |
|
|
|
|
|
if (storageUser) setUser(storageUser); |
|
|
|
|
|
|
|
|
global.location = { lat: -23.623, long: -46.5637 }; // await getLocation();
|
|
|
global.location = { lat: -23.623, long: -46.5637 }; // await getLocation();
|
|
|
if (user) setUser(user); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (!isReady && netInfo.isInternetReachable) { |
|
|
if (!isReady && netInfo.isInternetReachable) { |
|
@ -37,8 +41,6 @@ export default function App() { |
|
|
<AppLoading startAsync={restoreUser} onFinish={() => setIsReady(true)} /> |
|
|
<AppLoading startAsync={restoreUser} onFinish={() => setIsReady(true)} /> |
|
|
); |
|
|
); |
|
|
} else if (netInfo.isInternetReachable) { |
|
|
} else if (netInfo.isInternetReachable) { |
|
|
global.userDataBase = openDatabase(); |
|
|
|
|
|
initDatabase(global.userDataBase); |
|
|
|
|
|
global.formsSockets = useFiltering(global.location); |
|
|
global.formsSockets = useFiltering(global.location); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|