Skip to content

Commit

Permalink
feat: add overlayEnable option in drawer layout
Browse files Browse the repository at this point in the history
  • Loading branch information
brannonvann committed Oct 21, 2023
1 parent 688c43a commit 1ae0752
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/react-native-drawer-layout/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export type DrawerProps = {
*/
drawerStyle?: StyleProp<ViewStyle>;

/**
* Whether the overlay is enabled.
* If false, interaction is possible with the drawer content while drawer is open.
* Defaults to `true`.
*/
overlayEnabled?: boolean;

/**
* Style object for the drawer overlay.
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-drawer-layout/src/views/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function Drawer({
keyboardDismissMode = 'on-drag',
hideStatusBarOnOpen = false,
statusBarAnimation = 'slide',
overlayEnabled = true,
style,
...rest
}: Props) {
Expand Down Expand Up @@ -107,6 +108,7 @@ export function Drawer({
keyboardDismissMode={keyboardDismissMode}
hideStatusBarOnOpen={hideStatusBarOnOpen}
statusBarAnimation={statusBarAnimation}
overlayEnabled={overlayEnabled}
/>
</GestureHandlerRootView>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ export class Drawer extends React.Component<Props> {
children,
gestureHandlerProps,
overlayAccessibilityLabel,
overlayEnabled,
} = this.props;

const isOpen = drawerType === 'permanent' ? true : open;
Expand Down Expand Up @@ -596,8 +597,8 @@ export class Drawer extends React.Component<Props> {
{children}
</View>
{
// Disable overlay if sidebar is permanent
drawerType === 'permanent' ? null : (
// Disable overlay if sidebar is permanent or not overlayEnabled
drawerType === 'permanent' || !overlayEnabled ? null : (
<Overlay
progress={progress}
onPress={() => this.toggleDrawer(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function Drawer({
onTransitionStart,
onTransitionEnd,
open,
overlayEnabled,
overlayStyle,
overlayAccessibilityLabel,
statusBarAnimation,
Expand Down Expand Up @@ -395,7 +396,7 @@ export function Drawer({
>
{children}
</View>
{drawerType !== 'permanent' ? (
{drawerType !== 'permanent' && overlayEnabled ? (
<Overlay
progress={progress}
onPress={() => toggleDrawer(false)}
Expand Down

0 comments on commit 1ae0752

Please sign in to comment.