Skip to content

Commit 9f9b228

Browse files
committed
feat(harmonyos): improve LinearLayout and RelativeContainer layouts
- Improve the description of LinearLayout and add more specific examples. - Update the code in LinearLayout to use Column containers and set specific width and height properties. - Update RelativeContainer code to remove irrelevant alignRules and add example code instead.
1 parent 805048d commit 9f9b228

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ enum class ArkUiLayoutType(val description: String, val example: String) {
1515
"}.width('100%').margin({ top: 5 })"
1616
),
1717
LinearLayout(
18-
"Row/Column即线性布局(LinearLayout)是开发中最常用的布局,通过线性容器Row和Column构建。",
19-
"Column({ space: 20 }) {\n" +
20-
" Text('space: 20').fontSize(15).fontColor(Color.Gray).width('90%')\n" +
21-
" Row().width('90%').height(50).backgroundColor(0xF5DEB3)\n" +
22-
" Row().width('90%').height(50).backgroundColor(0xD2B48C)\n" +
23-
" Row().width('90%').height(50).backgroundColor(0xF5DEB3)\n" +
24-
"}.width('100%')"
18+
"Row/Column 即线性布局(LinearLayout)是开发中最常用的布局,通过线性容器 Row 和 Column 构建。",
19+
"Row({}) {\n" +
20+
" Column() {\n" +
21+
" // ...\n" +
22+
" }.width('20%').height(30).backgroundColor(0xF5DEB3)\n" +
23+
"\n" +
24+
" Column() {\n" +
25+
" // ...\n" +
26+
" }.width('20%').height(30).backgroundColor(0xD2B48C)\n" +
27+
"\n" +
28+
" Column() {\n" +
29+
" // ...\n" +
30+
" }.width('20%').height(30).backgroundColor(0xF5DEB3)\n" +
31+
"}.width('100%').height(200).alignItems(VerticalAlign.Center).backgroundColor('rgb(242,242,242)')"
2532
),
2633
RelativeContainer(
2734
"RelativeContainer为采用相对布局的容器,支持容器内部的子元素设置相对位置关系。",
@@ -35,12 +42,7 @@ enum class ArkUiLayoutType(val description: String, val example: String) {
3542
" .id(\"row1\")\n" +
3643
"\n" +
3744
" Row()\n" +
38-
" ...\n" +
39-
" .alignRules({\n" +
40-
" top: { anchor: '__container__', align: VerticalAlign.Top },\n" +
41-
" right: { anchor: '__container__', align: HorizontalAlign.End }\n" +
42-
" })\n" +
43-
" .id(\"row2\")\n" +
45+
" // ...\n" +
4446
"}\n" +
4547
"..."
4648
),
@@ -64,9 +66,6 @@ enum class ArkUiLayoutType(val description: String, val example: String) {
6466
" Text('北京').fontSize(24)\n" +
6567
" }\n" +
6668
" ListItem() {\n" +
67-
" Text('杭州').fontSize(24)\n" +
68-
" }\n" +
69-
" ListItem() {\n" +
7069
" Text('上海').fontSize(24)\n" +
7170
" }\n" +
7271
"}\n" +
@@ -94,7 +93,7 @@ enum class ArkUiLayoutType(val description: String, val example: String) {
9493
companion object {
9594
fun overview(): String {
9695
return ArkUiLayoutType.values().joinToString("\n") {
97-
it.name + ":" + it.description
96+
it.name + ":" + it.description
9897
}
9998
}
10099

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ArkUi has some special features:
66

77
- marginRight should be `margin({ right: 10 })`, or `margin(10)`
88
- paddingRight should be `padding({left: 5, top: 20, right: 5, bottom: 20})` // 设置不同的边距值
9+
- width and height should be length | percentage, like: `width('80%')` and `height(200)`
910
- list data should use `ForEach`, like: `ForEach(this.numbers, (num: string) => { Text(num) })`
1011
- layout should use `width` and `height` properties, like `.width('80%').height(200)`
1112

0 commit comments

Comments
 (0)