-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update getPartialStateDiff.ts fullscreen diff
- Loading branch information
1 parent
882af82
commit 220d866
Showing
2 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import NAVIGATORS from '@src/NAVIGATORS'; | ||
import type {FullScreenName, NavigationPartialRoute, RootStackParamList, State} from './types'; | ||
|
||
// Get the name of topmost fullscreen route in the navigation stack. | ||
function getTopmostFullScreenRoute(state: State<RootStackParamList>): NavigationPartialRoute<FullScreenName> | undefined { | ||
if (!state) { | ||
return; | ||
} | ||
|
||
const topmostFullScreenRoute = state.routes.filter((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR).at(-1); | ||
|
||
if (!topmostFullScreenRoute) { | ||
return; | ||
} | ||
|
||
if (!!topmostFullScreenRoute.params && 'screen' in topmostFullScreenRoute.params) { | ||
return {name: topmostFullScreenRoute.params.screen as FullScreenName, params: topmostFullScreenRoute.params.params}; | ||
} | ||
|
||
if (!topmostFullScreenRoute.state) { | ||
return; | ||
} | ||
|
||
// There will be at least one route in the fullscreen navigator. | ||
const {name, params} = topmostFullScreenRoute.state.routes.at(-1) as NavigationPartialRoute<FullScreenName>; | ||
|
||
return {name, params}; | ||
} | ||
|
||
export default getTopmostFullScreenRoute; |