mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-06 22:39:41 +08:00
accept style prop on Header component
to allow composition of the Header component when using a custom header component, styling is probably one of the options you want to have. For example, I need to dynamicly change the height of the header based on scroll position, and without this change I have to inherit from the Header component and copy the render function, instead of composing the Header component in my own component.
This commit is contained in:
committed by
Satyajit Sahoo
parent
31ee86ad5c
commit
ff99d6ec0a
@@ -14,6 +14,7 @@ export type HeaderProps = NavigationSceneRendererProps & {
|
||||
getScreenDetails: (
|
||||
NavigationScene,
|
||||
) => NavigationScreenDetails<NavigationStackScreenOptions>,
|
||||
style: Style,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -284,14 +284,15 @@ class Header extends React.PureComponent<void, HeaderProps, HeaderState> {
|
||||
position,
|
||||
screenProps,
|
||||
progress,
|
||||
style,
|
||||
...rest
|
||||
} = this.props;
|
||||
|
||||
const { options } = this.props.getScreenDetails(scene, screenProps);
|
||||
const style = options.headerStyle;
|
||||
const headerStyle = options.headerStyle;
|
||||
|
||||
return (
|
||||
<Animated.View {...rest} style={[styles.container, style]}>
|
||||
<Animated.View {...rest} style={[styles.container, headerStyle, style]}>
|
||||
<View style={styles.appBar}>
|
||||
{appBar}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user