Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
feat: add headerBackgroundStyle option
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 18, 2019
1 parent 27c4861 commit 2ea0912
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/stack/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type HeaderOptions = {
headerBackImage?: HeaderBackButtonProps['backImage'];
headerPressColorAndroid?: string;
headerBackground?: () => React.ReactNode;
headerBackgroundStyle?: StyleProp<ViewStyle>;
headerStyle?: StyleProp<ViewStyle>;
headerStatusBarHeight?: number;
};
Expand Down
27 changes: 13 additions & 14 deletions packages/stack/src/views/Header/HeaderSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export const getDefaultHeaderHeight = (layout: Layout) => {
};

export default class HeaderSegment extends React.Component<Props, State> {
static defaultProps = {
headerBackground: () => <HeaderBackground />,
};

state: State = {};

private handleTitleLayout = (e: LayoutChangeEvent) => {
Expand Down Expand Up @@ -124,10 +120,11 @@ export default class HeaderSegment extends React.Component<Props, State> {
headerLeft: left = (props: HeaderBackButtonProps) => (
<HeaderBackButton {...props} />
),
headerBackground,
headerStatusBarHeight = getStatusBarHeight(layout.width > layout.height),
headerTintColor,
headerBackground,
headerBackgroundStyle,
// @ts-ignore
headerStatusBarHeight = getStatusBarHeight(layout.width > layout.height),
headerRight: right,
headerBackImage: backImage,
headerBackTitle: leftLabel,
Expand Down Expand Up @@ -163,14 +160,16 @@ export default class HeaderSegment extends React.Component<Props, State> {

return (
<React.Fragment>
{headerBackground ? (
<Animated.View
pointerEvents="none"
style={[StyleSheet.absoluteFill, backgroundStyle]}
>
{headerBackground()}
</Animated.View>
) : null}
<Animated.View
pointerEvents="none"
style={[StyleSheet.absoluteFill, backgroundStyle]}
>
{headerBackground ? (
headerBackground()
) : (
<HeaderBackground style={headerBackgroundStyle} />
)}
</Animated.View>
<View pointerEvents="none" style={{ height: headerStatusBarHeight }} />
<View pointerEvents="box-none" style={styles.container}>
{onGoBack ? (
Expand Down

0 comments on commit 2ea0912

Please sign in to comment.