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:
Koen Punt
2017-04-28 11:59:18 +02:00
committed by Satyajit Sahoo
parent 31ee86ad5c
commit ff99d6ec0a
2 changed files with 4 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ export type HeaderProps = NavigationSceneRendererProps & {
getScreenDetails: (
NavigationScene,
) => NavigationScreenDetails<NavigationStackScreenOptions>,
style: Style,
};
/**

View File

@@ -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>