NewHotBannerListCell.js
2.19 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import {getSlicedUrl} from '../../utils/Utils';
import Immutable, {Map} from 'immutable';
const {
StyleSheet,
Text,
View,
Image,
Dimensions,
TouchableOpacity,
PixelRatio,
} = ReactNative;
export default class NewHotBannerListCell extends React.Component {
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.rowData, this.props.rowData)) {
return false;
} else {
return true;
}
}
render() {
let rowData = this.props.rowData;
let newSrc = getSlicedUrl(rowData.get('brand_ico'), width, height, 2);
let name = rowData.get('brand_name');
let yh_exposureData = this.props.yh_exposureData?this.props.yh_exposureData:null;
if (yh_exposureData) {
yh_exposureData = {
BRAND_ID: rowData.get('id')?rowData.get('id'):'0',
...yh_exposureData,
};
}
return (
<TouchableOpacity style={{overflow:'hidden'}} yh_exposureData={yh_exposureData} activeOpacity={0.5} onPress={() => {
this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.toJS());
}}>
<View style={styles.rowContainer}>
<Image
source={{uri: newSrc}}
style={styles.thumbnail}
resizeMode={'contain'}
>
</Image>
<View style={styles.itemTitle}>
<Text style={styles.itemText} numberOfLines={1}>{name}</Text>
</View>
</View>
</TouchableOpacity>
);
}
};
let width = Math.ceil((Dimensions.get('window').width - 40) / 3);
let height = width - 40;
let styles = StyleSheet.create({
thumbnail: {
width: width,
height: height,
marginLeft: 10,
marginTop: 20,
backgroundColor: 'white',
},
itemTitle: {
justifyContent: 'center',
height: 30,
width: width,
marginLeft: 10,
backgroundColor: 'white',
},
itemText: {
fontWeight: 'bold',
textAlign: 'center',
color: 'gray',
fontSize: 10,
},
rowContainer: {
backgroundColor:'white',
overflow:'hidden',
},
});