|
|
@ -3,7 +3,7 @@ import { NavigationContainer } from "@react-navigation/native"; |
|
|
|
|
|
|
|
import navigationTheme from "./app/navigation/navigationTheme"; |
|
|
|
import "./app/config/globals.js"; |
|
|
|
import AppLoading from "expo-app-loading"; |
|
|
|
import * as SplashScreen from 'expo-splash-screen'; |
|
|
|
import FlashMessage, { |
|
|
|
showMessage, |
|
|
|
hideMessage, |
|
|
@ -26,6 +26,9 @@ import { connect } from "formik"; |
|
|
|
import colors from "./app/config/colors"; |
|
|
|
import { dimensions } from "./app/config/dimensions"; |
|
|
|
|
|
|
|
|
|
|
|
SplashScreen.preventAutoHideAsync(); |
|
|
|
|
|
|
|
export default function App() { |
|
|
|
const [user, setUser] = useState(); |
|
|
|
const [pluviometerStation, setPluviometerStation] = useState(undefined); |
|
|
@ -103,45 +106,39 @@ export default function App() { |
|
|
|
} |
|
|
|
}, [pluviometerStation]); |
|
|
|
|
|
|
|
const restoreUser = async () => { |
|
|
|
const storageUser = await authStorage.getUser(); |
|
|
|
if (storageUser) setUser(storageUser); |
|
|
|
|
|
|
|
global.location = await getLocation(); |
|
|
|
}; |
|
|
|
|
|
|
|
if (!isReady) { |
|
|
|
return ( |
|
|
|
<AppLoading |
|
|
|
startAsync={restoreUser} |
|
|
|
onFinish={() => setIsReady(true)} |
|
|
|
onError={(e) => console.log(e)} |
|
|
|
/> |
|
|
|
useEffect(()=>{ |
|
|
|
const restoreUser = async () => { |
|
|
|
const storageUser = await authStorage.getUser(); |
|
|
|
if (storageUser) setUser(storageUser); |
|
|
|
|
|
|
|
global.location = await getLocation(); |
|
|
|
SplashScreen.hideAsync(); |
|
|
|
}; |
|
|
|
restoreUser() |
|
|
|
}) |
|
|
|
|
|
|
|
if (global.formsSockets === undefined) |
|
|
|
global.formsSockets = useFiltering( |
|
|
|
global.location || global.defaultLocation |
|
|
|
); |
|
|
|
} else { |
|
|
|
if (global.formsSockets === undefined) |
|
|
|
global.formsSockets = useFiltering( |
|
|
|
global.location || global.defaultLocation |
|
|
|
); |
|
|
|
|
|
|
|
return ( |
|
|
|
<AuthContext.Provider |
|
|
|
value={{ |
|
|
|
user, |
|
|
|
setUser, |
|
|
|
}} |
|
|
|
> |
|
|
|
<CurrentLocationProvider> |
|
|
|
<EventLocationProvider> |
|
|
|
<MapDataProvider> |
|
|
|
<NavigationContainer theme={navigationTheme}> |
|
|
|
{user ? <AppNavigator /> : <AuthNavigator />} |
|
|
|
<FlashMessage position="top" /> |
|
|
|
</NavigationContainer> |
|
|
|
</MapDataProvider> |
|
|
|
</EventLocationProvider> |
|
|
|
</CurrentLocationProvider> |
|
|
|
</AuthContext.Provider> |
|
|
|
); |
|
|
|
} |
|
|
|
return ( |
|
|
|
<AuthContext.Provider |
|
|
|
value={{ |
|
|
|
user, |
|
|
|
setUser, |
|
|
|
}} |
|
|
|
> |
|
|
|
<CurrentLocationProvider> |
|
|
|
<EventLocationProvider> |
|
|
|
<MapDataProvider> |
|
|
|
<NavigationContainer theme={navigationTheme}> |
|
|
|
{user ? <AppNavigator /> : <AuthNavigator />} |
|
|
|
<FlashMessage position="top" /> |
|
|
|
</NavigationContainer> |
|
|
|
</MapDataProvider> |
|
|
|
</EventLocationProvider> |
|
|
|
</CurrentLocationProvider> |
|
|
|
</AuthContext.Provider> |
|
|
|
); |
|
|
|
} |