-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSectionListGrid.js
More file actions
39 lines (38 loc) · 1.37 KB
/
Copy pathSectionListGrid.js
File metadata and controls
39 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react';
import { View, Text } from 'react-native';
export default SectionListGrid = (props) => {
return (
<View style={props.listStyle}>
{
props.data.map((obj, index) =>
<View style={props.cellStyle} key={'obj' + index}>
{props.renderHeader(obj, index, props.headerStyle)}
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
{
obj?.data.map((subObj, subIndex) =>
<View style={[{ width: 100 / props.numItemsRow + '%' }, props.itemViewStyle]} key={'sub' + subIndex}>
{props.renderItem(subObj, subIndex)}
</View>
)
}
</View>
</View>
)
}
</View>
);
};
SectionListGrid.defaultProps = {
data: [],
numItemsRow: 3,
itemViewStyle: {},
listStyle: {},
cellStyle: {},
headerStyle: {},
renderItem: (subObj, subIndex) => {
return <Text style={{ margin: 5 }} key={subIndex}>{subObj}</Text>
},
renderHeader: (obj, index, headerStyle) => {
return <Text style={[{ margin: 5 }, headerStyle]}>{obj.title}</Text>
}
}