Added itemContainerStyle prop

This commit is contained in:
Carlo Lucadei
2018-07-19 14:33:16 +02:00
parent 7d8e6163a8
commit 78f86e3d0a
4 changed files with 17 additions and 5 deletions

View File

@@ -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

7
index.d.ts vendored
View File

@@ -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<ItemType = any> {
*/
style?: StyleProp<ScrollViewStyle>;
/**
* Specifies the style about content row view
*/
itemContainerStyle?: StyleProp<ViewStyle>;
/**
* Specifies a static width or height for the GridView container.
* If your container dimension is known or can be calculated at runtime

View File

@@ -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) => (
<View key={`${data.key}_${i}`} style={itemContainerStyle}>
<View style={itemStyle}>
{this.props.renderItem(item, i + (data.rowNumber * itemsPerRow))}
{this.props.renderItem(item, i + (data.rowNumber * itemsPerRow))}
</View>
</View>
))}
@@ -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 };

View File

@@ -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",