# manifest
**Repository Path**: batee/manifest
## Basic Information
- **Project Name**: manifest
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 25
- **Created**: 2024-09-16
- **Last Updated**: 2026-03-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Ohos-AlertView
## 简介
> 本软件是参照开源软件[Android-AlertView](https://github.com/saiwu-bigkoo/Android-AlertView)源码适配OpenHarmony实现的AlertView功能,同时支持Alert和ActionSheet模式。
## 效果展示:
## 下载安装
````
ohpm install @ohos/Ohos-AlertView
````
OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://gitcode.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md)。
#### IDE编译运行
1、通过IDE工具下载依赖SDK,Tools->SDK Manager->OpenHarmony SDK 把native选项勾上下载,API版本>=19
2、开发手机选择API大于等于19
## 使用说明
### 示例代码
1. 在page页面中引入avro
```
import { AlertView, ButtonType, DialogType, DialogButton } from 'alertview'
```
2. 使用
```js
this.obj = new AlertView();
this.obj
.setContext(this.ctx)
.setType(DialogType.ALERT)
.setTitle("标题")
.setMsg("内容")
.setOnDismissListener(() => {
this.dialogControllerTwo.open();
})
.addDestructiveButton([{
text: '确定',
type: ButtonType.DESTRUCTIVE,
onPressed: () => {
this.dialogData = "点了第0个";
this.dialogController1.open();
}
}])
.addCancelButton({
text: '取消',
type: ButtonType.CANCEL,
onPressed: () => {
this.dialogData = "点了第-1个";
this.dialogController1.open();
}
})
.show()
this.obj
.setContext(this.ctx)
.setType(DialogType.ALERT)
.setTitle("标题")
.setMsg("内容")
.setCancelable(false)
.addDestructiveButton([{
text: '确定',
type: ButtonType.DESTRUCTIVE,
onPressed: () => {
this.dialogController2.open();
}
}])
.show()
```
## 接口说明
| 方法名 | 参数 | 接口描述 |
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------- |
| setContext(ctx: UIContext) | UI上下文 | 设置UI上下文 |
| show() | - | 显示AlertView |
| setType(type: DialogType) | 弹框类型 | 设置弹框类型,ALERT或ACTION_SHEET。默认值为ALERT |
| setTitle(title: string) | 标题字符串 | 设置弹框标题。默认值为空字符串 |
| setMsg(msg: string) | 消息字符串 | 设置弹框消息。默认值为空字符串 |
| addExtView(contentBuilder: () => void) | 自定义扩展视图 | 添加自定义扩展视图 |
| addCancelButton(button: DialogButton) | 取消按钮的文本、类型、点击后的回调函数 | 添加取消按钮 |
| addDestructiveButton(button: Array) | 破坏性按钮的数组 | 添加破坏性按钮 |
| addOthersButton(button: Array) | 其它按钮的数组 | 添加其他按钮 |
| setCancelable(isCancelable: boolean) | 弹框是否通过点击外部区域,右滑等方式可以取消 | 设置弹框是否可取消。默认值为true |
| setOnDismissListener(onDismissListener: () => void) | 弹框消失时的回调函数 | 设置弹框消失时的回调函数 |
## 约束与限制
在下述版本验证通过:
- DevEco Studio 版本:DevEco Studio 6.0.1 Release, OpenHarmony SDK:5.1.1(19)。
## 目录结构
````
|---- ohos_alertview
| |---- entry # 示例代码文件夹
| |---- avro # avro 库文件夹
| |---- cpp # native模块
| |----- napi # napi实现代码目录
| |----- third_party # 实现引用的三方库jansson、avro、snappy、zlib、lzma;需要创建此目录,拷贝依赖的三方库到此目录
| |----- utils # 工具、公共代码和日志接口目录
| |----- type # 对外接口函数目录
| |---- README_zh.md # 中文安装使用方法
| |---- README.md # 英文安装使用方法
````
## 贡献代码
使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-tpc-incubate/ohos_avroc/issues) 给组件,当然,也非常欢迎给发 [PR](https://gitee.com/openharmony-tpc-incubate/ohos_avroc/pulls)
。
## 开源协议
本项目基于 [Apache License 2.0](https://gitee.com/openharmony-tpc-incubate/ohos_avroc/blob/master/LICENSE) ,请自由地享受和参与开源。