-
Notifications
You must be signed in to change notification settings - Fork 176
/
Row.js
69 lines (59 loc) · 1.33 KB
/
Row.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, { PureComponent } from 'react';
import {
StyleSheet,
View,
} from 'react-native';
import PropTypes from 'prop-types';
import ImageItem from './ImageItem';
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
flex: 1,
},
});
class Row extends PureComponent {
constructor(props) {
super(props);
this.renderImage = this.renderImage.bind(this);
}
renderImage(item, isSelected) {
const {
imageMargin,
selectedMarker,
imagesPerRow,
containerWidth,
} = this.props;
const { uri } = item.node.image;
return (
<ImageItem
key={uri}
item={item}
selected={isSelected}
imageMargin={imageMargin}
selectedMarker={selectedMarker}
imagesPerRow={imagesPerRow}
containerWidth={containerWidth}
onClick={this.props.selectImage}
/>
);
}
render() {
const items = this.props.rowData.map((item, index) => {
if (item === null) {
return null;
}
return this.renderImage(item, this.props.isSelected[index]);
});
return (
<View style={styles.row}>
{items}
</View>
);
}
}
Row.propTypes = {
rowData: PropTypes.array.isRequired,
isSelected: PropTypes.array.isRequired,
selectImage: PropTypes.func.isRequired,
};
export default Row;