Skip to content

Commit

Permalink
Merge pull request #33426 from rayane-djouah/add-the-isInRHP-prop-to-…
Browse files Browse the repository at this point in the history
…the-ModalStackNavigator

Add layout=narrow initial param to the ModalStackNavigator
  • Loading branch information
roryabraham authored Jan 11, 2024
2 parents c93b0b2 + ae11cf0 commit 31aeaae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/hooks/useResponsiveLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useRoute} from '@react-navigation/native';
import useWindowDimensions from './useWindowDimensions';

type RouteParams = ParamListBase & {
params: {isInRHP?: boolean};
params: {layout?: string};
};
type ResponsiveLayoutResult = {
shouldUseNarrowLayout: boolean;
Expand All @@ -16,10 +16,11 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult {
try {
// eslint-disable-next-line react-hooks/rules-of-hooks
const {params} = useRoute<RouteProp<RouteParams, 'params'>>();
return {shouldUseNarrowLayout: isSmallScreenWidth || (params?.isInRHP ?? false)};
const isNarrowLayout = params?.layout === 'narrow' ?? false;
const shouldUseNarrowLayout = isSmallScreenWidth || isNarrowLayout;

return {shouldUseNarrowLayout};
} catch (error) {
return {
shouldUseNarrowLayout: isSmallScreenWidth,
};
return {shouldUseNarrowLayout: isSmallScreenWidth};
}
}
1 change: 1 addition & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function createModalStackNavigator<TStackParams extends ParamListBase>(screens:
key={name}
name={name}
getComponent={(screens as Required<Screens>)[name as Screen]}
initialParams={{layout: 'narrow'} as TStackParams[string]}
/>
))}
</ModalStackNavigator.Navigator>
Expand Down

0 comments on commit 31aeaae

Please sign in to comment.