Skip to content

Commit 4e40af6

Browse files
committed
feat(harmonyos): modify List component to include new features
The List component in `ArkUiLayoutType.kt` was modified to include new features such as space, initial index, list direction, divider, edge effects, and scroll index callback. These features enhance the functionality and customization options of the List component.
1 parent 9f9b228 commit 4e40af6

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,28 @@ enum class ArkUiLayoutType(val description: String, val example: String) {
6161
),
6262
List(
6363
"列表是一种复杂的容器,当列表项达到一定数量,内容超过屏幕大小时,可以自动提供滚动功能。",
64-
"List() {\n" +
65-
" ListItem() {\n" +
66-
" Text('北京').fontSize(24)\n" +
67-
" }\n" +
68-
" ListItem() {\n" +
69-
" Text('上海').fontSize(24)\n" +
70-
" }\n" +
64+
"List({ space: 20, initialIndex: 0 }) {\n" +
65+
" ForEach(this.arr, (item) => {\n" +
66+
" ListItem() {\n" +
67+
" Text(`\${item}`)\n" +
68+
" .fontSize(50)\n" +
69+
" .fontWeight(FontWeight.Bold)\n" +
70+
" .fontColor(['red', 'green', 'blue'][item % 3])\n" +
71+
" .padding({ left: '10', right: '10' })\n" +
72+
" .backgroundColor('white')\n" +
73+
" }\n" +
74+
" .backgroundColor('gray')\n" +
75+
" }, (item) => item)\n" +
7176
"}\n" +
72-
".width('100%').height('100%').backgroundColor('#FFF1F3F5').alignListItem(ListItemAlign.Center)"
77+
".listDirection(Axis.Vertical) // 排列方向 默认就是纵向排列\n" +
78+
".divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线,默认没有分界线\n" +
79+
".edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果\n" +
80+
".onScrollIndex((firstIndex: number, lastIndex: number) => {\n" +
81+
" console.info('first' + firstIndex)\n" +
82+
" console.info('last' + lastIndex)\n" +
83+
"})\n" +
84+
".width('100%')\n" +
85+
".height('100%')"
7386
),
7487
StackLayout(
7588
"层叠布局(StackLayout)用于在屏幕上预留一块区域来显示组件中的元素,提供元素可以重叠的布局。",

0 commit comments

Comments
 (0)