修改 逛详情 单图标签显示样式 review by chenlin
Showing
1 changed file
with
6 additions
and
35 deletions
@@ -17,36 +17,6 @@ const { | @@ -17,36 +17,6 @@ const { | ||
17 | } = ReactNative; | 17 | } = ReactNative; |
18 | 18 | ||
19 | 19 | ||
20 | -function getRandom(imageHeight,imageWidth,tagList) { | ||
21 | - let tagListSize = tagList?tagList.length:0; | ||
22 | - let list = tagList; | ||
23 | - let tagHeigthSize = Math.ceil((imageHeight/(tagHeigth+5))-2); | ||
24 | - | ||
25 | - //最多处理tagHeigthSize个 | ||
26 | - if (tagListSize > tagHeigthSize) { | ||
27 | - list = tagList.slice(0,tagHeigthSize); | ||
28 | - } | ||
29 | - for (var i = 0; i < list.length; i++) { | ||
30 | - let item = list[i]; | ||
31 | - item.right = Math.ceil(Math.random()*(imageWidth/3)+1); | ||
32 | - item.topCount = deDuplicating(tagHeigthSize,tagList); | ||
33 | - | ||
34 | - } | ||
35 | - return list; | ||
36 | -} | ||
37 | - | ||
38 | -function deDuplicating(tagHeigthSize,tagList) { | ||
39 | - let randomH = Math.ceil(Math.random()*(tagHeigthSize-1)+1); | ||
40 | - for (var i = 0; i < tagList.length; i++) { | ||
41 | - let item = tagList[i]; | ||
42 | - if (item.topCount == randomH) { | ||
43 | - randomH = deDuplicating(tagHeigthSize,tagList); | ||
44 | - break; | ||
45 | - } | ||
46 | - } | ||
47 | - return randomH; | ||
48 | -} | ||
49 | - | ||
50 | export default class SingleImage extends React.Component { | 20 | export default class SingleImage extends React.Component { |
51 | constructor(props) { | 21 | constructor(props) { |
52 | super(props); | 22 | super(props); |
@@ -90,7 +60,7 @@ export default class SingleImage extends React.Component { | @@ -90,7 +60,7 @@ export default class SingleImage extends React.Component { | ||
90 | tagList = tagList?tagList.toJS():[]; | 60 | tagList = tagList?tagList.toJS():[]; |
91 | 61 | ||
92 | if (imageHeight && imageWidth) { | 62 | if (imageHeight && imageWidth) { |
93 | - tagList = getRandom((imageHeight/imageWidth)*screenWidth,screenWidth,tagList); | 63 | + |
94 | return ( | 64 | return ( |
95 | <View style={{width: screenWidth,height: (imageHeight/imageWidth)*screenWidth,marginLeft: 10}}> | 65 | <View style={{width: screenWidth,height: (imageHeight/imageWidth)*screenWidth,marginLeft: 10}}> |
96 | {linkUrl?<TouchableOpacity activeOpacity={0.5} onPress={() => { | 66 | {linkUrl?<TouchableOpacity activeOpacity={0.5} onPress={() => { |
@@ -109,11 +79,11 @@ export default class SingleImage extends React.Component { | @@ -109,11 +79,11 @@ export default class SingleImage extends React.Component { | ||
109 | <View | 79 | <View |
110 | key={'values' + i} | 80 | key={'values' + i} |
111 | style={{ | 81 | style={{ |
112 | - maxWidth: screenWidth - value.right, | 82 | + maxWidth: screenWidth - 20, |
113 | height: tagHeigth, | 83 | height: tagHeigth, |
114 | position: 'absolute', | 84 | position: 'absolute', |
115 | - right: value.right, | ||
116 | - top: value.topCount*(tagHeigth+5), | 85 | + left: 10, |
86 | + bottom: i*(tagHeigth+10)+10, | ||
117 | backgroundColor: 'transparent', | 87 | backgroundColor: 'transparent', |
118 | flexDirection: 'row', | 88 | flexDirection: 'row', |
119 | justifyContent: 'flex-end', | 89 | justifyContent: 'flex-end', |
@@ -128,9 +98,10 @@ export default class SingleImage extends React.Component { | @@ -128,9 +98,10 @@ export default class SingleImage extends React.Component { | ||
128 | }}> | 98 | }}> |
129 | <View style={styles.tagView}> | 99 | <View style={styles.tagView}> |
130 | <Text style={{ | 100 | <Text style={{ |
131 | - maxWidth: screenWidth - value.right - 2*tagHeigth - 20, | 101 | + maxWidth: screenWidth - 20 - 2*tagHeigth - 20, |
132 | color: 'white', | 102 | color: 'white', |
133 | paddingLeft: 10, | 103 | paddingLeft: 10, |
104 | + paddingRight: 10, | ||
134 | backgroundColor: 'transparent', | 105 | backgroundColor: 'transparent', |
135 | }} numberOfLines={1}>{value.tagName}</Text> | 106 | }} numberOfLines={1}>{value.tagName}</Text> |
136 | <TouchableOpacity style={styles.button} activeOpacity={0.5} onPress={() => { | 107 | <TouchableOpacity style={styles.button} activeOpacity={0.5} onPress={() => { |
-
Please register or login to post a comment