-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageView.js
61 lines (50 loc) · 1.47 KB
/
ImageView.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
import React, {Component} from 'react'
import {
Image,
StyleSheet,
Dimensions,
TouchableOpacity,
} from 'react-native'
export default class ImageItem extends Component {
static defaultProps = {
item: {},
selected: false,
}
static propTypes = {
item: React.PropTypes.object.isRequired,
selected: React.PropTypes.bool.isRequired,
selectedMarker: React.PropTypes.element,
columnWidth: React.PropTypes.number.isRequired,
onClick: React.PropTypes.func,
}
render() {
let {item, selected, selectedMarker, columnWidth } = this.props
let marker = selectedMarker ? selectedMarker :
<Image
style={[styles.marker, {width: 25, height: 25}]}
source={require('./selected.png')}
/>
let image = item.node.image
return (
<TouchableOpacity
onPress={this._handleClick.bind(this, image)}>
<Image
source={{uri: image.uri}}
style={{margin: 1, height: columnWidth - 2, width: columnWidth - 2,}} >
{ (selected) ? marker : null }
</Image>
</TouchableOpacity>
)
}
_handleClick(item) {
this.props.onClick(item)
}
}
const styles = StyleSheet.create({
marker: {
position: 'absolute',
top: 5,
right: 5,
backgroundColor: 'transparent',
},
})