SingleNameImage.js
1.89 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
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
70
71
72
73
74
75
76
77
78
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import HeadTitleCell from '../cell/HeadTitleCell';
import YH_Image from '../../../common/components/YH_Image';
import Immutable, {Map} from 'immutable';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Platform,
} = ReactNative;
export default class SingleNameImage extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.data, this.props.data)) {
return false;
} else {
return true;
}
}
render() {
let {data} = this.props;
if (!data || data.size == 0) {
return null;
}
let title = data.get('title');
let imageUrl = YH_Image.getSlicedUrl(data.get(0).get('src'), width, imageHeight, 2);
return (
<View style={styles.container}>
<HeadTitleCell title={title} />
<TouchableOpacity
activeOpacity={1}
yh_exposureData={data.get(0).get('yh_exposureData')}
onPress={() => {
this.props.onPressSlideItem && this.props.onPressSlideItem(data.get(0).get('url'), imageUrl, 0);
}}
>
<YH_Image
url={imageUrl}
style={styles.image}
/>
</TouchableOpacity>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let imageHeight = Math.ceil(100 * DEVICE_WIDTH_RATIO);
let styles = StyleSheet.create({
container: {
width: width,
height: imageHeight + 40,
flexDirection: 'column',
},
image: {
width: width,
height: imageHeight,
},
});