mirror of
https://github.com/zhigang1992/react-native-super-grid.git
synced 2026-01-12 17:42:52 +08:00
Added itemContainerStyle prop
This commit is contained in:
@@ -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
7
index.d.ts
vendored
@@ -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
|
||||
|
||||
10
index.js
10
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) => (
|
||||
<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 };
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user