Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance User Interaction with Customizable hitSlop on DrawerToggleButton #11781

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/drawer/src/views/DrawerToggleButton.tsx
Expand Up @@ -5,7 +5,7 @@ import {
useNavigation,
} from '@react-navigation/native';
import * as React from 'react';
import { Image, Platform, StyleSheet } from 'react-native';
import { Image, type Insets, Platform, StyleSheet } from 'react-native';

import type { DrawerNavigationProp } from '../types';

Expand All @@ -14,6 +14,7 @@ type Props = {
pressColor?: string;
pressOpacity?: number;
tintColor?: string;
hitSlop?: null | Insets | number | undefined;
};

export function DrawerToggleButton({ tintColor, ...rest }: Props) {
Expand All @@ -25,10 +26,13 @@ export function DrawerToggleButton({ tintColor, ...rest }: Props) {
android_ripple={{ borderless: true }}
onPress={() => navigation.dispatch(DrawerActions.toggleDrawer())}
style={styles.touchable}
hitSlop={Platform.select({
ios: undefined,
default: { top: 16, right: 16, bottom: 16, left: 16 },
})}
hitSlop={
rest?.hitSlop ||
Platform.select({
ios: { top: 16, right: 16, bottom: 0, left: 0 },
default: { top: 16, right: 16, bottom: 16, left: 16 },
})
}
>
<Image
style={[styles.icon, tintColor ? { tintColor } : null]}
Expand Down