MyCustomDialog.ets 1.88 KB
@CustomDialog
export struct MyCustomDialog {
  @State title: string = "标题"
  @State titleShow: boolean = true
  @State tipValue: string ="提示文字"
  @State tipShow: boolean = true

  @State leftText: string = "取消"
  @State rightText: string = "确认"

  controller: CustomDialogController
  cancel: () => void = () => {
  }
  confirm: () => void = () => {
  }

  build() {
    Column() {
      if(this.titleShow){
        Text(this.title)
          .fontSize("32lpx")
          .margin({ top: "40lpx", bottom: "15lpx" })
          .fontColor($r('app.color.color_333333'))
          .fontSize('35lpx')
          .fontWeight('600lpx')
      }

      if(this.tipShow){
        Text(this.tipValue)
          .margin({ bottom: "30lpx" })
          .fontSize("27lpx")
          .fontColor($r('app.color.color_B0B0B0'))
      }

      Divider()
        .width("100%")
        .strokeWidth('1lpx')
        .height('1lpx')
        .color($r('app.color.color_EEEEEE'))

      Row(){
        Text(this.leftText)
          .fontSize('35lpx')
          .fontWeight('400lpx')
          .fontColor($r('app.color.color_333333'))
          .onClick(() => {
            this.controller.close()
            this.cancel()
          }).layoutWeight(1)
          .textAlign(TextAlign.Center)
        Divider()
          .width("1lpx")
          .strokeWidth('1lpx')
          .vertical(true)
          .height('92lpx')
          .color($r('app.color.color_EEEEEE'))

        Text(this.rightText)
          .fontSize('35lpx')
          .textAlign(TextAlign.Center)
          .fontWeight('400lpx')
          .fontColor($r('app.color.color_648DF2'))
          .onClick(() => {
            if (this.controller != undefined) {
              this.controller.close()
              this.confirm()
            }
          }).layoutWeight(1)
      }
      .alignItems(VerticalAlign.Center)
      .height('96lpx')
    }.borderRadius(10)
  }
}