Skip to content
Open
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
35 changes: 19 additions & 16 deletions src/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ModalView: FC<ModalViewProps> = ({
onRequestDismiss,
contentContainerStyle,
statusBar,
showBackdrop = true,
BackdropPressableComponent = Pressable,
backdropColor = defaultBackdropColor,
disableDefaultStatusBarIOS = false,
Expand All @@ -44,22 +45,24 @@ export const ModalView: FC<ModalViewProps> = ({
<StatusBar {...statusBar} />
) : null}
<GestureHandlerRootView style={styles.flex}>
<View style={[styles.backdropContainer]}>
<BackdropPressableComponent
accessibilityLabel={backdropAccessibilityLabel}
accessibilityHint={backdropAccessibilityHint}
style={styles.flex}
onPress={() => onRequestDismiss?.(DismissalSource.Backdrop)}
>
{renderBackdrop ? (
renderBackdrop()
) : (
<View
style={[styles.flex, { backgroundColor: backdropColor }]}
/>
)}
</BackdropPressableComponent>
</View>
{showBackdrop && (
<View style={[styles.backdropContainer]}>
<BackdropPressableComponent
accessibilityLabel={backdropAccessibilityLabel}
accessibilityHint={backdropAccessibilityHint}
style={styles.flex}
onPress={() => onRequestDismiss?.(DismissalSource.Backdrop)}
>
{renderBackdrop ? (
renderBackdrop()
) : (
<View
style={[styles.flex, { backgroundColor: backdropColor }]}
/>
)}
</BackdropPressableComponent>
</View>
)}
<ScrollContextResetter>
<View
pointerEvents='box-none'
Expand Down
35 changes: 19 additions & 16 deletions src/ModalView.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const ModalView: FC<ModalViewWebProps> = ({
renderBackdrop,
onRequestDismiss,
contentContainerStyle,
showBackdrop = true,
BackdropPressableComponent = Pressable,
backdropColor = defaultBackdropColor,
animationType = 'none',
Expand Down Expand Up @@ -57,22 +58,24 @@ export const ModalView: FC<ModalViewWebProps> = ({
}, [animationType, modalIsOpen]);

return createPortal(
<View style={[styles.backdropContainer]}>
<BackdropPressableComponent
accessibilityLabel={backdropAccessibilityLabel}
accessibilityHint={backdropAccessibilityHint}
style={[
styles.backdropPressable,
!isBackdropVisible && styles.backdropHidden,
]}
onPress={() => onRequestDismiss?.(DismissalSource.Backdrop)}
>
{renderBackdrop ? (
renderBackdrop()
) : (
<View style={[styles.flex, { backgroundColor: backdropColor }]} />
)}
</BackdropPressableComponent>
<View style={[showBackdrop && styles.backdropContainer]}>
{showBackdrop && (
<BackdropPressableComponent
accessibilityLabel={backdropAccessibilityLabel}
accessibilityHint={backdropAccessibilityHint}
style={[
styles.backdropPressable,
!isBackdropVisible && styles.backdropHidden,
]}
onPress={() => onRequestDismiss?.(DismissalSource.Backdrop)}
>
{renderBackdrop ? (
renderBackdrop()
) : (
<View style={[styles.flex, { backgroundColor: backdropColor }]} />
)}
</BackdropPressableComponent>
)}

<View
role='dialog'
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export type ModalViewProps = {
*/
animationType?: 'none' | 'fade' | 'slide';

/**
* Whether to show the backdrop behind the modal.
* Defaults to true.
*/
showBackdrop?: boolean;

/**
* @deprecated Use `statusBar.translucent` instead.
*/
Expand Down