BrandIntro.js
4.2 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* 潮流优选、明星原创
*/
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
ScrollView,
Text,
NativeAppEventEmitter,
StyleSheet,
Image,
Dimensions,
TouchableOpacity,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
export default class BrandIntro extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
}
render() {
let{brandIntro, brandFav}=this.props;
let detail = brandIntro.get('detail').toJS();
let favIcon = brandFav.get('isFav') ? require("../../images/red_heart.png") : require("../../images/gray_heart.png");
let titleFoldArrowIcon = brandIntro.titleUnfold ? require("../../images/arrow_small_up.png") : require("../../images/arrow_small_down.png");
return (
<View style={styles.container}>
<SlicedImage style={styles.coverImage} source={{uri: detail.cover_img}} style={{width, height:coverImageHeight}}/>
<View style={styles.titleLikeView}>
<TouchableOpacity onPress={() => {
this.props.onPressFav && this.props.onPressFav(!brandFav.get('isFav'));
}}>
<Image style={styles.like} source={favIcon} />
</TouchableOpacity>
<Text style={styles.title}>
{detail.brand_name}
</Text>
</View>
<Text style={styles.intro} numberOfLines={brandIntro.titleUnfold ? 0 : 4}>
{detail.brand_intro}
</Text>
<TouchableOpacity onPress={() => {
this.props.onPressBrandIntroMore && this.props.onPressBrandIntroMore(!brandIntro.titleUnfold);
}}>
<View style={styles.moreView}>
<Image style={styles.moreArrow} source={titleFoldArrowIcon}/>
<Text style={styles.moreText}>
{brandIntro.titleUnfold ? '收起' : 'more'}
</Text>
</View>
</TouchableOpacity>
<View style={styles.brandIcon}>
<SlicedImage resizeMode={'stretch'} source={{uri: detail.brand_ico}} style={{width:brandIconWidth-2, height:brandIconWidth-2}}/>
</View>
<View style={styles.blackView}>
</View>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let coverImageHeight = 155 * DEVICE_WIDTH_RATIO;
let brandIconWidth = 84 * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
backgroundColor: 'white',
},
coverImage: {
height: 200,
},
brandIcon: {
position: 'absolute',
top: 116 * DEVICE_WIDTH_RATIO,
left: 25 * DEVICE_WIDTH_RATIO,
borderWidth: 1,
height: brandIconWidth,
width: brandIconWidth,
borderWidth: 1,
borderColor: '#b5b5b5',
},
titleLikeView: {
height:41 * DEVICE_WIDTH_RATIO,
flexDirection: 'row-reverse',
},
title: {
fontSize: 17 * DEVICE_WIDTH_RATIO,
width: 147.5 * DEVICE_WIDTH_RATIO,
height: 20.5 * DEVICE_WIDTH_RATIO,
top: 12 * DEVICE_WIDTH_RATIO,
},
like: {
width: 17 * DEVICE_WIDTH_RATIO,
height: 16 * DEVICE_WIDTH_RATIO,
margin: 15 * DEVICE_WIDTH_RATIO,
},
intro: {
margin: 15 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
color: '#444444',
lineHeight: Math.ceil(18 * DEVICE_WIDTH_RATIO),
},
moreView: {
paddingBottom: 15 * DEVICE_WIDTH_RATIO,
flexDirection: 'row-reverse',
},
moreText: {
fontSize: 14 * DEVICE_WIDTH_RATIO,
color: '#bbbbbb',
},
moreArrow: {
marginTop: 5 * DEVICE_WIDTH_RATIO,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
marginRight: 15 * DEVICE_WIDTH_RATIO,
},
blackView: {
backgroundColor: '#f0f0f0',
height: 15 * DEVICE_WIDTH_RATIO,
}
});