Skip to content

Commit

Permalink
feat: adds foreground props to predefined headers
Browse files Browse the repository at this point in the history
  • Loading branch information
IdaszakDaniel committed May 17, 2021
1 parent cb668bf commit d5d3c04
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/predefinedComponents/DetailsHeader/DetailsHeader.js
Expand Up @@ -60,7 +60,7 @@ class DetailsHeader extends React.Component {
);
};

renderForeground = (user) => {
renderDetailsForeground = (user) => () => {
const { labelColor } = user;
const { image, title, tag, iconNumber } = this.props;
const labelOpacity = this.scrollY.y.interpolate({
Expand Down Expand Up @@ -105,6 +105,13 @@ class DetailsHeader extends React.Component {
);
};

renderForeground = (user) => {
const { foreground } = this.props;
const renderForeground = foreground || this.renderDetailsForeground(user);

return renderForeground(user);
};

renderBackground = () => {
const { hasBorderRadius, backgroundColor } = this.props;
const {
Expand Down Expand Up @@ -142,7 +149,7 @@ class DetailsHeader extends React.Component {
snapToEdge,
bounces,
parallaxHeight,
transparentHeader
transparentHeader,
} = this.props;

if (renderBody) {
Expand Down Expand Up @@ -193,6 +200,7 @@ DetailsHeader.propTypes = {
iconNumber: number,
parallaxHeight: number,
transparentHeader: bool,
foreground: func
};
DetailsHeader.defaultProps = {
leftTopIconOnPress: () => {},
Expand Down
15 changes: 12 additions & 3 deletions src/predefinedComponents/TabbedHeader/TabbedHeader.js
@@ -1,5 +1,5 @@
import React from 'react';
import { Text, View, Image, StatusBar, Animated, ViewPropTypes } from 'react-native';
import { Text, View, Image, StatusBar, Animated, ViewPropTypes, ScrollView } from 'react-native';
import { arrayOf, bool, number, shape, string, func, node, element, oneOfType, oneOf, instanceOf } from 'prop-types';
import StickyParallaxHeader from '../../StickyParallaxHeader';
import { constants, colors, sizes } from '../../constants';
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class TabbedHeader extends React.Component {
return renderHeader();
};

renderForeground = (scrollY) => {
renderTabbedForeground = (scrollY) => () => {
const { title, titleStyle, foregroundImage } = this.props;
const messageStyle = titleStyle || styles.message;
const startSize = constants.responsiveWidth(18);
Expand Down Expand Up @@ -109,6 +109,13 @@ export default class TabbedHeader extends React.Component {
);
};

renderForeground = (scrollY) => {
const { foreground } = this.props;
const renderForeground = foreground || this.renderTabbedForeground(scrollY);

return renderForeground();
};

onLayoutContent = (e, title) => {
const { contentHeight } = this.state;
const contentHeightTmp = { ...contentHeight };
Expand Down Expand Up @@ -163,7 +170,8 @@ export default class TabbedHeader extends React.Component {
contentContainerStyles,
refreshControl,
rememberTabScrollPosition,
parallaxHeight
parallaxHeight,
transparentHeader
} = this.props;

if (renderBody) {
Expand Down Expand Up @@ -241,6 +249,7 @@ TabbedHeader.propTypes = {
onRef: func,
parallaxHeight: number,
transparentHeader: bool,
foreground: func
};

TabbedHeader.defaultProps = {
Expand Down

0 comments on commit d5d3c04

Please sign in to comment.