Showing
1 changed file
with
54 additions
and
45 deletions
| @@ -185,53 +185,13 @@ export struct CommentIconComponent { | @@ -185,53 +185,13 @@ export struct CommentIconComponent { | ||
| 185 | Image(this.styleType == 1 ? $r('app.media.comment_icon') : | 185 | Image(this.styleType == 1 ? $r('app.media.comment_icon') : |
| 186 | $r('app.media.comment_icon_white')).width(24).height(24) | 186 | $r('app.media.comment_icon_white')).width(24).height(24) |
| 187 | // Stack({alignContent:Alignment.Start}) { | 187 | // Stack({alignContent:Alignment.Start}) { |
| 188 | - if (Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0) { | ||
| 189 | - RelativeContainer() { | ||
| 190 | - Image(this.styleType == 1 ? this.showMainText?$r('app.media.comment_icon_text_bg'):$r('app.media.comment_icon_number_bg') : this.showMainText?$r('app.media.comment_icon_text_block_bg'):$r('app.media.ic_like_back_Select')) | ||
| 191 | - .objectFit(ImageFit.Fill) | ||
| 192 | - .resizable({ | ||
| 193 | - slice: { | ||
| 194 | - top: 1, | ||
| 195 | - left: 20, | ||
| 196 | - right: 1, | ||
| 197 | - bottom: 1 | ||
| 198 | - } | ||
| 199 | - }) | ||
| 200 | - .alignRules({ | ||
| 201 | - top: { anchor: "Text", align: VerticalAlign.Top }, | ||
| 202 | - left: { anchor: "Text", align: HorizontalAlign.Start }, | ||
| 203 | - right: { anchor: "Text", align: HorizontalAlign.End }, | ||
| 204 | - bottom: { anchor: "Text", align: VerticalAlign.Bottom }, | ||
| 205 | - })// .offset({ | ||
| 206 | - // x:-6 | ||
| 207 | - // }) | ||
| 208 | - .id("Image") | ||
| 209 | - Text(this.showMainText?'正文':NumberFormatterUtils.formatNumberWithWan(this.publishCommentModel.totalCommentNumer))// Text("44444444") | ||
| 210 | - .fontSize(8) | ||
| 211 | - .fontColor(this.showMainText?'#222222':'#ffffff')// .backgroundColor('#ED2800') | ||
| 212 | - .height(12) | ||
| 213 | - .textAlign(TextAlign.Center) | ||
| 214 | - .alignRules({ | ||
| 215 | - top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 216 | - left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 217 | - })// .margin({left: 4,right:4 | ||
| 218 | - // }) | ||
| 219 | - /*动态计算文字宽度*/ | ||
| 220 | - .width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.publishCommentModel.totalCommentNumer)) + | ||
| 221 | - 12)// .backgroundColor(Color.Green) | ||
| 222 | - .id("Text") | ||
| 223 | - .visibility(this.publishCommentModel.totalCommentNumer ? Visibility.Visible : Visibility.Hidden) | ||
| 224 | - // .offset({ | ||
| 225 | - // x: 3 | ||
| 226 | - // }) | ||
| 227 | 188 | ||
| 189 | + if (this.showMainText) { | ||
| 190 | + this.commentIcon() | ||
| 191 | + }else { | ||
| 192 | + if (Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0) { | ||
| 193 | + this.commentIcon() | ||
| 228 | } | 194 | } |
| 229 | - // } | ||
| 230 | - .offset({ | ||
| 231 | - x: this.showMainText?8:12, | ||
| 232 | - y: -2 | ||
| 233 | - }) | ||
| 234 | - | ||
| 235 | } | 195 | } |
| 236 | } | 196 | } |
| 237 | } | 197 | } |
| @@ -242,6 +202,55 @@ export struct CommentIconComponent { | @@ -242,6 +202,55 @@ export struct CommentIconComponent { | ||
| 242 | // .backgroundColor(Color.Blue) | 202 | // .backgroundColor(Color.Blue) |
| 243 | } | 203 | } |
| 244 | 204 | ||
| 205 | + @Builder | ||
| 206 | + commentIcon() { | ||
| 207 | + RelativeContainer() { | ||
| 208 | + Image(this.styleType == 1 ? this.showMainText?$r('app.media.comment_icon_text_bg'):$r('app.media.comment_icon_number_bg') : this.showMainText?$r('app.media.comment_icon_text_block_bg'):$r('app.media.ic_like_back_Select')) | ||
| 209 | + .objectFit(ImageFit.Fill) | ||
| 210 | + .resizable({ | ||
| 211 | + slice: { | ||
| 212 | + top: 1, | ||
| 213 | + left: 20, | ||
| 214 | + right: 1, | ||
| 215 | + bottom: 1 | ||
| 216 | + } | ||
| 217 | + }) | ||
| 218 | + .alignRules({ | ||
| 219 | + top: { anchor: "Text", align: VerticalAlign.Top }, | ||
| 220 | + left: { anchor: "Text", align: HorizontalAlign.Start }, | ||
| 221 | + right: { anchor: "Text", align: HorizontalAlign.End }, | ||
| 222 | + bottom: { anchor: "Text", align: VerticalAlign.Bottom }, | ||
| 223 | + })// .offset({ | ||
| 224 | + // x:-6 | ||
| 225 | + // }) | ||
| 226 | + .id("Image") | ||
| 227 | + Text(this.showMainText?'正文':NumberFormatterUtils.formatNumberWithWan(this.publishCommentModel.totalCommentNumer))// Text("44444444") | ||
| 228 | + .fontSize(8) | ||
| 229 | + .fontColor(this.showMainText?'#222222':'#ffffff')// .backgroundColor('#ED2800') | ||
| 230 | + .height(12) | ||
| 231 | + .textAlign(TextAlign.Center) | ||
| 232 | + .alignRules({ | ||
| 233 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 234 | + left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 235 | + })// .margin({left: 4,right:4 | ||
| 236 | + // }) | ||
| 237 | + /*动态计算文字宽度*/ | ||
| 238 | + .width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.publishCommentModel.totalCommentNumer)) + | ||
| 239 | + 12)// .backgroundColor(Color.Green) | ||
| 240 | + .id("Text") | ||
| 241 | + .visibility(this.publishCommentModel.totalCommentNumer ? Visibility.Visible : Visibility.Hidden) | ||
| 242 | + // .offset({ | ||
| 243 | + // x: 3 | ||
| 244 | + // }) | ||
| 245 | + | ||
| 246 | + } | ||
| 247 | + // } | ||
| 248 | + .offset({ | ||
| 249 | + x: this.showMainText?8:12, | ||
| 250 | + y: -2 | ||
| 251 | + }) | ||
| 252 | + } | ||
| 253 | + | ||
| 245 | private getMeasureText(text: string) { | 254 | private getMeasureText(text: string) { |
| 246 | 255 | ||
| 247 | 256 |
-
Please register or login to post a comment