Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ const CONST = {
MODAL_TYPE: {
CONFIRM: 'confirm',
CENTERED: 'centered',
CENTERED_SWIPABLE_TO_RIGHT: 'centered_swipable_to_right',
CENTERED_UNSWIPEABLE: 'centered_unswipeable',
CENTERED_SMALL: 'centered_small',
BOTTOM_DOCKED: 'bottom_docked',
Expand Down
6 changes: 5 additions & 1 deletion src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
const showModal = () => {
const statusBarColor = StatusBar.getBackgroundColor() ?? theme.appBG;

const isFullScreenModal = type === CONST.MODAL.MODAL_TYPE.CENTERED || type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE || type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED;
const isFullScreenModal =
type === CONST.MODAL.MODAL_TYPE.CENTERED ||
type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE ||
type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED ||
CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT;

if (statusBarColor) {
setPreviousStatusBarColor(statusBarColor);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/SearchRouter/SearchRouterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ function SearchRouterModal() {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {isSearchRouterDisplayed, closeSearchRouter} = useSearchRouterContext();

const modalType = shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE : CONST.MODAL.MODAL_TYPE.POPOVER;
const modalType = shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT : CONST.MODAL.MODAL_TYPE.POPOVER;

return (
<Modal
type={modalType}
isVisible={isSearchRouterDisplayed}
popoverAnchorPosition={{right: 6, top: 6}}
fullscreen
propagateSwipe
shouldHandleNavigationBack={Browser.isMobileChrome()}
onClose={closeSearchRouter}
>
Expand Down
30 changes: 30 additions & 0 deletions src/styles/utils/generators/ModalStyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,36 @@ const createModalStyleUtils: StyleUtilGenerator<GetModalStylesStyleUtil> = ({the
shouldAddTopSafeAreaPadding = isSmallScreenWidth;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT:
// A centered modal is one that has a visible backdrop
// and can be dismissed by clicking outside of the modal.
// This modal should take up the entire visible area when
// viewed on a smaller device (e.g. mobile or mobile web).
modalStyle = {
...modalStyle,
...{
alignItems: 'center',
},
};
modalContainerStyle = {
boxShadow: '0px 0px 5px 5px rgba(0, 0, 0, 0.1)',
flex: 1,
marginTop: isSmallScreenWidth ? 0 : 20,
marginBottom: isSmallScreenWidth ? 0 : 20,
borderRadius: isSmallScreenWidth ? 0 : variables.componentBorderRadiusLarge,
overflow: 'hidden',
...getCenteredModalStyles(styles, windowWidth, isSmallScreenWidth),
};

// Allow this modal to be dismissed with a swipe to the right, required when we want to have a list in centered modal
swipeDirection = ['right'];
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut';
Comment on lines +142 to +143

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, we can define these strings as constants, since its used these few time in this file

shouldAddTopSafeAreaMargin = !isSmallScreenWidth;
shouldAddBottomSafeAreaMargin = !isSmallScreenWidth;
shouldAddTopSafeAreaPadding = isSmallScreenWidth;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE:
// A centered modal that cannot be dismissed with a swipe.
modalStyle = {
Expand Down