From 331b6a4a1aee5e25e6ca3fe1be4333b22fc45eb8 Mon Sep 17 00:00:00 2001 From: Vladislav Shabanov Date: Fri, 15 Jun 2018 22:10:43 +0700 Subject: [PATCH] Make headers of non-standard heights work correctly in StackNavigator when header is null (Fixes #4208) (#4353) * Measure header height dynamically * Add comment * StacksOverTopTabs playground example --- .../examples/NavigationPlayground/js/App.js | 6 + .../js/StacksOverTopTabs.js | 130 +++++++++ .../NavigationPlayground/package.json | 3 +- .../examples/NavigationPlayground/yarn.lock | 2 +- .../NestedNavigator-test.js.snap | 218 +++++++------- .../__snapshots__/StackNavigator-test.js.snap | 276 +++++++++--------- .../src/views/StackView/StackViewLayout.js | 31 +- 7 files changed, 411 insertions(+), 255 deletions(-) create mode 100644 packages/react-navigation/examples/NavigationPlayground/js/StacksOverTopTabs.js diff --git a/packages/react-navigation/examples/NavigationPlayground/js/App.js b/packages/react-navigation/examples/NavigationPlayground/js/App.js index 6435338e..e21c9738 100644 --- a/packages/react-navigation/examples/NavigationPlayground/js/App.js +++ b/packages/react-navigation/examples/NavigationPlayground/js/App.js @@ -26,6 +26,7 @@ import TabsInDrawer from './TabsInDrawer'; import ModalStack from './ModalStack'; import StacksInTabs from './StacksInTabs'; import StacksOverTabs from './StacksOverTabs'; +import StacksOverTopTabs from './StacksOverTopTabs'; import StacksWithKeys from './StacksWithKeys'; import InactiveStack from './InactiveStack'; import StackWithCustomHeaderBackImage from './StackWithCustomHeaderBackImage'; @@ -105,6 +106,10 @@ const ExampleInfo = { name: 'Stacks over Tabs', description: 'Nested stack navigation that pushes on top of tabs', }, + StacksOverTopTabs: { + name: 'Stacks over Top Tabs with non-standard header height', + description: 'Tab navigator in stack with custom header heights', + }, StacksWithKeys: { name: 'Link in Stack with keys', description: 'Use keys to link between screens', @@ -146,6 +151,7 @@ const ExampleRoutes = { StacksWithKeys: StacksWithKeys, StacksInTabs: StacksInTabs, StacksOverTabs: StacksOverTabs, + StacksOverTopTabs: StacksOverTopTabs, LinkStack: { screen: SimpleStack, path: 'people/Jordan', diff --git a/packages/react-navigation/examples/NavigationPlayground/js/StacksOverTopTabs.js b/packages/react-navigation/examples/NavigationPlayground/js/StacksOverTopTabs.js new file mode 100644 index 00000000..93f21868 --- /dev/null +++ b/packages/react-navigation/examples/NavigationPlayground/js/StacksOverTopTabs.js @@ -0,0 +1,130 @@ +/** + * @flow + */ + +import React from 'react'; +import { View, ScrollView, StatusBar, StyleSheet } from 'react-native'; +import { + SafeAreaView, + createStackNavigator, + createMaterialTopTabNavigator, +} from 'react-navigation'; +import { Constants } from 'expo'; +import { MaterialTopTabBar } from 'react-navigation-tabs'; + +import SampleText from './SampleText'; +import { Button } from './commonComponents/ButtonWithMargin'; + +const HEADER_HEIGHT = 64; + +const MyNavScreen = ({ navigation, banner }) => ( + + + {banner} +