鸿蒙OS promptAction的使用

复制代码
效果如下:
复制代码
import { promptAction } from '@kit.ArkUI'

let customDialogId: number = 0

@Builder
function customDialogBuilder() {
  Column() {
    Blank().height(30)
    Text('确定要删除吗?').fontSize(15)
    Blank().height(40)
    Row() {
        Button("取消").onClick(() => {
          promptAction.closeCustomDialog(customDialogId)
        })
        .width(80).height(30)
        .fontColor($r("app.color.btn_button"))
        .backgroundColor($r('app.color.white'))
      Blank().width(50)
      Button("确认").onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
        .backgroundColor($r("app.color.btn_button"))
        .fontColor($r('app.color.white'))
     .width(80).height(30)
    }
  }
}



@Entry
@Component
struct CustomDialog {
  @State message: string = 'Hello World'

  @Builder
  customDialogComponent() {
    customDialogBuilder()
  }

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(() => {
            promptAction.openCustomDialog({
              builder: () => {
                this.customDialogComponent()
              },
              showInSubWindow: false,
              offset: { dx: 5, dy: 5 },
              backgroundColor: 0xd9ffffff,
              cornerRadius: 20,
              width: '80%',
              height: 150,
              borderWidth: 1,
              borderColor:$r('app.color.white'), //使用borderColor属性,需要和borderWidth属性一起使用
              shadow: ({
                radius: 20,
                color: Color.Grey,
                offsetX: 50,
                offsetY: 0
              }),
            }).then((dialogId: number) => {
              customDialogId = dialogId
            })
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}
相关推荐
柒儿吖3 小时前
Flutter跨平台三方库animations和flutter_animate在鸿蒙中的使用指南
flutter·华为·harmonyos
安卓理事人7 小时前
鸿蒙list第三个参数的意思
harmonyos
IT陈图图9 小时前
基于 Flutter × OpenHarmony 的文本排序工具开发实战
flutter·开源·鸿蒙·openharmony
奋斗的小青年!!9 小时前
Flutter开发OpenHarmony应用:设置页面组件的深度实践
flutter·harmonyos·鸿蒙
大雷神9 小时前
HarmonyAPP 开发Flutter 嵌入鸿蒙原生 Swiper 组件教程
flutter·华为·harmonyos
ShiMetaPi9 小时前
八核RISC-V + 双屏输出 + 全接口扩展:M-K1HSE 深度解析
人工智能·机器人·鸿蒙·开源鸿蒙
鸣弦artha11 小时前
Flutter框架跨平台鸿蒙开发——Flutter Framework层架构概览
flutter·架构·harmonyos
安卓理事人12 小时前
鸿蒙启动后台服务运行
华为·harmonyos
小雨下雨的雨12 小时前
鸿蒙PC应用:工程结构解析与配置文件详解
ui·华为·harmonyos·鸿蒙系统
世人万千丶13 小时前
鸿蒙跨端框架 Flutter 学习 Day 3:性能进阶——Iterable 延迟加载与计算流的智慧
学习·flutter·ui·华为·harmonyos·鸿蒙·鸿蒙系统