Skip to content

Commit

Permalink
Add scrollViewBackgroundColor props
Browse files Browse the repository at this point in the history
  • Loading branch information
Nhacsam committed Feb 4, 2018
1 parent 72e2806 commit c9b5e6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -76,6 +76,7 @@ The `HeaderImageScrollView` handle also the following props. None is required :
| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| `ScrollViewComponent` | `Component` | `ScrollView` | The component to be used for scrolling. Can be any component with an `onScroll` props (ie. `ListView`, `FlatList`, `SectionList` or `ScrollView`) |
| `scrollViewBackgroundColor` | `string` | `white` | Background color of the scrollView content |


### TriggeringView
Expand Down
14 changes: 12 additions & 2 deletions src/ImageHeaderScrollView.js
Expand Up @@ -27,6 +27,7 @@ export type Props = ScrollViewProps & {
renderHeader: () => React$Element<any>,
renderTouchableFixedForeground?: ?() => React$Element<any>,
ScrollViewComponent: React$ComponentType<ScrollViewProps>,
scrollViewBackgroundColor: string,
};

export type DefaultProps = {
Expand All @@ -40,6 +41,7 @@ export type DefaultProps = {
renderFixedForeground: () => React$Element<any>,
renderHeader: () => React$Element<any>,
ScrollViewComponent: React$ComponentType<ScrollViewProps>,
scrollViewBackgroundColor: string,
};

export type State = {
Expand All @@ -65,6 +67,7 @@ class ImageHeaderScrollView extends Component<Props, State> {
renderFixedForeground: () => <View />,
renderHeader: () => <View />,
ScrollViewComponent: ScrollView,
scrollViewBackgroundColor: 'white',
};

constructor(props: Props) {
Expand Down Expand Up @@ -206,6 +209,7 @@ class ImageHeaderScrollView extends Component<Props, State> {
contentContainerStyle,
onScroll,
ScrollViewComponent,
scrollViewBackgroundColor,
...scrollViewProps
} = this.props;
/* eslint-enable no-unused-vars */
Expand All @@ -214,7 +218,13 @@ class ImageHeaderScrollView extends Component<Props, State> {

return (
<View
style={[styles.container, { paddingTop: minHeight }]}
style={[
styles.container,
{
paddingTop: minHeight,
backgroundColor: scrollViewBackgroundColor,
},
]}
ref={ref => (this.container = ref)}
onLayout={this.onContainerLayout}
>
Expand All @@ -226,7 +236,7 @@ class ImageHeaderScrollView extends Component<Props, State> {
{...scrollViewProps}
contentContainerStyle={[
{
backgroundColor: 'white',
backgroundColor: scrollViewBackgroundColor,
marginTop: inset,
paddingBottom: inset,
},
Expand Down

0 comments on commit c9b5e6d

Please sign in to comment.