mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-26 13:35:32 +08:00
fix: provide navigation prop in header
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
import { NavigationRoute } from 'react-navigation';
|
||||
import { NavigationContext, NavigationRoute } from 'react-navigation';
|
||||
import {
|
||||
Layout,
|
||||
HeaderScene,
|
||||
@@ -88,36 +88,40 @@ export default function HeaderContainer({
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
<NavigationContext.Provider
|
||||
key={scene.route.key}
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
? e =>
|
||||
onContentHeightChange({
|
||||
route: scene.route,
|
||||
height: e.nativeEvent.layout.height,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
pointerEvents="box-none"
|
||||
accessibilityElementsHidden={!isFocused}
|
||||
importantForAccessibility={
|
||||
isFocused ? 'auto' : 'no-hide-descendants'
|
||||
}
|
||||
style={
|
||||
mode === 'float' || options.headerTransparent
|
||||
? styles.header
|
||||
: null
|
||||
}
|
||||
value={scene.descriptor.navigation}
|
||||
>
|
||||
{options.header !== undefined ? (
|
||||
options.header === null ? null : (
|
||||
options.header(props)
|
||||
)
|
||||
) : (
|
||||
<Header {...props} />
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
? e =>
|
||||
onContentHeightChange({
|
||||
route: scene.route,
|
||||
height: e.nativeEvent.layout.height,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
pointerEvents="box-none"
|
||||
accessibilityElementsHidden={!isFocused}
|
||||
importantForAccessibility={
|
||||
isFocused ? 'auto' : 'no-hide-descendants'
|
||||
}
|
||||
style={
|
||||
mode === 'float' || options.headerTransparent
|
||||
? styles.header
|
||||
: null
|
||||
}
|
||||
>
|
||||
{options.header !== undefined ? (
|
||||
options.header === null ? null : (
|
||||
options.header(props)
|
||||
)
|
||||
) : (
|
||||
<Header {...props} />
|
||||
)}
|
||||
</View>
|
||||
</NavigationContext.Provider>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user