Showing
1 changed file
with
39 additions
and
74 deletions
| @@ -185,6 +185,34 @@ struct createImg { | @@ -185,6 +185,34 @@ struct createImg { | ||
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | + @Builder | ||
| 189 | + longPicTip(weight: number, height: number) { | ||
| 190 | + Flex({ direction: FlexDirection.Row }) { | ||
| 191 | + Image($r('app.media.icon_long_pic')) | ||
| 192 | + .width(12) | ||
| 193 | + .height(12) | ||
| 194 | + .margin({ right: 4 }) | ||
| 195 | + Text('长图') | ||
| 196 | + .fontSize(10) | ||
| 197 | + .fontWeight(400) | ||
| 198 | + .textShadow({ | ||
| 199 | + radius: 1, | ||
| 200 | + color: `rgba(0,0,0,0.5)`, | ||
| 201 | + offsetY:1, | ||
| 202 | + offsetX:1 | ||
| 203 | + }) | ||
| 204 | + .fontColor(0xffffff) | ||
| 205 | + .fontFamily('PingFang SC') | ||
| 206 | + .visibility( | ||
| 207 | + weight / height > 2 || height / weight > 2 | ||
| 208 | + ? Visibility.Visible : Visibility.None | ||
| 209 | + ) | ||
| 210 | + } | ||
| 211 | + .width(48) | ||
| 212 | + .align(Alignment.BottomEnd) | ||
| 213 | + .padding({ bottom: 8 }) | ||
| 214 | + } | ||
| 215 | + | ||
| 188 | build() { | 216 | build() { |
| 189 | GridRow({ | 217 | GridRow({ |
| 190 | gutter: { x: 2, y: 2 } | 218 | gutter: { x: 2, y: 2 } |
| @@ -212,29 +240,7 @@ struct createImg { | @@ -212,29 +240,7 @@ struct createImg { | ||
| 212 | .autoResize(true) | 240 | .autoResize(true) |
| 213 | .borderRadius(this.caclImageRadius(index)) | 241 | .borderRadius(this.caclImageRadius(index)) |
| 214 | } | 242 | } |
| 215 | - Flex({ direction: FlexDirection.Row }) { | ||
| 216 | - Image($r('app.media.icon_long_pic')) | ||
| 217 | - .width(12) | ||
| 218 | - .height(12) | ||
| 219 | - .margin({right: 4}) | ||
| 220 | - Text('长图') | ||
| 221 | - .fontSize(10) | ||
| 222 | - .fontWeight(400) | ||
| 223 | - .textShadow({ | ||
| 224 | - radius: 1, | ||
| 225 | - color: '#777', | ||
| 226 | - offsetX:1, | ||
| 227 | - offsetY:1 | ||
| 228 | - }) | ||
| 229 | - .fontColor(0xffffff) | ||
| 230 | - .fontFamily('PingFang SC') | ||
| 231 | - .visibility( | ||
| 232 | - item.weight / item.height > 2 / 1 || item.weight / item.height < 1 / 2 | ||
| 233 | - ? Visibility.Visible : Visibility.None | ||
| 234 | - ) | ||
| 235 | - } | ||
| 236 | - .width(48) | ||
| 237 | - .padding({bottom: 9}) | 243 | + this.longPicTip(item.weight, item.height) |
| 238 | 244 | ||
| 239 | } | 245 | } |
| 240 | } | 246 | } |
| @@ -261,20 +267,25 @@ struct createImg { | @@ -261,20 +267,25 @@ struct createImg { | ||
| 261 | GridCol({ | 267 | GridCol({ |
| 262 | span: this.onePicW > this.onePicH ? 12 : 8 | 268 | span: this.onePicW > this.onePicH ? 12 : 8 |
| 263 | }) { | 269 | }) { |
| 270 | + Stack({alignContent: Alignment.BottomEnd}) { | ||
| 264 | Image(this.loadImg ? item.url || item.fullUrl : '') | 271 | Image(this.loadImg ? item.url || item.fullUrl : '') |
| 265 | .backgroundColor(0xf5f5f5) | 272 | .backgroundColor(0xf5f5f5) |
| 266 | // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) | 273 | // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) |
| 267 | .width('100%') | 274 | .width('100%') |
| 275 | + .constraintSize({ | ||
| 276 | + maxHeight: this.onePicW > this.onePicH ? 198 : 305 | ||
| 277 | + }) | ||
| 268 | .autoResize(true) | 278 | .autoResize(true) |
| 269 | - // .objectFit(ImageFit.Cover) | ||
| 270 | - .autoResize(true) | ||
| 271 | - // .aspectRatio(3/4) | ||
| 272 | .borderRadius(this.caclImageRadius(index)) | 279 | .borderRadius(this.caclImageRadius(index)) |
| 273 | .opacity(!item.weight && !item.height ? 0 : 1) | 280 | .opacity(!item.weight && !item.height ? 0 : 1) |
| 274 | .onComplete((event?) => { | 281 | .onComplete((event?) => { |
| 275 | this.onePicW = event?.width || 0; | 282 | this.onePicW = event?.width || 0; |
| 276 | this.onePicH = event?.height || 0; | 283 | this.onePicH = event?.height || 0; |
| 277 | }) | 284 | }) |
| 285 | + if (this.onePicW && this.onePicH) { | ||
| 286 | + this.longPicTip(this.onePicW, this.onePicH) | ||
| 287 | + } | ||
| 288 | + } | ||
| 278 | } | 289 | } |
| 279 | } | 290 | } |
| 280 | } else if (this.fullColumnImgUrls.length === 5) { | 291 | } else if (this.fullColumnImgUrls.length === 5) { |
| @@ -290,30 +301,7 @@ struct createImg { | @@ -290,30 +301,7 @@ struct createImg { | ||
| 290 | .height('226lvp') | 301 | .height('226lvp') |
| 291 | .borderRadius(this.caclImageRadius(index)) | 302 | .borderRadius(this.caclImageRadius(index)) |
| 292 | if(this.getPicType(item.weight, item.height) !== 3){ | 303 | if(this.getPicType(item.weight, item.height) !== 3){ |
| 293 | - Flex({ direction: FlexDirection.Row }) { | ||
| 294 | - Image($r('app.media.icon_long_pic')) | ||
| 295 | - .width(12) | ||
| 296 | - .height(12) | ||
| 297 | - .margin({ right: 4 }) | ||
| 298 | - Text('长图') | ||
| 299 | - .fontSize(10) | ||
| 300 | - .fontWeight(400) | ||
| 301 | - .textShadow({ | ||
| 302 | - radius: 1, | ||
| 303 | - color: `rgba(0,0,0,0.5)`, | ||
| 304 | - offsetY:1, | ||
| 305 | - offsetX:1 | ||
| 306 | - }) | ||
| 307 | - .fontColor(0xffffff) | ||
| 308 | - .fontFamily('PingFang SC') | ||
| 309 | - .visibility( | ||
| 310 | - item.weight / item.height > 2 / 1 || item.weight / item.height < 1 / 2 | ||
| 311 | - ? Visibility.Visible : Visibility.None | ||
| 312 | - ) | ||
| 313 | - } | ||
| 314 | - .width(48) | ||
| 315 | - .align(Alignment.BottomEnd) | ||
| 316 | - .padding({ bottom: 3 }) | 304 | + this.longPicTip(item.weight, item.height) |
| 317 | } | 305 | } |
| 318 | } | 306 | } |
| 319 | } | 307 | } |
| @@ -329,30 +317,7 @@ struct createImg { | @@ -329,30 +317,7 @@ struct createImg { | ||
| 329 | .width('100%') | 317 | .width('100%') |
| 330 | .autoResize(true) | 318 | .autoResize(true) |
| 331 | if (this.getPicType(item.weight, item.height) !== 3) { | 319 | if (this.getPicType(item.weight, item.height) !== 3) { |
| 332 | - Flex({ direction: FlexDirection.Row }) { | ||
| 333 | - Image($r('app.media.icon_long_pic')) | ||
| 334 | - .width(12) | ||
| 335 | - .height(12) | ||
| 336 | - .margin({ right: 4 }) | ||
| 337 | - Text('长图') | ||
| 338 | - .fontSize(10) | ||
| 339 | - .fontWeight(400) | ||
| 340 | - .textShadow({ | ||
| 341 | - radius: 1, | ||
| 342 | - color: `rgba(0,0,0,0.5)`, | ||
| 343 | - offsetY: 1, | ||
| 344 | - offsetX: 1 | ||
| 345 | - }) | ||
| 346 | - .fontColor(0xffffff) | ||
| 347 | - .fontFamily('PingFang SC') | ||
| 348 | - .visibility( | ||
| 349 | - item.weight / item.height > 2 / 1 || item.weight / item.height < 1 / 2 | ||
| 350 | - ? Visibility.Visible : Visibility.None | ||
| 351 | - ) | ||
| 352 | - } | ||
| 353 | - .width(48) | ||
| 354 | - .align(Alignment.BottomEnd) | ||
| 355 | - .padding({ bottom: 3 }) | 320 | + this.longPicTip(item.weight, item.height) |
| 356 | } | 321 | } |
| 357 | } | 322 | } |
| 358 | .onClick(() => { | 323 | .onClick(() => { |
-
Please register or login to post a comment