-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40570 from software-mansion-labs/search-v1/rhp-re…
…port [Search v1] Add ReportScreen to RHP
- Loading branch information
Showing
23 changed files
with
185 additions
and
40 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
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
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,9 @@ | ||
import {useNavigationState} from '@react-navigation/native'; | ||
import getTopmostRouteName from '@libs/Navigation/getTopmostRouteName'; | ||
import SCREENS from '@src/SCREENS'; | ||
|
||
// This hook checks if the currently open route is ReportScreen in RHP. | ||
export default function useIsReportOpenInRHP() { | ||
const activeRoute = useNavigationState(getTopmostRouteName); | ||
return activeRoute === SCREENS.SEARCH.REPORT_RHP; | ||
} |
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
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
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 type {NavigationContainerRef} from '@react-navigation/native'; | ||
import {StackActions} from '@react-navigation/native'; | ||
import Log from '@libs/Log'; | ||
import NAVIGATORS from '@src/NAVIGATORS'; | ||
import type {RootStackParamList} from './types'; | ||
|
||
/** | ||
* Closes the last RHP flow, if there is only one, closes the entire RHP. | ||
*/ | ||
export default function closeRHPFlow(navigationRef: NavigationContainerRef<RootStackParamList>) { | ||
if (!navigationRef.isReady()) { | ||
return; | ||
} | ||
const state = navigationRef.getState(); | ||
const lastRoute = state.routes.at(-1); | ||
const isLastRouteRHP = lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; | ||
|
||
if (!isLastRouteRHP) { | ||
Log.warn('RHP Navigator has not been found when calling closeRHPFlow function'); | ||
return; | ||
} | ||
|
||
let target = state.key; | ||
|
||
const hasMoreThanOneRoute = lastRoute?.state?.routes?.length && lastRoute.state.routes.length > 1; | ||
if (lastRoute?.state?.key && hasMoreThanOneRoute) { | ||
target = lastRoute.state.key; | ||
} | ||
navigationRef.dispatch({...StackActions.pop(), target}); | ||
} |
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,12 @@ | ||
import type {NavigationState, PartialState} from '@react-navigation/native'; | ||
|
||
// Get the name of topmost route in the navigation stack. | ||
function getTopmostRouteName(state: NavigationState | PartialState<NavigationState>): string | undefined { | ||
if (!state) { | ||
return; | ||
} | ||
|
||
return state.routes.at(-1)?.name; | ||
} | ||
|
||
export default getTopmostRouteName; |
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
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
Oops, something went wrong.