LivePicture.js 2.79 KB
'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,
    },

});