xugenyuan

ref |> 处理底部评论数量为0时,不显示

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
@@ -87,45 +87,45 @@ export struct CommentIconComponent { @@ -87,45 +87,45 @@ export struct CommentIconComponent {
87 Stack({ alignContent: Alignment.TopEnd }) { 87 Stack({ alignContent: Alignment.TopEnd }) {
88 Image($r('app.media.comment_icon')).width(24).height(24) 88 Image($r('app.media.comment_icon')).width(24).height(24)
89 // Stack({alignContent:Alignment.Start}) { 89 // Stack({alignContent:Alignment.Start}) {
90 - // if(Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0){  
91 - RelativeContainer() {  
92 - Image($r('app.media.comment_icon_number_bg'))  
93 - .objectFit(ImageFit.Fill)  
94 - .resizable({ slice: { top: 1, left: 20, right: 1, bottom: 1 } })  
95 - .alignRules({  
96 - top: { anchor: "Text", align: VerticalAlign.Top },  
97 - left: { anchor: "Text", align: HorizontalAlign.Start },  
98 - right: { anchor: "Text", align: HorizontalAlign.End },  
99 - bottom: { anchor: "Text", align: VerticalAlign.Bottom },  
100 - })// .offset({  
101 - // x:-6  
102 - // })  
103 - .id("Image")  
104 -  
105 - Text(this.publishCommentModel.totalCommentNumer)// Text("44444444")  
106 - .fontSize(8)  
107 - .fontColor('#ffffff')// .backgroundColor('#ED2800')  
108 - .height(12)  
109 - .textAlign(TextAlign.Center)  
110 - .alignRules({  
111 - top: { anchor: "__container__", align: VerticalAlign.Top },  
112 - left: { anchor: "__container__", align: HorizontalAlign.Start }  
113 - })// .margin({left: 4,right:4  
114 - // })  
115 - /*动态计算文字宽度*/  
116 - .width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) + 12)// .backgroundColor(Color.Green)  
117 - .id("Text")  
118 - // .offset({  
119 - // x: 3  
120 - // }) 90 + if(Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0){
  91 + RelativeContainer() {
  92 + Image($r('app.media.comment_icon_number_bg'))
  93 + .objectFit(ImageFit.Fill)
  94 + .resizable({ slice: { top: 1, left: 20, right: 1, bottom: 1 } })
  95 + .alignRules({
  96 + top: { anchor: "Text", align: VerticalAlign.Top },
  97 + left: { anchor: "Text", align: HorizontalAlign.Start },
  98 + right: { anchor: "Text", align: HorizontalAlign.End },
  99 + bottom: { anchor: "Text", align: VerticalAlign.Bottom },
  100 + })// .offset({
  101 + // x:-6
  102 + // })
  103 + .id("Image")
  104 +
  105 + Text(this.publishCommentModel.totalCommentNumer)// Text("44444444")
  106 + .fontSize(8)
  107 + .fontColor('#ffffff')// .backgroundColor('#ED2800')
  108 + .height(12)
  109 + .textAlign(TextAlign.Center)
  110 + .alignRules({
  111 + top: { anchor: "__container__", align: VerticalAlign.Top },
  112 + left: { anchor: "__container__", align: HorizontalAlign.Start }
  113 + })// .margin({left: 4,right:4
  114 + // })
  115 + /*动态计算文字宽度*/
  116 + .width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) + 12)// .backgroundColor(Color.Green)
  117 + .id("Text")
  118 + // .offset({
  119 + // x: 3
  120 + // })
  121 +
  122 + }
  123 + // }
  124 + .offset({
  125 + x: 12
  126 + })
121 127
122 } 128 }
123 - // }  
124 - .offset({  
125 - x: 12  
126 - })  
127 -  
128 - // }  
129 } 129 }
130 }.width(24).height(24) 130 }.width(24).height(24)
131 131