Skip to content

Instantly share code, notes, and snippets.

@ScreamZ
Last active November 1, 2019 18:49
Show Gist options
  • Save ScreamZ/638349c0921155f23da1ffb0815c738b to your computer and use it in GitHub Desktop.
Save ScreamZ/638349c0921155f23da1ffb0815c738b to your computer and use it in GitHub Desktop.
import { Splashscreen } from "@images";
import AppLoader from "@modules/app/AppLoader";
import { LoadingProcess } from "@modules/app/types";
import AppNavigator from "@modules/navigation/AppNavigator";
import { CountrySelectionStatus } from "@modules/onboarding/types";
import _ from "lodash";
import React from "react";
import styled from "styled-components/native";
import { useFavoriteCountry } from "@modules/app/hooks/useFavoriteCountry";
function App() {
// … others import
const userFavoriteCountryContext = useFavoriteCountry();
// As long as not all screens are ready, display splashscreen
const loadingProcesses: LoadingProcess[] = [
{ name: "user_favorite_country", isReady: userFavoriteCountryContext.favoriteCountry !== CountrySelectionStatus.Loading },
];
return (
<AppLoader
mandatoryProcesses={loadingProcesses}
loadingComponent={<SplashImage source={Splashscreen.Default} />}
minimumLoadingTime={__DEV__ ? 0 : 2000}
>
<AppNavigator />
</AppLoader>
);
}
const SplashImage = styled.Image`
height: 100%;
width: 100%;
`;
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment