...
|
...
|
@@ -17,36 +17,6 @@ const { |
|
|
} = ReactNative;
|
|
|
|
|
|
|
|
|
function getRandom(imageHeight,imageWidth,tagList) {
|
|
|
let tagListSize = tagList?tagList.length:0;
|
|
|
let list = tagList;
|
|
|
let tagHeigthSize = Math.ceil((imageHeight/(tagHeigth+5))-2);
|
|
|
|
|
|
//最多处理tagHeigthSize个
|
|
|
if (tagListSize > tagHeigthSize) {
|
|
|
list = tagList.slice(0,tagHeigthSize);
|
|
|
}
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
let item = list[i];
|
|
|
item.right = Math.ceil(Math.random()*(imageWidth/3)+1);
|
|
|
item.topCount = deDuplicating(tagHeigthSize,tagList);
|
|
|
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
function deDuplicating(tagHeigthSize,tagList) {
|
|
|
let randomH = Math.ceil(Math.random()*(tagHeigthSize-1)+1);
|
|
|
for (var i = 0; i < tagList.length; i++) {
|
|
|
let item = tagList[i];
|
|
|
if (item.topCount == randomH) {
|
|
|
randomH = deDuplicating(tagHeigthSize,tagList);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return randomH;
|
|
|
}
|
|
|
|
|
|
export default class SingleImage extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
...
|
...
|
@@ -90,7 +60,7 @@ export default class SingleImage extends React.Component { |
|
|
tagList = tagList?tagList.toJS():[];
|
|
|
|
|
|
if (imageHeight && imageWidth) {
|
|
|
tagList = getRandom((imageHeight/imageWidth)*screenWidth,screenWidth,tagList);
|
|
|
|
|
|
return (
|
|
|
<View style={{width: screenWidth,height: (imageHeight/imageWidth)*screenWidth,marginLeft: 10}}>
|
|
|
{linkUrl?<TouchableOpacity activeOpacity={0.5} onPress={() => {
|
...
|
...
|
@@ -109,11 +79,11 @@ export default class SingleImage extends React.Component { |
|
|
<View
|
|
|
key={'values' + i}
|
|
|
style={{
|
|
|
maxWidth: screenWidth - value.right,
|
|
|
maxWidth: screenWidth - 20,
|
|
|
height: tagHeigth,
|
|
|
position: 'absolute',
|
|
|
right: value.right,
|
|
|
top: value.topCount*(tagHeigth+5),
|
|
|
left: 10,
|
|
|
bottom: i*(tagHeigth+10)+10,
|
|
|
backgroundColor: 'transparent',
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'flex-end',
|
...
|
...
|
@@ -128,9 +98,10 @@ export default class SingleImage extends React.Component { |
|
|
}}>
|
|
|
<View style={styles.tagView}>
|
|
|
<Text style={{
|
|
|
maxWidth: screenWidth - value.right - 2*tagHeigth - 20,
|
|
|
maxWidth: screenWidth - 20 - 2*tagHeigth - 20,
|
|
|
color: 'white',
|
|
|
paddingLeft: 10,
|
|
|
paddingRight: 10,
|
|
|
backgroundColor: 'transparent',
|
|
|
}} numberOfLines={1}>{value.tagName}</Text>
|
|
|
<TouchableOpacity style={styles.button} activeOpacity={0.5} onPress={() => {
|
...
|
...
|
|