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

Commit

Permalink
feat: support transform style for header (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy03h authored and satya164 committed Nov 4, 2019
1 parent 57b411c commit a93a81e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/stack/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ export type StackHeaderOptions = {
* This is useful for using backgrounds such as an image or a gradient.
* You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
*/
headerBackground?: () => React.ReactNode;
headerBackground?: (props: {
style: StyleProp<ViewStyle>;
}) => React.ReactNode;
/**
* Style object for the header. You can specify a custom background color here, for example.
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/stack/src/views/Header/HeaderSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
shadowOpacity,
shadowRadius,
opacity,
transform,
...unsafeStyles
} = StyleSheet.flatten(customHeaderStyle || {}) as ViewStyle;

Expand Down Expand Up @@ -263,6 +264,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
shadowOpacity,
shadowRadius,
opacity,
transform,
};

// Setting a property to undefined triggers default style
Expand Down Expand Up @@ -301,14 +303,14 @@ export default class HeaderSegment extends React.Component<Props, State> {
style={[StyleSheet.absoluteFill, backgroundStyle]}
>
{headerBackground ? (
headerBackground()
headerBackground({ style: safeStyles })
) : headerTransparent ? null : (
<HeaderBackground style={safeStyles} />
)}
</Animated.View>
<Animated.View
pointerEvents="box-none"
style={[{ height, minHeight, maxHeight, opacity }]}
style={[{ height, minHeight, maxHeight, opacity, transform }]}
>
<View pointerEvents="none" style={{ height: insets.top }} />
<View pointerEvents="box-none" style={styles.content}>
Expand Down

0 comments on commit a93a81e

Please sign in to comment.