...
|
...
|
@@ -22,22 +22,26 @@ export default class SmallPic extends React.Component { |
|
|
this.state = {
|
|
|
width0: 1,
|
|
|
width1: 1,
|
|
|
height0: 1,
|
|
|
height1: 1,
|
|
|
height0: 0,
|
|
|
height1: 0,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
let {resource} = this.props;
|
|
|
let data = resource.get('data')?resource.get('data').toJS():null;
|
|
|
let url1 = data?data[0].src:null;
|
|
|
let url2 = data?data[1].src:null;
|
|
|
Image.getSize(url1, (width, height) => {
|
|
|
this.setState({width0 : width, height0 : height});
|
|
|
});
|
|
|
Image.getSize(url2, (width, height) => {
|
|
|
this.setState({width1 : width, height1 : height});
|
|
|
});
|
|
|
let imageHeight = data?data[0].height:null;
|
|
|
let imageWidth = data?data[0].width:null;
|
|
|
if (!imageHeight || !imageWidth) {
|
|
|
let url1 = data?data[0].src:null;
|
|
|
let url2 = data?data[1].src:null;
|
|
|
Image.getSize(url1, (width, height) => {
|
|
|
this.setState({width0 : width, height0 : height});
|
|
|
});
|
|
|
Image.getSize(url2, (width, height) => {
|
|
|
this.setState({width1 : width, height1 : height});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
render() {
|
...
|
...
|
@@ -48,12 +52,26 @@ export default class SmallPic extends React.Component { |
|
|
if (!url1 || !url2) {
|
|
|
return null;
|
|
|
}
|
|
|
return (
|
|
|
<View style={styles.Small_pic}>
|
|
|
<Image source={{uri: url1}} style={{width: width/2,height: (width/2)*(this.state.height0/this.state.width0)}} ></Image>
|
|
|
<Image source={{uri: url2}} style={{width: width/2,height: (width/2)*(this.state.height1/this.state.width1)}} ></Image>
|
|
|
</View>
|
|
|
);
|
|
|
|
|
|
let imageHeight0 = data?data[0].height:null;
|
|
|
let imageWidth0 = data?data[0].width:null;
|
|
|
let imageHeight1 = data?data[1].height:null;
|
|
|
let imageWidth1 = data?data[1].width:null;
|
|
|
if (imageHeight0 && imageWidth0 && imageHeight1 && imageWidth1) {
|
|
|
return (
|
|
|
<View style={styles.Small_pic}>
|
|
|
<Image source={{uri: url1}} style={{width: width/2,height: (width/2)*(imageHeight0/imageWidth0)}} ></Image>
|
|
|
<Image source={{uri: url2}} style={{width: width/2,height: (width/2)*(imageHeight1/imageWidth1)}} ></Image>
|
|
|
</View>
|
|
|
);
|
|
|
}else {
|
|
|
return (
|
|
|
<View style={styles.Small_pic}>
|
|
|
<Image source={{uri: url1}} style={{width: width/2,height: (width/2)*(this.state.height0/this.state.width0)}} ></Image>
|
|
|
<Image source={{uri: url2}} style={{width: width/2,height: (width/2)*(this.state.height1/this.state.width1)}} ></Image>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|