Skip to content

Commit 998f5dc

Browse files
committed
feat(arkui): add support for ArkUi special features, components, and layouts
You are working on migration code to ArkUi, a new frontend DSL UI framework with a lot of components and layouts. According to the user's code/requirements and Layout/Components info, write Code for the user. ArkUi has some special features: - marginRight should be margin({ right: 10 }), or margin(10) - paddingRight should be padding({left: 5, top: 20, right: 5, bottom: 20})// 设置不同的边距值 ArkUi Layout/Components Infos: ```ArkTS ${context.requirement} ``` You should use provided components, please write your code with Markdown syntax, no explanation is needed. Also, support was added for the following components: CustomDialog, Image, Popup, Progress, Text, TextArea, Video, Web, and XComponent. Descriptions and usage examples for each component were added in the code.
1 parent 87d68b8 commit 998f5dc

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

exts/ext-harmonyos/src/main/kotlin/cc/unitmesh/harmonyos/actions/auto/ArkUiComponentType.kt

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ enum class ArkUiComponentType(val description: String, val example: String) {
2626
" console.info(\"checkbox group content\" + JSON.stringify(itemName))\n" +
2727
" })"
2828
),
29+
CustomDialog(
30+
"自定义弹窗(CustomDialog)可用于广告、中奖、警告、软件更新等与用户交互响应操作。",
31+
"1. 使用@CustomDialog装饰器装饰自定义弹窗。" +
32+
"@CustomDialog\n" +
33+
"struct CustomDialogExample {\n" +
34+
" controller: CustomDialogController\n" +
35+
" build() {\n" +
36+
" Column() {\n" +
37+
" Text('我是内容')\n" +
38+
" .fontSize(20)\n" +
39+
" .margin({ top: 10, bottom: 10 })\n" +
40+
" }\n" +
41+
" }\n" +
42+
"}" +
43+
"2. 创建构造器,与装饰器呼应相连。" +
44+
"dialogController: CustomDialogController = new CustomDialogController({\n" +
45+
" builder: CustomDialogExample({}),\n" +
46+
"})" +
47+
"3. 点击与onClick事件绑定的组件使弹窗弹出" +
48+
"" +
49+
"Flex({justifyContent:FlexAlign.Center}){\n" +
50+
" Button('click me')\n" +
51+
" .onClick(() => {\n" +
52+
" this.dialogController.open()\n" +
53+
" })\n" +
54+
"}.width('100%')"
55+
),
2956
Image(
3057
"Image为图片组件,常用于在应用中显示图片。Image支持加载string、PixelMap和Resource类型的数据源,支持png、jpg、bmp、svg和gif类型的图片格式。",
3158
"Image(this.src)\n" +
@@ -64,13 +91,30 @@ enum class ArkUiComponentType(val description: String, val example: String) {
6491
" })\n" +
6592
" }"
6693
),
94+
Popup(
95+
"Popup属性可绑定在组件上显示气泡弹窗提示,设置弹窗内容、交互逻辑和显示状态。",
96+
"Button('PopupOptions')\n" +
97+
" .onClick(() => {\n" +
98+
" this.handlePopup = !this.handlePopup\n" +
99+
" })\n" +
100+
" .bindPopup(this.handlePopup, {\n" +
101+
" message: 'This is a popup with PopupOptions',\n" +
102+
" })"
103+
),
104+
Progress(
105+
"Progress 是进度条显示组件,显示内容通常为某次目标操作的当前进度。",
106+
"Progress({value:0, total:100, type:ProgressType.Capsule}).width(200).height(50)\n" +
107+
" .style({strokeWidth:50}).value(this.progressValue)"
108+
),
67109
Text(
68110
"显示一段文本的组件。。", "Text('TextAlign set to Center.')\n" +
69111
" .textAlign(TextAlign.Center)\n" +
70112
" .fontSize(12)\n" +
113+
" .fontColor('#ff0000')\n" +
71114
" .border({ width: 1 })\n" +
72115
" .padding(10)\n" +
73-
" .width('100%')"
116+
" .width('100%')\n" +
117+
" .decoration({type: TextDecorationType.Underline, color: Color.Black})"
74118
),
75119
TextArea(
76120
"多行文本输入框。",
@@ -124,6 +168,14 @@ enum class ArkUiComponentType(val description: String, val example: String) {
124168
" console.info('Component status:' + isOn)\n" +
125169
" })"
126170
),
171+
Video(
172+
"Video组件用于播放视频文件并控制其播放状态,常用于为短视频应用和应用内部视频的列表页面。",
173+
"Video({\n" +
174+
" src: this.innerResource,\n" +
175+
" previewUri: this.previewUris,\n" +
176+
" controller: this.controller\n" +
177+
"})"
178+
),
127179
Web(
128180
"提供具有网页显示能力的Web组件,@ohos.web.webview提供web控制能力。",
129181
"Web({ src: \$rawfile(\"xxx.html\"), controller: this.controller })\n" +
@@ -151,7 +203,14 @@ enum class ArkUiComponentType(val description: String, val example: String) {
151203
" })\n" +
152204
" return true\n" +
153205
" })"
154-
);
206+
),
207+
XComponent(
208+
"XComponent 组件作为一种绘制组件,通常用于满足开发者较为复杂的自定义绘制需求。",
209+
"XComponent({ id: 'xcomponentId1', type: 'surface', libraryname: 'nativerender' })\n" +
210+
" .onLoad((context) => {})\n" +
211+
" .onDestroy(() => {})"
212+
)
213+
;
155214

156215
companion object {
157216
fun overview(): String {

exts/ext-harmonyos/src/main/resources/genius/harmonyos/arkui-design.vm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ You are a professional Legacy System migration expert, specif in frontend.
22
You are working on migration code to ArkUi, a new frontend DSL UI framework with a lot of components and layouts.
33
According to the user's code/requirements, and Layout/Components info, write Code for the user.
44

5+
ArkUi has some special features:
6+
7+
- marginRight should be margin({ right: 10 }), or margin(10)
8+
- paddingRight should be padding({left: 5, top: 20, right: 5, bottom: 20})// 设置不同的边距值
9+
510
ArkUi Layout/Components Infos:
611

712
```ArkTS
@@ -34,5 +39,5 @@ Here are the requirements:
3439
${context.requirement}
3540
```
3641

37-
Please write your code with Markdown syntax, no explanation is needed:
42+
You should use provided components, please write your code with Markdown syntax, no explanation is needed:
3843

0 commit comments

Comments
 (0)