fix: provide route context to header and bottom tabs

This commit is contained in:
Satyajit Sahoo
2020-02-11 15:42:00 +01:00
parent 6c6102b459
commit b6e7e08b9a
2 changed files with 56 additions and 50 deletions

View File

@@ -2,6 +2,7 @@ import * as React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import {
NavigationContext,
NavigationRouteContext,
Route,
ParamListBase,
} from '@react-navigation/native';
@@ -119,35 +120,37 @@ export default function HeaderContainer({
key={scene.route.key}
value={scene.descriptor.navigation}
>
<View
onLayout={
onContentHeightChange
? e =>
onContentHeightChange({
route: scene.route,
height: e.nativeEvent.layout.height,
})
: undefined
}
pointerEvents={isFocused ? 'box-none' : 'none'}
accessibilityElementsHidden={!isFocused}
importantForAccessibility={
isFocused ? 'auto' : 'no-hide-descendants'
}
style={
mode === 'float' || options.headerTransparent
? styles.header
: null
}
>
{options.headerShown !== false ? (
options.header !== undefined ? (
options.header(props)
) : (
<Header {...props} />
)
) : null}
</View>
<NavigationRouteContext.Provider value={scene.route}>
<View
onLayout={
onContentHeightChange
? e =>
onContentHeightChange({
route: scene.route,
height: e.nativeEvent.layout.height,
})
: undefined
}
pointerEvents={isFocused ? 'box-none' : 'none'}
accessibilityElementsHidden={!isFocused}
importantForAccessibility={
isFocused ? 'auto' : 'no-hide-descendants'
}
style={
mode === 'float' || options.headerTransparent
? styles.header
: null
}
>
{options.headerShown !== false ? (
options.header !== undefined ? (
options.header(props)
) : (
<Header {...props} />
)
) : null}
</View>
</NavigationRouteContext.Provider>
</NavigationContext.Provider>
);
})}