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

Commit

Permalink
fix: use header height from style if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Oct 16, 2019
1 parent 0ee7bc5 commit 90a72fa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/views/Stack/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ const ANIMATED_ONE = new Animated.Value(1);
const getFloatingHeaderHeights = (
routes: NavigationRoute[],
insets: EdgeInsets | null,
descriptors: SceneDescriptorMap,
layout: Layout,
previous: { [key: string]: number }
) => {
const defaultHeaderHeight = getDefaultHeaderHeight(layout, insets);

return routes.reduce(
(acc, curr) => {
acc[curr.key] = previous[curr.key] || defaultHeaderHeight;
const { options = {} } = descriptors[curr.key] || {};
const { height = previous[curr.key] } = StyleSheet.flatten(
options.headerStyle || {}
);

acc[curr.key] = typeof height === 'number' ? height : defaultHeaderHeight;

return acc;
},
Expand Down Expand Up @@ -202,6 +208,7 @@ export default class Stack extends React.Component<Props, State> {
floatingHeaderHeights: getFloatingHeaderHeights(
props.routes,
props.insets,
state.descriptors,
state.layout,
state.floatingHeaderHeights
),
Expand Down Expand Up @@ -234,15 +241,16 @@ export default class Stack extends React.Component<Props, State> {

const layout = { width, height };

this.setState({
this.setState(state => ({
layout,
floatingHeaderHeights: getFloatingHeaderHeights(
this.props.routes,
this.props.insets,
state.descriptors,
layout,
{}
),
});
}));
};

private handleFloatingHeaderLayout = ({
Expand Down

0 comments on commit 90a72fa

Please sign in to comment.