|
@ -26,9 +26,6 @@ import { connect } from "formik"; |
|
|
import colors from "./app/config/colors"; |
|
|
import colors from "./app/config/colors"; |
|
|
import { dimensions } from "./app/config/dimensions"; |
|
|
import { dimensions } from "./app/config/dimensions"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SplashScreen.preventAutoHideAsync(); |
|
|
|
|
|
|
|
|
|
|
|
export default function App() { |
|
|
export default function App() { |
|
|
const [user, setUser] = useState(); |
|
|
const [user, setUser] = useState(); |
|
|
const [pluviometerStation, setPluviometerStation] = useState(undefined); |
|
|
const [pluviometerStation, setPluviometerStation] = useState(undefined); |
|
@ -107,38 +104,49 @@ export default function App() { |
|
|
}, [pluviometerStation]); |
|
|
}, [pluviometerStation]); |
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
|
const restoreUser = async () => { |
|
|
const restoreUser = async () => { |
|
|
|
|
|
await SplashScreen.preventAutoHideAsync(); |
|
|
|
|
|
|
|
|
const storageUser = await authStorage.getUser(); |
|
|
const storageUser = await authStorage.getUser(); |
|
|
if (storageUser) setUser(storageUser); |
|
|
if (storageUser) setUser(storageUser); |
|
|
|
|
|
|
|
|
global.location = await getLocation(); |
|
|
global.location = await getLocation(); |
|
|
SplashScreen.hideAsync(); |
|
|
|
|
|
|
|
|
setIsReady(true) |
|
|
|
|
|
await SplashScreen.hideAsync(); |
|
|
}; |
|
|
}; |
|
|
restoreUser() |
|
|
restoreUser() |
|
|
}) |
|
|
|
|
|
|
|
|
},[]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!isReady) { |
|
|
|
|
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
|
if (global.formsSockets === undefined) |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
if (global.formsSockets === undefined) |
|
|
global.formsSockets = useFiltering( |
|
|
global.formsSockets = useFiltering( |
|
|
global.location || global.defaultLocation |
|
|
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> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |