I've been looking for a way to disable edge-swipe open of a Drawer. When using horizontal lists, it's accidentally open the Drawer instead of scrolling the list across.
Please check my bellow code:
<Drawer.Navigator
screenOptions={{
swipeEdgeWidth: 0,
}}
drawerContent={(props) => <Menu props={props} />}>
<Drawer.Screen
name="screenWithDrawer1"
options={{
swipeEnabled: false,
unmountOnBlur: true,
headerShown: true,
drawerItemStyle: { display: "none" },
drawerIcon: ({ color }) => (
<FontAwesome5 name="calculator" size={20} color={color} />
),
drawerLabel: 'Purchase Menu',
drawerLabelStyle: { fontSize: 16, paddingLeft: 6 },
title: "Purchase Menu",
headerTitleAlign: 'center',
headerStyle: { backgroundColor: '#f5a756' }
}}
>
{() => (
<Stack.Navigator initialRouteName='purchasemenu'
>
<Stack.Screen
name='purchasemenu'
component={Purchasemenu}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseOrdersList'
component={PurchaseOrdersList}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseWareHouse'
component={PurchaseWareHouse}
options={{ header: () => null }}
/>
<Stack.Screen
name='settings'
component={Settings}
options={{ header: () => null }}
/>
</Stack.Navigator>
)}
</Drawer.Screen>
</Drawer.Navigator>
I have set
swipeEnabled: false
but it's not working.
If anyone can help me I will be grateful.
I've been looking for a way to disable edge-swipe open of a Drawer. When using horizontal lists, it's accidentally open the Drawer instead of scrolling the list across.
Please check my bellow code:
<Drawer.Navigator
screenOptions={{
swipeEdgeWidth: 0,
}}
drawerContent={(props) => <Menu props={props} />}>
<Drawer.Screen
name="screenWithDrawer1"
options={{
swipeEnabled: false,
unmountOnBlur: true,
headerShown: true,
drawerItemStyle: { display: "none" },
drawerIcon: ({ color }) => (
<FontAwesome5 name="calculator" size={20} color={color} />
),
drawerLabel: 'Purchase Menu',
drawerLabelStyle: { fontSize: 16, paddingLeft: 6 },
title: "Purchase Menu",
headerTitleAlign: 'center',
headerStyle: { backgroundColor: '#f5a756' }
}}
>
{() => (
<Stack.Navigator initialRouteName='purchasemenu'
>
<Stack.Screen
name='purchasemenu'
component={Purchasemenu}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseOrdersList'
component={PurchaseOrdersList}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseWareHouse'
component={PurchaseWareHouse}
options={{ header: () => null }}
/>
<Stack.Screen
name='settings'
component={Settings}
options={{ header: () => null }}
/>
</Stack.Navigator>
)}
</Drawer.Screen>
</Drawer.Navigator>
I have set
swipeEnabled: false
but it's not working.
If anyone can help me I will be grateful.
Share Improve this question asked Nov 19, 2024 at 8:35 user28353622user283536222 Answers
Reset to default 0There are multiple ways you can resolve this issue
- disable swipe & gestures for the screen with the horizontal carousel
<Drawer.Screen name="screenWithDrawer1"
options={{
swipeEnabled: false, // Disable swipe for this screen
gestureEnabled: false, // disable gestures for this screen
// Other options... }} >
{/* Screen Content */}
</Drawer.Screen>
- Increase your swipe edge & see if this takes effect
<Drawer.Navigator
screenOptions={{ swipeEdgeWidth: 1, // Minimum swipe edge width }}
drawerContent={(props) =>
<Menu props={props} />
}> {/* Other configurations */}
</Drawer.Navigator>
Please try with bellow code
useEffect(() => {
const onBackPress = () => {
return true;
};
const backHandler = BackHandler.addEventListener(
'hardwareBackPress',
onBackPress
);
return () => backHandler.remove();
}, []);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745574113a4633857.html
评论列表(0条)