From ce03a32b775c83c183208c47fa6266d8ef610ac7 Mon Sep 17 00:00:00 2001 From: limeng Date: Fri, 16 Sep 2022 15:52:25 +0800 Subject: [PATCH] commit according to LiAn & LuoYing's suggestions Signed-off-by: limeng --- .../arkui-ts/figures/grid-autofill.png | Bin 0 -> 15610 bytes .../reference/arkui-ts/ts-container-grid.md | 63 +++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 zh-cn/application-dev/reference/arkui-ts/figures/grid-autofill.png diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/grid-autofill.png b/zh-cn/application-dev/reference/arkui-ts/figures/grid-autofill.png new file mode 100644 index 0000000000000000000000000000000000000000..c45eee033be4548744fd84bbcb5ba29d17868e69 GIT binary patch literal 15610 zcmeHO2V9d^yN9Ap6$!112n2AUhzeC?$ZSxyObyCR6%-I6B73V8scdCL5ZOUCA`lRS zh!_H*?3u`rh|Gwr$Oy?jiQ1aldhNa6cfYUS?e7=yN633}&Uv5r`H$y0*9`SFdDaT9 z<>27p(bhU*%)!BF$HDPc&Np9ycWxRSO9B6Jx)^J!aTGMc#=tMDY~gxv4vwNoZrZ8U z;P*8bv`k$%IH0x6f1CuTEE^6ErAX}~@Z+9Vl*F1GnG-i|PvwrTKDg0)^<}FcQi^_% zZte(gNl|X$j``L#a`G}f{ea!+K$)!9ruL`9C*k++!UZ>nsKr3k@26%%lZAaYgglK_ zwAMWP+)cP>;oG+wXIF}vh+bV)jDcrfiw@bxB?J(7BZ=6jIYZ*HI%g5iF*;(!Ir2J~ z8>R-KWF(!2PG(F8Cs!}cPcf*X{%@W9)oF_!s?()7`urW_N(B#Z)^cPv>vezL-||9_b4>3SQXdF_CH?14TTXyF;|qa{}J6LI5wD>VQ3# zusOLH%9LO@Bl$|!av69xqaykIpn0+uKcN}7c#0OumfT^9eI6#)8Q%CMWXf* zoHA`zl<{~#>AED;R9!+|ygn!4x#mmB4R`C5w%oaG7_d0TtI8nr1}sE^PkD?DZDz>D zNJPMY`G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qq!Nj>&K=WB7 z$-V&o_!0!AiJ}JBwrc>zdt1)~JwYN^YH6Oh3)MuFwRQzXf|n)B;A?9Y7s5ba*~3 z6nte}J@WAm2s+~aV^HdKis92^>c+mss>;^zrtWxF8o<+M4tUm>+#4}OY z;Z8d_n4+^rt4MDj@*Gt1c8&eyO-m>8uKVv5H=)jxWAw74RLxpY`h9mk#G&O7YGCsz z{QfPxq_qwdtT}4^1ZXERKmWEYDNvVS0XV>Lc=h?IA9{xDV46DUq?M|9jt>n`KF%d_ zwm!tKr}0I8Hxi1-xQv5&z;ZXY3J=tUSe%)>`68UIc=QTC#Q9tMWm24={)bI3lrF`bY<6E|5+_ryO(C=zhXZE_8D~jPu>YO)c9Nguyc_wb6r04enC(v zq3OVKPk49O5COv&H{?lxE@hjzRC(z6eX%;(t}S0P-?m3WP=?Giid47XzEQg11yhoU z)xjWhLcn10A01^}Hlry)MZlk86zl?-?Lb#ATq1F+Q*|R>nYWB+wX~laY+EGS>kHotJ^} z?-P%08)x`31_BsmjPFCpBLlRD{1vXwhR7`B!Mdp}kT?0f*}9egqMwf$w90_86&W>t zg2_G4q?$673`xqPf6dSD0_eBt0Yh8#LdeOCg例如, '1fr 1fr 2fr' 是将父组件分3列,将父组件允许的宽分为4等份,第一列占1份,第二列占1份,第三列占2份。
默认值:'1fr' | -| rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。
例如, '1fr 1fr 2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。
默认值:'1fr' | +| columnsTemplate | string | 设置当前网格布局列的数量,不设置时默认1列。
例如, '1fr 1fr 2fr' 是将父组件分3列,将父组件允许的宽分为4等份,第一列占1份,第二列占1份,第三列占2份。并支持[auto-fill](#auto-fill说明)。
默认值:'1fr' | +| rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。
例如, '1fr 1fr 2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。并支持[auto-fill](#auto-fill说明)。
默认值:'1fr' | | columnsGap | Length | 设置列与列的间距。
默认值:0 | | rowsGap | Length | 设置行与行的间距。
默认值:0 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off | @@ -65,6 +65,16 @@ Grid(scroller?: Scroller) | onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void) | 拖拽离开网格元素时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 拖拽离开的网格元素索引值。 | | onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) | 绑定该事件的网格元素可作为拖拽释放目标,当在网格元素内停止拖拽时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 拖拽起始位置。
- insertIndex: 拖拽插入位置。
- isSuccess: 是否成功释放。 | +## auto-fill说明 + +Grid的columnsTemplate、rowsTemplate属性的auto-fill仅支持以下格式: + +```css +repeat(auto-fill, track-size) +``` + +其中repeat、auto-fill为关键字。track-size为行高或者列宽,支持的单位包括px、vp、%或有效数字,track-size至少包括一个有效行高或者列宽。 + ## ItemDragInfo对象说明 | 名称 | 类型 | 描述 | @@ -134,4 +144,51 @@ struct GridExample { } ``` -![zh-cn_image_0000001219744183](figures/zh-cn_image_0000001219744183.gif) \ No newline at end of file +![zh-cn_image_0000001219744183](figures/zh-cn_image_0000001219744183.gif) + +**auto-fill示例** + +```ts +// grid-autofill.ets +@Entry +@Component +struct Index { + @State gridItemWidth: string = "100%" + @State gridItemHeight: string = "100%" + @State gridWidth: string = "100%" + @State gridHeight: string = "100%" + @State itemList: string[] = [] + build() { + Column() { + Grid() { + ForEach(this.itemList, (item) => { + GridItem() { + Text(item.toString()) + .fontSize(16) + .width('100%') + .textAlign(TextAlign.Center) + } + .width(this.gridItemWidth) + .height(this.gridItemHeight) + .backgroundColor(0xF9CF93) + }, item => item) + } + .columnsGap(1) + .rowsGap(1) + .border({ width: 4, color: 0xffdb7093, style: BorderStyle.Dashed, radius: 5 }) + .width(this.gridWidth) + .height(this.gridHeight) + .columnsTemplate("15% repeat(auto-fill, 10% 50px 20%) 50px") + .rowsTemplate("150px repeat(auto-fill, 20% 25%)") + }.margin(5) + } + + aboutToAppear() { + for(var i = 1; i < 50; i++) { + this.itemList.push(i.toString()) + } + } +} +``` + +![grid-autofill](figures/grid-autofill.png) \ No newline at end of file -- GitLab