-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove touch disabling in header corners (#1157)
PR fixing the behavior of cutting the hit area of the corners of the header when the headerLeft/headerRight components are provided. It overrides the default method and checks directly if the point is inside one of header subviews.
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from 'react'; | ||
import {Button, View, TouchableOpacity} from 'react-native'; | ||
import {NavigationContainer, ParamListBase} from '@react-navigation/native'; | ||
import {createNativeStackNavigator, NativeStackNavigationProp} from 'react-native-screens/native-stack'; | ||
|
||
function First({ | ||
navigation, | ||
}: { | ||
navigation: NativeStackNavigationProp<ParamListBase>; | ||
}) { | ||
return ( | ||
<View style={{flex: 1, backgroundColor: 'red'}}> | ||
<Button | ||
title="Tap me for second screen" | ||
onPress={() => navigation.navigate('Second')} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
function Second({ | ||
navigation, | ||
}: { | ||
navigation: NativeStackNavigationProp<ParamListBase>; | ||
}) { | ||
return ( | ||
<View style={{flex: 1, backgroundColor: 'yellow'}}> | ||
<Button title="Tap me for first screen" onPress={() => navigation.goBack()} /> | ||
</View> | ||
); | ||
} | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const ButtonWithBiggerChild = () => ( | ||
<TouchableOpacity style={{width: 30, height: 30, backgroundColor: 'red'}} onPress={() => console.log("hello")}> | ||
<View style={{width: 30, height: 30, backgroundColor: 'yellow', marginLeft: -15}}/> | ||
</TouchableOpacity> | ||
); | ||
|
||
export default function App() { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator screenOptions={{stackPresentation: 'modal'}}> | ||
<Stack.Screen name="First" component={First} | ||
options={{headerShown: true, | ||
// headerLeft: () => <TouchableOpacity onPress={() => console.log("hello")} style={{width: 30, height: 30, backgroundColor: 'red', marginLeft: -15}}/>, | ||
headerLeft: () => <ButtonWithBiggerChild />, | ||
headerRight: () => <TouchableOpacity onPress={() => console.log("there")} style={{width: 30, height: 30, backgroundColor: 'red', marginRight: -15}}/>, | ||
}} | ||
/> | ||
<Stack.Screen | ||
name="Second" | ||
component={Second} | ||
options={{ | ||
headerLeft: () => <TouchableOpacity onPress={() => console.log("hello")} style={{width: 50, height: 50, backgroundColor: 'red', marginLeft: -15}}/> | ||
}} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters