diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 18d2011e673acc805e8541eaabcd3b220268c539..66dce4ec9d823922c7fc09e25164a178cc4b1597 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -125,7 +125,6 @@ - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) - - [WaterFlow](ts-container-waterflow.md) - Media Components - [Video](ts-media-components-video.md) - Drawing Components diff --git a/en/application-dev/reference/arkui-ts/ts-components-summary.md b/en/application-dev/reference/arkui-ts/ts-components-summary.md index 19bc1f97eec987ec2e7b97f4507b3e8fc107f29d..5bc9050761a4e913be7d1df70a4f4361cb70b468 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/en/application-dev/reference/arkui-ts/ts-components-summary.md @@ -69,12 +69,6 @@ - [Swiper](ts-container-swiper.md) A container that is able to display child components in looping mode. -- [WaterFlow](ts-container-waterflow.md) - - A container that consists of cells formed by rows and columns and arranges items of different sizes from top to bottom according to the preset rules. -- [FlowItem](ts-container-flowitem.md) - - A child component of the **\** container that is used to display specific items in the container layout. ## Navigation diff --git a/en/application-dev/reference/arkui-ts/ts-container-flowitem.md b/en/application-dev/reference/arkui-ts/ts-container-flowitem.md deleted file mode 100644 index 71a0bf73f8e45100ea0ae7a5f4a5533486c056b4..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-flowitem.md +++ /dev/null @@ -1,31 +0,0 @@ -# FlowItem - - -**\** is a child component of the [\](ts-container-waterflow.md) container and is used to display specific items in the container layout. - - -> **NOTE** -> -> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. - - -## Child Components - - -This component supports only one child component. - - -## APIs - -FlowItem() - -Ceates a child component in the **\** layout. - - -## Attributes - -None - -## Example - -See [WaterFlow](ts-container-waterflow.md#example). diff --git a/en/application-dev/reference/arkui-ts/ts-container-scroll.md b/en/application-dev/reference/arkui-ts/ts-container-scroll.md index 14ed577d91fb25d1a797573dd045a7e2f7c86555..4ad560e029ae6ad0ab5573beb62b774b995c52ce 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/en/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -61,7 +61,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ## Scroller -Implements a controller for a scrollable container component. You can bind this component to a container component and use it to control the scrolling of that component. One controller can control only one container component. The supported container components are **\**, **\**, **\**, **\**, and **\**. +Implements a controller for a scrollable container component. You can bind this component to a container component and use it to control the scrolling of that component. One controller can control only one container component. The supported container components are **\**, **\**, **\**, **\**. ### Objects to Import diff --git a/en/application-dev/reference/arkui-ts/ts-container-waterflow.md b/en/application-dev/reference/arkui-ts/ts-container-waterflow.md deleted file mode 100644 index 68298be49f4f8d99223f4b8345cd64067fc30ce5..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-waterflow.md +++ /dev/null @@ -1,291 +0,0 @@ -# WaterFlow - - -The **\** component is a container that consists of cells formed by rows and columns and arranges items of different sizes from top to bottom according to the preset rules. - - -> **NOTE** -> -> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. - - -## Child Components - - -The [\](ts-container-flowitem.md) child component is supported. - - -## APIs - - -WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller}) - -**Parameters** - -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------------------- | ------ | -------------------------------------------- | -| footer | [CustomBuilder](ts-types.md#custombuilder8) | No | Footer of the **\** component. | -| scroller | [Scroller](ts-container-scroll.md#scroller) | No | Controller, which can be bound to scrollable components.
The **\** component supports only the **scrollToIndex** API of the **\** component.| - - -## Attributes - - -In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. - -| Name| Type| Description| -| -------- | -------- | -------- | -| columnsTemplate | string | Number of columns in the layout. If this attribute is not set, one column is used by default.
For example, **'1fr 1fr 2fr'** indicates three columns, with the first column taking up 1/4 of the parent component's full width, the second column 1/4, and the third column 2/4. This attribute supports [auto-fill](#auto-fill).
Default value: **'1fr'**| -| rowsTemplate | string | Number of rows in the layout. If this attribute is not set, one row is used by default.
For example, **'1fr 1fr 2fr'** indicates three rows, with the first row taking up 1/4 of the parent component's full height, the second row 1/4, and the third row 2/4. This attribute supports [auto-fill](#auto-fill).
Default value: **'1fr'**| -| itemConstraintSize | [ConstraintSizeOptions](ts-types.md#constraintsizeoptions) | Size constraints of the child components during layout. | -| columnsGap | Length |Gap between columns.
Default value: **0**| -| rowsGap | Length |Gap between rows.
Default value: **0**| -| layoutDirection | [FlexDirection](ts-appendix-enums.md#flexdirection) |Main axis direction of the layout.
Default value: **FlexDirection.Column**| - -The priority of **layoutDirection** is higher than that of **rowsTemplate** and **columnsTemplate**. Depending on the **layoutDirection** settings, there are three layout modes: - -- **layoutDirection** is set to **FlexDirection.Column** or **FlexDirection.ColumnReverse** - - In this case, **columnsTemplate** is valid. If it is not set, the default value is used. For example, if **columnsTemplate** is set to **"1fr 1fr"** and **rowsTemplate** **"1fr 1fr 1fr"**, child components are arranged in vertical layout, with the cross axis equally divided into two columns. - -- **layoutDirection** set to **FlexDirection.Row** or **FlexDirection.RowReverse** - - In this case, **rowsTemplate** is valid. If it is not set, the default value is used. For example, if **columnsTemplate** is set to **"1fr 1fr"** and **rowsTemplate** **"1fr 1fr 1fr"**, child components are arranged in horizontal layout, with the cross axis equally divided into three columns. - -- **layoutDirection** is not set - - In this case, the default value of **layoutDirection** is used, which is **FlexDirection.Column**, and **columnsTemplate** is valid. For example, if **columnsTemplate** is set to **"1fr 1fr"** and **rowsTemplate** **"1fr 1fr 1fr"**, child components are arranged in vertical layout, with the cross axis equally divided into two columns. - -## Events - - -In addition to the [universal events](ts-universal-events-click.md), the following events are supported. - - -| Name| Description| -| -------- | -------- | -| onReachStart(event: () => void) | Triggered when the component reaches the start.| -| onReachEnd(event: () => void) | Triggered when the component reaches the end.| - - -## auto-fill - -The **columnsTemplate** and **rowsTemplate** attributes supports **auto-fill** in the following format: - -```css -repeat(auto-fill, track-size) -``` - -Where, **repeat** and **auto-fill** are keywords, and **track-size** indicates the row height or column width. The supported units include px, vp, %, and digits. The value of **track-size** must contain at least one valid row height or column width. - - -## Example - - -```ts -// WaterFlowDataSource.ets - -// Object that implements the IDataSource API, which is used by the component to load data. -export class WaterFlowDataSource implements IDataSource { - - private dataArray: number[] = [] - private listeners: DataChangeListener[] = [] - - constructor() { - for (let i = 0; i < 100; i++) { - this.dataArray.push(i) - } - } - - // Obtain the data corresponding to the specified index. - public getData(index: number): any { - return this.dataArray[index] - } - - // Notify the controller of data reloading. - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded() - }) - } - - // Notify the controller of data addition. - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdded(index) - }) - } - - // Notify the controller of data changes. - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChanged(index) - }) - } - - // Notify the controller of data deletion. - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDeleted(index) - }) - } - - // Notify the controller of the data location change. - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMoved(from, to) - }) - } - - // Obtain the total number of data records. - public totalCount(): number { - return this.dataArray.length - } - - // Register the data change listener. - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener) - } - } - - // Unregister the data change listener. - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener) - if (pos >= 0) { - this.listeners.splice(pos, 1) - } - } - - // Add data. - public Add1stItem(): void { - this.dataArray.splice(0, 0, this.dataArray.length) - this.notifyDataAdd(0) - } - - // Add an item to the end of the data. - public AddLastItem(): void { - this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) - this.notifyDataAdd(this.dataArray.length-1) - } - - // Add an item to the position corresponding to the specified index. - public AddItem(index: number): void { - this.dataArray.splice(index, 0, this.dataArray.length) - this.notifyDataAdd(index) - } - - // Delete the first item. - public Delete1stItem(): void { - this.dataArray.splice(0, 1) - this.notifyDataDelete(0) - } - - // Delete the second item. - public Delete2ndItem(): void { - this.dataArray.splice(1, 1) - this.notifyDataDelete(1) - } - - // Delete the last item. - public DeleteLastItem(): void { - this.dataArray.splice(-1, 1) - this.notifyDataDelete(this.dataArray.length) - } - - // Reload data. - public Reload(): void { - this.dataArray.splice(1, 1) - this.dataArray.splice(3, 2) - this.notifyDataReload() - } -} -``` - -```ts -// WaterflowDemo.ets -import { WaterFlowDataSource } from './WaterFlowDataSource' - -@Entry -@Component -struct WaterflowDemo { - @State minSize: number = 50 - @State maxSize: number = 100 - @State fontSize: number = 24 - @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] - scroller: Scroller = new Scroller() - datasource: WaterFlowDataSource = new WaterFlowDataSource() - private itemWidthArray: number[] = [] - private itemHeightArray: number[] = [] - - // Calculate the width and height of a flow item. - getSize() { - let ret = Math.floor(Math.random() * this.maxSize) - return (ret > this.minSize ? ret : this.minSize) - } - - // Save the width and height of the flow item. - getItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()) - this.itemHeightArray.push(this.getSize()) - } - } - - aboutToAppear() { - this.getItemSizeArray() - } - - @Builder itemFoot() { - Column() { - Text(`Footer`) - .fontSize(10) - .backgroundColor(Color.Red) - .width(50) - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - } - } - - build() { - Column({ space: 2 }) { - WaterFlow({ footer: this.itemFoot, scroller: this.scroller }) { - LazyForEach(this.datasource, (item: number) => { - FlowItem() { - Column() { - Text("N" + item).fontSize(12).height('16') - Image('res/waterFlowTest(' + item % 5 + ').jpg') - .objectFit(ImageFit.Fill) - } - } - .width(this.itemWidthArray[item]) - .height(this.itemHeightArray[item]) - .backgroundColor(this.colors[item % 5]) - }, item => item) - } - .columnsTemplate("1fr 1fr 1fr 1fr") - .itemConstraintSize({ - minWidth: 0, - maxWidth: '100%', - minHeight: 0, - maxHeight: '100%' - }) - .columnsGap(10) - .rowsGap(5) - .onReachStart(() => { - console.info("onReachStart") - }) - .onReachEnd(() => { - console.info("onReachEnd") - }) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('80%') - .layoutDirection(FlexDirection.Column) - } - } -} -``` - -![en-us_image_WaterFlow.gif](figures/waterflow.gif) diff --git a/en/application-dev/ui/ui-ts-components-intro.md b/en/application-dev/ui/ui-ts-components-intro.md index 61d17d0084575d7d1835d29d8618bc67a893d0a2..764d1c141a09367d9c8a115a6fd344d7c514130e 100644 --- a/en/application-dev/ui/ui-ts-components-intro.md +++ b/en/application-dev/ui/ui-ts-components-intro.md @@ -7,7 +7,7 @@ The table below lists the components available in the declarative development pa | Component Type | Components | | ---------------------------- | ---------------------------------------------------------- | | [Basic components](../reference/arkui-ts/ts-basic-components-blank.md) | Blank, Button, Checkbox, CheckboxGroup, DataPanel, DatePicker, Divider, Gauge, Image, ImageAnimator, LoadingProgress, Marquee, Navigation, PatternLock, PluginComponent, Progress, QRCode, Radio, Rating, RemoteWindow, RichText, ScrollBar, Search, Select, Slider, Span, Stepper, StepperItem, Text, TextArea, TextClock, TextInput, TextPicker, TextTimer, TimePicker, Toggle, Web, XComponent | -| [Container components](../reference/arkui-ts/ts-container-ability-component.md) | AbilityComponent, AlphabetIndexer, Badge, Column, ColumnSplit, Counter, Flex, FlowItem, GridContainer, GridCol, GridRow, Grid, GridItem, List, ListItem, ListItemGroup, Navigator, Panel, Refresh, RelativeContainer, Row, RowSplit, Scroll, SideBarContainer, Stack, Swiper, Tabs, TabContent, WaterFlow | +| [Container components](../reference/arkui-ts/ts-container-ability-component.md) | AbilityComponent, AlphabetIndexer, Badge, Column, ColumnSplit, Counter, Flex, FlowItem, GridContainer, GridCol, GridRow, Grid, GridItem, List, ListItem, ListItemGroup, Navigator, Panel, Refresh, RelativeContainer, Row, RowSplit, Scroll, SideBarContainer, Stack, Swiper, Tabs, TabContent | | [Media components](../reference/arkui-ts/ts-media-components-video.md)| Video | | [Drawing components](../reference/arkui-ts/ts-drawing-components-circle.md)| Circle, Ellipse, Line, Polyline, Polygon, Path, Rect, Shape | | [Canvas components](../reference/arkui-ts/ts-components-canvas-canvas.md)| Canvas | diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 22372d596c6ead11a925f9633d02571197b1d621..0cd30b40d8d18c3d03c1652549617160759e4bf6 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -582,7 +582,6 @@ - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [WaterFlow](reference/arkui-ts/ts-container-waterflow.md) - Media Component - [Video](reference/arkui-ts/ts-media-components-video.md) - Drawing Components diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 6c332986211035fec322160debb82f7b331f9262..c74f7ee0954487a5e886b2d10004c9e2af37458a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -125,7 +125,6 @@ - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) - - [WaterFlow](ts-container-waterflow.md) - 媒体组件 - [Video](ts-media-components-video.md) - 绘制组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md index 6504c28f9530a96cc49e936c6f884e7859e12187..1becf8095e670afa88849f400616a5183be6afb8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md @@ -69,12 +69,6 @@ - [Swiper](ts-container-swiper.md) 滑块视图容器组件,提供子组件滑动轮播显示的能力。 -- [WaterFlow](ts-container-waterflow.md) - - 瀑布流容器组件,由“行”和“列”分割的单元格所组成,通过容器自身的排列规则,将不同大小的“项目”自上而下,如瀑布般紧密布局。 -- [FlowItem](ts-container-flowitem.md) - - 瀑布流组件WaterFlow的子组件,用来展示瀑布流具体item。 ## 导航 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-flowitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-flowitem.md deleted file mode 100644 index 4628ea7bb51de907d3b1ace994e25c80d1e100b3..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-flowitem.md +++ /dev/null @@ -1,31 +0,0 @@ -# FlowItem - - -[瀑布流组件](ts-container-waterflow.md)的子组件,用来展示瀑布流具体item。 - - -> **说明:** -> -> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 子组件 - - -支持单个子组件。 - - -## 接口 - -FlowItem() - -使用该接口来创建瀑布流子组件。 - - -## 属性 - -无 - -## 示例 - -详见[瀑布流组件示例](ts-container-waterflow.md#示例)。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index bd8d15720086142ef5ce0d40c497bfff2a5730d0..540a21c07f9d6c6f1da471c7f8a76f306e758bf1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -61,7 +61,7 @@ Scroll(scroller?: Scroller) ## Scroller -可滚动容器组件的控制器,可以将此组件绑定至容器组件,然后通过它控制容器组件的滚动,同一个控制器不可以控制多个容器组件,目前支持绑定到List、Scroll、ScrollBar、Grid、WaterFlow上。 +可滚动容器组件的控制器,可以将此组件绑定至容器组件,然后通过它控制容器组件的滚动,同一个控制器不可以控制多个容器组件,目前支持绑定到List、Scroll、ScrollBar、Grid上。 ### 导入对象 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-waterflow.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-waterflow.md deleted file mode 100644 index 8be87f8269e96ba280ae5a236231e7b8bd1b1a27..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-waterflow.md +++ /dev/null @@ -1,294 +0,0 @@ -# WaterFlow - - -瀑布流容器,由“行”和“列”分割的单元格所组成,通过容器自身的排列规则,将不同大小的“项目”自上而下,如瀑布般紧密布局。 - - -> **说明:** -> -> 该组件从API Version 9 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 子组件 - - -包含[FlowItem](ts-container-flowitem.md)子组件。 - -> **说明:** -> -> WaterFlow子组件的visibility属性设置为None时不显示,但依然会占用子组件对应的网格。 - -## 接口 - - -WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller}) - -**参数:** - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| ---------- | ----------------------------------------------- | ------ | -------------------------------------------- | -| footer | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置WaterFlow尾部组件。 | -| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器,与可滚动组件绑定。
目前瀑布流仅支持Scroller组件的scrollToIndex接口。 | - - -## 属性 - - -除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: - -| 名称 | 参数类型 | 描述 | -| -------- | -------- | -------- | -| 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' | -| itemConstraintSize | [ConstraintSizeOptions](ts-types.md#constraintsizeoptions) | 设置约束尺寸,子组件布局时,进行尺寸范围限制。 | -| columnsGap | Length |设置列与列的间距。
默认值:0| -| rowsGap | Length |设置行与行的间距。
默认值:0| -| layoutDirection | [FlexDirection](ts-appendix-enums.md#flexdirection) |设置布局的主轴方向。
默认值:FlexDirection.Column| - -layoutDirection优先级高于rowsTemplate和columnsTemplate。根据layoutDirection设置情况,分为以下三种设置模式: - -- layoutDirection设置纵向布局(FlexDirection.Column 或 FlexDirection.ColumnReverse) - - 此时columnsTemplate有效(如果未设置,取默认值)。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,瀑布流组件纵向布局,辅轴均分成横向2列。 - -- layoutDirection设置横向布局(FlexDirection.Row 或 FlexDirection.RowReverse) - - 此时rowsTemplate有效(如果未设置,取默认值)。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,瀑布流组件横向布局,辅轴均分成纵向3列。 - -- layoutDirection未设置布局方向 - - 布局方向为layoutDirection的默认值:FlexDirection.Column,此时columnsTemplate有效。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,瀑布流组件纵向布局,辅轴均分成横向2列。 - -## 事件 - - -除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: - - -| 名称 | 功能描述 | -| -------- | -------- | -| onReachStart(event: () => void) | 瀑布流组件到达起始位置时触发。 | -| onReachEnd(event: () => void) | 瀑布流组件到底末尾位置时触发。 | - - -## auto-fill说明 - -WaterFlow的columnsTemplate、rowsTemplate属性的auto-fill仅支持以下格式: - -```css -repeat(auto-fill, track-size) -``` - -其中repeat、auto-fill为关键字。track-size为行高或者列宽,支持的单位包括px、vp、%或有效数字,track-size至少包括一个有效行高或者列宽。 - - -## 示例 - - -```ts -// WaterFlowDataSource.ets - -// 实现IDataSource接口的对象,用于瀑布流组件加载数据 -export class WaterFlowDataSource implements IDataSource { - - private dataArray: number[] = [] - private listeners: DataChangeListener[] = [] - - constructor() { - for (let i = 0; i < 100; i++) { - this.dataArray.push(i) - } - } - - // 获取索引对应的数据 - public getData(index: number): any { - return this.dataArray[index] - } - - // 通知控制器数据重新加载 - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded() - }) - } - - // 通知控制器数据增加 - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdded(index) - }) - } - - // 通知控制器数据变化 - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChanged(index) - }) - } - - // 通知控制器数据删除 - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDeleted(index) - }) - } - - // 通知控制器数据位置变化 - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMoved(from, to) - }) - } - - // 获取数据总数 - public totalCount(): number { - return this.dataArray.length - } - - // 注册改变数据的控制器 - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener) - } - } - - // 注销改变数据的控制器 - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener) - if (pos >= 0) { - this.listeners.splice(pos, 1) - } - } - - // 增加数据 - public Add1stItem(): void { - this.dataArray.splice(0, 0, this.dataArray.length) - this.notifyDataAdd(0) - } - - // 在数据尾部增加一个元素 - public AddLastItem(): void { - this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) - this.notifyDataAdd(this.dataArray.length-1) - } - - // 在指定索引位置增加一个元素 - public AddItem(index: number): void { - this.dataArray.splice(index, 0, this.dataArray.length) - this.notifyDataAdd(index) - } - - // 删除第一个元素 - public Delete1stItem(): void { - this.dataArray.splice(0, 1) - this.notifyDataDelete(0) - } - - // 删除第二个元素 - public Delete2ndItem(): void { - this.dataArray.splice(1, 1) - this.notifyDataDelete(1) - } - - // 删除最后一个元素 - public DeleteLastItem(): void { - this.dataArray.splice(-1, 1) - this.notifyDataDelete(this.dataArray.length) - } - - // 重新加载数据 - public Reload(): void { - this.dataArray.splice(1, 1) - this.dataArray.splice(3, 2) - this.notifyDataReload() - } -} -``` - -```ts -// WaterflowDemo.ets -import { WaterFlowDataSource } from './WaterFlowDataSource' - -@Entry -@Component -struct WaterflowDemo { - @State minSize: number = 50 - @State maxSize: number = 100 - @State fontSize: number = 24 - @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] - scroller: Scroller = new Scroller() - datasource: WaterFlowDataSource = new WaterFlowDataSource() - private itemWidthArray: number[] = [] - private itemHeightArray: number[] = [] - - // 计算flow item宽/高 - getSize() { - let ret = Math.floor(Math.random() * this.maxSize) - return (ret > this.minSize ? ret : this.minSize) - } - - // 保存flow item宽/高 - getItemSizeArray() { - for (let i = 0; i < 100; i++) { - this.itemWidthArray.push(this.getSize()) - this.itemHeightArray.push(this.getSize()) - } - } - - aboutToAppear() { - this.getItemSizeArray() - } - - @Builder itemFoot() { - Column() { - Text(`Footer`) - .fontSize(10) - .backgroundColor(Color.Red) - .width(50) - .height(50) - .align(Alignment.Center) - .margin({ top: 2 }) - } - } - - build() { - Column({ space: 2 }) { - WaterFlow({ footer: this.itemFoot, scroller: this.scroller }) { - LazyForEach(this.datasource, (item: number) => { - FlowItem() { - Column() { - Text("N" + item).fontSize(12).height('16') - Image('res/waterFlowTest(' + item % 5 + ').jpg') - .objectFit(ImageFit.Fill) - } - } - .width(this.itemWidthArray[item]) - .height(this.itemHeightArray[item]) - .backgroundColor(this.colors[item % 5]) - }, item => item) - } - .columnsTemplate("1fr 1fr 1fr 1fr") - .itemConstraintSize({ - minWidth: 0, - maxWidth: '100%', - minHeight: 0, - maxHeight: '100%' - }) - .columnsGap(10) - .rowsGap(5) - .onReachStart(() => { - console.info("onReachStart") - }) - .onReachEnd(() => { - console.info("onReachEnd") - }) - .backgroundColor(0xFAEEE0) - .width('100%') - .height('80%') - .layoutDirection(FlexDirection.Column) - } - } -} -``` - -![zh-cn_image_WaterFlow.gif](figures/waterflow.gif) diff --git a/zh-cn/application-dev/ui/ui-ts-components-intro.md b/zh-cn/application-dev/ui/ui-ts-components-intro.md index 4ad77eeebffe934c49971db9f402d4970a1b5e31..72663acebdf766682c7986ff893185702f853e83 100644 --- a/zh-cn/application-dev/ui/ui-ts-components-intro.md +++ b/zh-cn/application-dev/ui/ui-ts-components-intro.md @@ -7,7 +7,7 @@ | 组件类型 | 主要组件 | | ---------------------------- | ---------------------------------------------------------- | | [基础组件](../reference/arkui-ts/ts-basic-components-blank.md) | Blank、Button、Checkbox、CheckboxGroup、DataPanel、DatePicker、Divider、Gauge、Image、ImageAnimator、LoadingProgress、Marquee、Navigation、PatternLock、PluginComponent、Progress、QRCode、Radio、Rating、RemoteWindow、RichText、ScrollBar、Search、Select、Slider、Span、Stepper、StepperItem、Text、TextArea、TextClock、TextInput、TextPicker、TextTimer、TimePicker、Toggle、Web、XComponent | -| [容器组件](../reference/arkui-ts/ts-container-ability-component.md) | AbilityComponent、AlphabetIndexer、Badge、Column、ColumnSplit、Counter、Flex、FlowItem、GridContainer、GridCol、GridRow、Grid、GridItem、List、ListItem、ListItemGroup、Navigator、Panel、Refresh、RelativeContainer、Row、RowSplit、Scroll、SideBarContainer、Stack、Swiper、Tabs、TabContent、WaterFlow | +| [容器组件](../reference/arkui-ts/ts-container-ability-component.md) | AbilityComponent、AlphabetIndexer、Badge、Column、ColumnSplit、Counter、Flex、FlowItem、GridContainer、GridCol、GridRow、Grid、GridItem、List、ListItem、ListItemGroup、Navigator、Panel、Refresh、RelativeContainer、Row、RowSplit、Scroll、SideBarContainer、Stack、Swiper、Tabs、TabContent | | [媒体组件](../reference/arkui-ts/ts-media-components-video.md) | Video | | [绘制组件](../reference/arkui-ts/ts-drawing-components-circle.md) | Circle、Ellipse、Line、Polyline、Polygon、Path、Rect、Shape | | [画布组件](../reference/arkui-ts/ts-components-canvas-canvas.md) | Canvas | diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 00a5aef15712105dc5b9bad5591ad0f6738dc470..3b59a7938d6a4be44e2a1fd19dd8f50e38669aa9 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -636,7 +636,6 @@ - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [WaterFlow](reference/arkui-ts/ts-container-waterflow.md) - 媒体组件 - [Video](reference/arkui-ts/ts-media-components-video.md) - 绘制组件