|
|
'use strict';
|
|
|
|
|
|
import React from 'react';
|
|
|
import ReactNative from 'react-native';
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
import YH_Image from '../../../common/components/YH_Image';
|
|
|
import {getSlicedUrl} from '../../../classify/utils/Utils';
|
|
|
|
|
|
const {
|
|
|
View,
|
|
|
Text,
|
|
|
TouchableOpacity,
|
|
|
Dimensions,
|
|
|
StyleSheet,
|
|
|
Platform,
|
|
|
} = ReactNative;
|
|
|
|
|
|
export default class ActivityCell extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super (props);
|
|
|
}
|
|
|
|
|
|
shouldComponentUpdate(nextProps,nextState){
|
|
|
if (Immutable.is(nextProps.resource, this.props.resource)) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {resource} = this.props;
|
|
|
if (!resource) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
let data = resource.toJS();
|
|
|
|
|
|
let newSrc = getSlicedUrl(data.coverUrl, backgroundWidth, backgroundHeight);
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<TouchableOpacity
|
|
|
activeOpacity={1}
|
|
|
style={{width: backgroundWidth, height: backgroundHeight}}
|
|
|
onPress={() => {
|
|
|
this.props.onPressProduct && this.props.onPressProduct();
|
|
|
}}
|
|
|
>
|
|
|
<YH_Image
|
|
|
url={newSrc}
|
|
|
style={{ width: backgroundWidth, height: backgroundHeight}}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
<View style={styles.space} />
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let backgroundWidth = width;
|
|
|
let backgroundHeight = Math.ceil((300 / 640) * width);
|
|
|
let spaceH = Math.ceil((30 / 640) * width);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
width: width,
|
|
|
height: backgroundHeight + spaceH,
|
|
|
},
|
|
|
|
|
|
space: {
|
|
|
width: width,
|
|
|
height: spaceH,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
}); |
...
|
...
|
|