AlbumCardComponent.ets 3.64 KB
@Component
export struct AlbumCard {
  // @Link isRefreshData: boolean; // Timer to fresh
  // @State title: Resource = $r('app.string.title_default');

  build() {
    Flex({direction:FlexDirection.Column}) {
      Text('测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字' +
      '测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字' +
      '测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字')
        .textOverflow({ overflow: TextOverflow.Ellipsis })
        .fontSize(17)
        .fontColor(0x222222)
        .lineHeight(25)
        .maxLines(3)
          // .padding({ top: 6,
          //   left: 16,
          //   right: 16 })
        .width('100%')
        .height(75)

      Grid() {
        GridItem() {
          Image($r('app.media.icon'))
            .width('100%')
            .height('100%')
        }
        .rowStart(1)
        .rowEnd(2)
        .backgroundColor(0xFF0000)

        GridItem() {
          Image($r('app.media.icon'))
            .width('100%')
            .height('100%')
        }
        .backgroundColor(0x00FF00)

        GridItem() {
          Stack({alignContent:Alignment.BottomEnd}) {
            Image($r('app.media.icon'))
              .width('100%')
              .height('100%')


            Shape() {
              Rect().width(33).height(18)
            }
            // .viewPort({ x: -2, y: -2, width: 304, height: 130 })
            .fill(0x000000)
            .fillOpacity(0.3)
            // .strokeDashArray([20])
            // .strokeDashOffset(10)
            .strokeLineCap(LineCapStyle.Round)
            .strokeLineJoin(LineJoinStyle.Round)
            .antiAlias(true)
            .align(Alignment.BottomEnd)
            .margin({bottom:4,right:4})

            Image($r('app.media.album_card_shape'))
              .width(22)
              .height(18)
              .align(Alignment.BottomEnd)
              .margin({bottom:4,right:15})

            Text('6')
              .fontSize(13)
              .fontColor(0xFFFFFF)
                // .id('pageIndex')
                // .alignRules({
                //   right: {anchor: "shape", align: HorizontalAlign.End},
                //   top: {anchor: "shape", align: VerticalAlign.Top}
                // })
              .textAlign(TextAlign.Center)
              .width(17)
              .height(17)
              .align(Alignment.BottomEnd)
              .margin({bottom:4,right:4})


          }
          .width('100%')
          .height('100%')
        }
        .backgroundColor(0x0000FF)
      }
      .rowsTemplate('1fr 1fr')
      .columnsTemplate('2fr 1fr')
      .columnsGap(2)
      .rowsGap(2)
      .width('100%')
      .height(154)
      // .aspectRatio(343/154)
      .margin({top:8})

      Row() {
        Text('人民日报')
          .fontSize(13)
          .fontColor(0xB0B0B0)

        Image($r('app.media.album_card_divide'))
          .width(16)
          .height(16)

        Text('46分钟前')
          .fontSize(13)
          .fontColor(0xB0B0B0)

        Text('328评')
          .fontSize(13)
          .fontColor(0xB0B0B0)
          .margin({
            left:6
          })
      }
      .width('100%')
      .height(16)
      .margin({top:8})

    }
    .width('100%')
    .height(289)
    .padding({top: 14,left: 16,right: 16,bottom: 14})
    // .aspectRatio(375 / 289)
    .backgroundColor(0x000000)
  }
}