Commit de89481c by G

handling logic for splash screen in auth context. memo this component for caching

parent 153ecec7
......@@ -5,7 +5,7 @@ import HomeUserNotLoggedIn from "@screens/HomeUserNotLoggedIn";
import PaymentResultScreen from "@screens/PaymentResultScreen";
import UserLoginScreen from "@screens/UserLoginScreen";
import WaveQrCodePaymentScreen from "@screens/WaveQrCodePaymentScreen";
import * as SplashScreen from "expo-splash-screen";
import { memo } from "react";
import { AppBottomTabsNavigator } from "./AppBottomTabsNavigator";
import type { ImainStackNavigator } from "./Types";
......@@ -13,20 +13,14 @@ const Stack = createNativeStackNavigator<ImainStackNavigator>();
const log = LOG.extend("AppMainStackNavigator");
SplashScreen.preventAutoHideAsync();
interface IappMainStackNavigatorProps {
isAuthenticated: boolean;
}
const AppMainStackNavigator = () => {
const { isAuthenticated, isAuthenticating } = useUserAuthenticationContext();
if (isAuthenticating) {
log.info("isAuthenticating");
return null;
}
(async () => {
await SplashScreen.hideAsync();
})();
if (!isAuthenticating && !isAuthenticated) {
const AppMainStackNavigator: React.FC<IappMainStackNavigatorProps> = ({ isAuthenticated }) => {
if (!isAuthenticated) {
log.info("Navigating to UserLoginScreen");
return (
<Stack.Navigator
initialRouteName="homeUserNotLoggedIn"
......@@ -53,4 +47,9 @@ const AppMainStackNavigator = () => {
);
};
export default AppMainStackNavigator;
export default memo(AppMainStackNavigator);
export const AppMainStackNavigatorAuthWrapper = () => {
const { isAuthenticated } = useUserAuthenticationContext();
return <AppMainStackNavigator isAuthenticated={isAuthenticated} />;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment