Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
de89481c
Commit
de89481c
authored
Sep 09, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling logic for splash screen in auth context. memo this component for caching
parent
153ecec7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
AppMainStackNavigator.tsx
src/navigations/AppMainStackNavigator.tsx
+13
-14
No files found.
src/navigations/AppMainStackNavigator.tsx
View file @
de89481c
...
...
@@ -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
}
/>;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment