From 78f86e3d0abab1b03b484aeab6e138f38f57d9ba Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Thu, 19 Jul 2018 14:33:16 +0200 Subject: [PATCH] Added itemContainerStyle prop --- README.md | 3 +++ index.d.ts | 7 ++++++- index.js | 10 +++++++--- package.json | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f59bb1a..d2b44f0 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,9 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Changelog +### [2.4.2] - 2018-07-19 +- Add itemContainerStyle prop + ### [2.4.1] - 2018-07-07 - Add onLayout prop @ataillefer diff --git a/index.d.ts b/index.d.ts index 0c61a8b..41b16e5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import { ScrollViewStyle, SectionListData, StyleProp } from "react-native"; +import { ScrollViewStyle, ViewStyle, SectionListData, StyleProp } from "react-native"; /** * React Native Super Grid Properties @@ -35,6 +35,11 @@ export interface SuperGridProps { */ style?: StyleProp; + /** + * Specifies the style about content row view + */ + itemContainerStyle?: StyleProp; + /** * Specifies a static width or height for the GridView container. * If your container dimension is known or can be calculated at runtime diff --git a/index.js b/index.js index f78ac97..3e0ddbd 100644 --- a/index.js +++ b/index.js @@ -76,8 +76,9 @@ class SuperGrid extends Component { justifyContent: 'center', height: containerDimension, paddingBottom: spacing, + ...this.props.itemContainerStyle }; - let itemStyle = { }; + let itemStyle = {}; if (fixed) { itemStyle = { height: itemDimension, @@ -91,7 +92,7 @@ class SuperGrid extends Component { {(data || []).map((item, i) => ( - {this.props.renderItem(item, i + (data.rowNumber * itemsPerRow))} + {this.props.renderItem(item, i + (data.rowNumber * itemsPerRow))} ))} @@ -114,6 +115,7 @@ class SuperGrid extends Component { justifyContent: 'center', width: containerDimension, paddingRight: spacing, + ...this.props.itemContainerStyle }; let itemStyle = {}; if (fixed) { @@ -184,6 +186,7 @@ SuperGrid.propTypes = { fixed: PropTypes.bool, spacing: PropTypes.number, style: ViewPropTypes.style, + itemContainerStyle: ViewPropTypes.style, staticDimension: PropTypes.number, horizontal: PropTypes.bool, onLayout: PropTypes.func, @@ -195,9 +198,10 @@ SuperGrid.defaultProps = { itemWidth: null, spacing: 10, style: {}, + itemContainerStyle: undefined, staticDimension: undefined, horizontal: false, }; export default SuperGrid; -export {SuperGridSectionList}; +export { SuperGridSectionList }; diff --git a/package.json b/package.json index 0b1c779..fd0a5d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-super-grid", - "version": "2.4.1", + "version": "2.4.2", "description": "Responsive Grid View for React Native", "main": "index.js", "types": "index.d.ts",