forked from software-mansion/react-native-screens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: correct measure with native header (software-mansion#2028)
## Description PR adding the `getContentOriginOffset` to Screen's `ShadowNode` in order to account for native header on both platforms. It seems like for the different screen orientations don't work correctly on `Android` so it needs to be investigated too. It also adds `ModalScreen` concept for now only to have different shadow node there. We need it for different traits since the non-modal Screen can be placed below some other views, so it should not be treated as the root of the view hierarchy by yoga. ## Changes - Added new prop to `Screen`'s state which is used in `getContentOriginOffset` method which is in turn used by `LayoutableShadowNode` when adding offsets to elements: https://github.com/facebook/react-native/blob/8da1da2e7320e23341e024a855e87c4762b220cc/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp#L54. - Added `ModalScreen`
- Loading branch information
Showing
28 changed files
with
459 additions
and
236 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,54 @@ | ||
|
||
import React from 'react'; | ||
import { Button, SafeAreaView, View } from 'react-native'; | ||
|
||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const TestScreen = ({ navigation }): React.JSX.Element => { | ||
return ( | ||
<SafeAreaView> | ||
<Button | ||
title={ | ||
'Click me and drag around a bit and I should log something still' | ||
} | ||
onPress={() => { | ||
console.log(Date.now()); | ||
}} | ||
/> | ||
<Button | ||
title={'Navigate to modal'} | ||
onPress={() => { | ||
navigation.navigate('Test2'); | ||
}} | ||
/> | ||
</SafeAreaView> | ||
); | ||
}; | ||
function App(): React.JSX.Element { | ||
return ( | ||
<> | ||
<View style={{ width: 100, height: 200, backgroundColor: 'red' }} /> | ||
<NavigationContainer> | ||
<Stack.Navigator | ||
initialRouteName="Test" | ||
screenOptions={{ presentation: 'modal' }}> | ||
<Stack.Screen | ||
name="Test" | ||
component={TestScreen} | ||
options={{ headerShown: true }} | ||
/> | ||
<Stack.Screen | ||
name="Test2" | ||
component={TestScreen} | ||
options={{ headerShown: false }} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
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
Oops, something went wrong.