LivePicture.js
2.79 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
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
import YH_Image from '../../../common/components/YH_Image';
import HeadTitleCell from '../cell/HeadTitleCell';
/**
* 直播资源位楼层
* 这个楼层是三张大图构成
**/
export default class LivePicture extends Component{
constructor(props) {
super(props);
}
render(){
let data = this.props.data;
let title = data.get("title");
let imglst = data.get("list");
let image1Url = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), imageWidth, imageHeight, 2);
let image2Url = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), imageWidth, imageHeight, 2);
let image3Url = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), imageWidth, imageHeight, 2);
return(
<View style={styles.container}>
<HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} onPressTitleMore={this.props.onPressTitleMore} />
<View style={styles.imageContainer}>
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).get('url'), 0)}>
<YH_Image style={styles.imageLeftAndRight} url={image1Url}/>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(1).get('url'), 1)}>
<YH_Image style={styles.imageMiddle} url={image2Url}/>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(2).get('url'), 2)}>
<YH_Image style={styles.imageLeftAndRight} url={image3Url}/>
</TouchableOpacity>
</View>
</View>
);
}
};
let {width} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let imageWidth = Math.ceil((width - 64) / 3);
let imageHeight = Math.ceil(imageWidth * 86 / 64);
let styles = StyleSheet.create({
container: {
width: width,
height: 40 + imageHeight,
},
imageContainer: {
width: width,
paddingLeft: 16 * DEVICE_WIDTH_RATIO,
paddingRight: 16 * DEVICE_WIDTH_RATIO,
paddingTop: 16 * DEVICE_WIDTH_RATIO,
paddingBottom: 16 * DEVICE_WIDTH_RATIO,
flexDirection: "row",
},
imageLeftAndRight: {
width: imageWidth,
height: imageHeight,
},
imageMiddle: {
width: imageWidth,
height: imageHeight,
marginLeft: 16 * DEVICE_WIDTH_RATIO,
marginRight: 16 * DEVICE_WIDTH_RATIO,
},
});