AllBrandListCell.js
1.97 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
93
94
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
const {
StyleSheet,
Text,
View,
Image,
Dimensions,
TouchableOpacity,
} = ReactNative;
export default class AllBrandListCell extends React.Component {
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.rowData, this.props.rowData)) {
return false;
} else {
return true;
}
}
render() {
let data = this.props.rowData;
let name = data.get('brand_name');
let is_hot = data.get('is_hot');
let is_show_new = data.get('is_show_new');
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressSlideItem && this.props.onPressSlideItem(this.props.rowData.toJS());
}}>
<View style={styles.rowTitle}>
<Text style={styles.rowText}>{name}</Text>
{is_show_new=='Y' ? <View style={styles.new}><Text style={styles.text}>NEW</Text></View> : null}
{is_hot=='Y' ? <View style={styles.hot}><Text style={styles.text}>HOT</Text></View> : null}
</View>
</TouchableOpacity>
);
}
};
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
rowText: {
textAlign: 'left',
fontSize: 14,
marginLeft:10,
},
rowTitle: {
flexDirection: 'row',
alignItems: 'center',
height: 44,
width,
backgroundColor: 'white',
borderBottomColor: '#e5e5e5',
borderBottomWidth: 0.5,
borderBottomLeftRadius: 10,
borderBottomRightRadius: 20,
},
text: {
textAlign: 'left',
fontSize: 10,
color: 'white',
fontWeight: 'bold',
},
hot: {
alignItems: 'center',
height: 15,
width: 30,
backgroundColor: 'red',
marginLeft: 10,
justifyContent: 'center',
borderRadius: 30,
},
new: {
alignItems: 'center',
height: 15,
width: 30,
backgroundColor: 'green',
marginLeft: 10,
justifyContent: 'center',
borderRadius: 50,
},
});