From 3db73e9a077fa229a3ce4ffee2efd3addaa2e841 Mon Sep 17 00:00:00 2001 From: rekirt Date: Sat, 30 Aug 2025 13:53:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0readme=E5=92=8Ccopyright?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterFlowSample/README.md | 19 +++++++++++++++++++ .../ets/common/constants/CommonConstants.ets | 2 +- .../main/ets/entryability/EntryAbility.ets | 15 +++++++++++++++ .../entrybackupability/EntryBackupAbility.ets | 15 +++++++++++++++ .../entry/src/main/ets/model/MyDataSource.ets | 1 + .../main/ets/pages/CustomItemHeightPage.ets | 15 +++++++++++++++ .../src/main/ets/pages/DataLoadMorePage.ets | 15 +++++++++++++++ .../ets/pages/DataUpadteAndAnimationPage.ets | 15 +++++++++++++++ .../src/main/ets/pages/ElementByOrderPage.ets | 15 +++++++++++++++ .../src/main/ets/pages/FadingEdgePage.ets | 15 +++++++++++++++ .../main/ets/pages/FlowItemAutoPlayPage.ets | 15 +++++++++++++++ .../ets/pages/FlowItemRmoveAnimationPage.ets | 15 +++++++++++++++ .../src/main/ets/pages/FlowItemRmovePage.ets | 15 +++++++++++++++ .../main/ets/pages/ForceShowOnTopLeftPage.ets | 15 +++++++++++++++ .../entry/src/main/ets/pages/Index.ets | 1 - .../ets/pages/MergeDoubleWaterFlowPage.ets | 15 +++++++++++++++ .../main/ets/pages/SectionOptionsUsePage.ets | 15 +++++++++++++++ .../src/main/ets/pages/StickOnTopPage.ets | 15 +++++++++++++++ .../main/ets/pages/ZoomChangeColumnPage.ets | 15 +++++++++++++++ .../entry/src/main/ets/utils/WindowUtil.ets | 2 +- 20 files changed, 247 insertions(+), 3 deletions(-) create mode 100644 WaterFlowSample/README.md diff --git a/WaterFlowSample/README.md b/WaterFlowSample/README.md new file mode 100644 index 00000000..d8f32c0a --- /dev/null +++ b/WaterFlowSample/README.md @@ -0,0 +1,19 @@ +# 常见瀑布流操作 + +### 简介 + +本示例基于WaterFlow组件的特性,整理了瀑布流常见操作的示例代码。 + +### 相关权限 + +不涉及 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机。 + +2.HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。 + +3.DevEco Studio版本:DevEco Studio 5.0.5 Release及以上。 + +4.HarmonyOS SDK版本:HarmonyOS 5.0.5 Release SDK及以上。 \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/common/constants/CommonConstants.ets b/WaterFlowSample/entry/src/main/ets/common/constants/CommonConstants.ets index a6ba20f2..5de6c0e9 100644 --- a/WaterFlowSample/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/WaterFlowSample/entry/src/main/ets/common/constants/CommonConstants.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets index a1b9d910..eac02998 100644 --- a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets +++ b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; diff --git a/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index fae19f9d..1fca37ec 100644 --- a/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { hilog } from '@kit.PerformanceAnalysisKit'; import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; diff --git a/WaterFlowSample/entry/src/main/ets/model/MyDataSource.ets b/WaterFlowSample/entry/src/main/ets/model/MyDataSource.ets index 540edfc0..ceef0cc5 100644 --- a/WaterFlowSample/entry/src/main/ets/model/MyDataSource.ets +++ b/WaterFlowSample/entry/src/main/ets/model/MyDataSource.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { BasicDataSource } from "./BasicDataSource"; export class MyDataSource extends BasicDataSource { diff --git a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets index 95b6dd02..bf51f3f0 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; // [StartExclude flow_item_layout] diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets index a5796056..63b36a2c 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets index 577a7a7e..89e5fcaa 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; diff --git a/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets index 2cabc98a..06f953b9 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { CommonConstants } from '../common/constants/CommonConstants'; @Entry diff --git a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets index 6826eed2..66ae7e2c 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets index 6606e901..a109868f 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/constants/CommonConstants'; diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets index a38c698c..de352726 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets index 870d96ac..39fd4513 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; // [StartExclude flow_item_layout] diff --git a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets index a711b368..24ad635d 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from '../common/constants/CommonConstants'; import { MyDataSource } from '../model/MyDataSource' diff --git a/WaterFlowSample/entry/src/main/ets/pages/Index.ets b/WaterFlowSample/entry/src/main/ets/pages/Index.ets index 05cb67b4..e92c9301 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/Index.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/Index.ets @@ -13,7 +13,6 @@ * limitations under the License. */ - @Entry @Component struct Index { diff --git a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets index 54cb0e86..9e259d3b 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from '../common/constants/CommonConstants'; import { MyDataSource } from '../model/MyDataSource' diff --git a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets index 12137c6a..86f8ec47 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; diff --git a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets index 929dc3ed..ff5b1cb6 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/constants/CommonConstants'; diff --git a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets index aef08e29..f000305f 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // [Start quick_start] import { MyDataSource } from '../model/MyDataSource' import { image } from '@kit.ImageKit'; diff --git a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets index f711a36f..535ac139 100644 --- a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets +++ b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee From e971d84c0d01ee104f874f63dba0ac55729f5741 Mon Sep 17 00:00:00 2001 From: rekirt Date: Sat, 6 Sep 2025 14:56:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=82=E9=85=8Dide=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E5=8F=8A=E8=87=AA=E6=A3=80=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterFlowSample/README.md | 35 +++++++++++++++++++ WaterFlowSample/build-profile.json5 | 4 +-- .../main/ets/entryability/EntryAbility.ets | 6 +++- .../main/ets/pages/CustomItemHeightPage.ets | 10 ++++-- .../src/main/ets/pages/DataLoadMorePage.ets | 20 +++++++---- .../ets/pages/DataUpadteAndAnimationPage.ets | 27 ++++++++------ .../src/main/ets/pages/ElementByOrderPage.ets | 6 ++-- .../src/main/ets/pages/FadingEdgePage.ets | 17 +++++---- .../main/ets/pages/FlowItemAutoPlayPage.ets | 13 ++++--- .../ets/pages/FlowItemRmoveAnimationPage.ets | 21 +++++++---- .../src/main/ets/pages/FlowItemRmovePage.ets | 21 ++++++----- .../main/ets/pages/ForceShowOnTopLeftPage.ets | 9 +++-- .../ets/pages/MergeDoubleWaterFlowPage.ets | 11 +++--- .../main/ets/pages/SectionOptionsUsePage.ets | 14 +++++--- .../src/main/ets/pages/StickOnTopPage.ets | 14 ++++++-- .../main/ets/pages/ZoomChangeColumnPage.ets | 12 ++++--- .../entry/src/main/ets/utils/WindowUtil.ets | 26 +++++++++----- WaterFlowSample/entry/src/main/module.json5 | 5 +-- 18 files changed, 187 insertions(+), 84 deletions(-) diff --git a/WaterFlowSample/README.md b/WaterFlowSample/README.md index d8f32c0a..90b36e1d 100644 --- a/WaterFlowSample/README.md +++ b/WaterFlowSample/README.md @@ -4,6 +4,41 @@ 本示例基于WaterFlow组件的特性,整理了瀑布流常见操作的示例代码。 +### 工程目录 +``` +├─entry/src/main/ets +│ ├─common/constants +│ │ └─CommonConstants.ets // 常量类 +│ ├─entryability +│ │ └─EntryAbility.ets // 入口文件 +│ ├─entrybackupability +│ │ └─EntryBackupAbility.ets // backup +│ ├─model +│ │ ├─BasicDataSource.ets // 基类DataSource +│ │ ├─MediaItem.ets // 媒体实体类 +│ │ ├─MyDataSource.ets // 我的DataSource +│ │ ├─SectionsWaterFlowDataSource.ets // 分组DataSource +│ │ └─StickyWaterFlowDataSource.ets // 吸顶DataSource +│ ├─pages +│ │ ├─CustomItemHeightPage.ets // 自定义分组和高度页面 +│ │ ├─DataLoadMorePage.ets // 加载更多页面 +│ │ ├─DataUpadteAndAnimationPage.ets // 下拉刷新页面 +│ │ ├─ElementByOrderPage.ets // 元素分类页面 +│ │ ├─FadingEdgePage.ets // 边缘渐隐页面 +│ │ ├─FlowItemAutoPlayPage.ets // 停止自动播放页面 +│ │ ├─FlowItemRmoveAnimationPage.ets // 移除item带动画页面 +│ │ ├─FlowItemRmovePage.ets // 移除item页面 +│ │ ├─ForceShowOnTopLeftPage.ets // 强制左上角显示页面 +│ │ ├─Index.ets // 主页 +│ │ ├─MergeDoubleWaterFlowPage.ets // 合并两个瀑布流页面 +│ │ ├─SectionOptionsUsePage.ets // 分组功能页面 +│ │ ├─StickOnTopPage.ets // 吸顶功能页面 +│ │ └─ZoomChangeColumnPage.ets // 缩放改变列数页面 +│ └─utils +│ └─WindowUtil.ets // 窗口工具类 +└─entry/src/main/resources // 应用资源目录 +``` + ### 相关权限 不涉及 diff --git a/WaterFlowSample/build-profile.json5 b/WaterFlowSample/build-profile.json5 index 3897adc5..7cfdffbb 100644 --- a/WaterFlowSample/build-profile.json5 +++ b/WaterFlowSample/build-profile.json5 @@ -6,8 +6,8 @@ { "name": "default", "signingConfig": "default", - "targetSdkVersion": "5.0.2(14)", - "compatibleSdkVersion": "5.0.2(14)", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", "runtimeOS": "HarmonyOS", "buildOption": { "strictMode": { diff --git a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets index eac02998..b6b0dcb6 100644 --- a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets +++ b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -22,8 +22,12 @@ const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(0x0000, 'testTag', 'Failed to setColorMode. Cause: %{public}s', JSON.stringify(err) ?? ''); + } } onDestroy(): void { diff --git a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets index bf51f3f0..c72e67e6 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets @@ -15,6 +15,7 @@ // [Start quick_start] import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -75,6 +76,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -123,12 +125,12 @@ export struct CustomItemHeightPage { } }; - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } @@ -139,7 +141,7 @@ export struct CustomItemHeightPage { this.initSections(); } - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -181,6 +183,8 @@ export struct CustomItemHeightPage { .layoutWeight(1) } } + // [EndExclude method_declare] } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets index 63b36a2c..b1b6abb5 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets @@ -16,6 +16,7 @@ // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -76,6 +77,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -135,7 +137,7 @@ struct DataLoadMorePage { .justifyContent(FlexAlign.Center) } - refresh() { + refresh(): void { this.currentItem = -1; setTimeout(() => { // Add new data. @@ -159,18 +161,18 @@ struct DataLoadMorePage { }, 2000); } - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -199,7 +201,7 @@ struct DataLoadMorePage { let newSection: SectionOptions; let tmpIndex = 0; let sectionIndex = 0; - for(let i = 0; i < sections.length; i++) { + for (let i = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -218,16 +220,17 @@ struct DataLoadMorePage { this.setItemSizeArray(); this.initSections(); } + // [EndExclude variable_declare] build() { Column({ space: 0 }) { - Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh()}) { + Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh() }) { WaterFlow({ scroller: this.scroller, sections: this.sections }) { // [StartExclude water_flow_data] LazyForEach(this.dataSource, (item: number) => { FlowItem() { Stack() { - Row(){ + Row() { Button('Delete') .fontColor(Color.Red) .backgroundColor(Color.White) @@ -244,6 +247,7 @@ struct DataLoadMorePage { .zIndex(1) .visibility(this.currentItem === item ? Visibility.Visible : Visibility.Hidden) .backgroundColor('#33000000') + ReusableFlowItem({ item: item }) } } @@ -285,6 +289,7 @@ struct DataLoadMorePage { .onRefreshing(() => { this.refresh(); }) + // [EndExclude refresh] } .padding({ @@ -292,4 +297,5 @@ struct DataLoadMorePage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets index 89e5fcaa..8f822627 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataUpadteAndAnimationPage.ets @@ -16,6 +16,7 @@ // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -73,6 +74,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -87,7 +89,6 @@ struct DataUpadteAndAnimationPage { private itemHeightArray: number[] = []; @State sections: WaterFlowSections = new WaterFlowSections(); @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; - sectionMargin: Margin = { top: 8, left: 16, @@ -120,6 +121,7 @@ struct DataUpadteAndAnimationPage { return this.itemHeightArray[index % 100]; } }; + // [EndExclude variable_declare] // 1、Refresh Loading Animation Component. @Builder @@ -135,7 +137,7 @@ struct DataUpadteAndAnimationPage { } // 5、Pull down to refresh the data update logic. - refresh() { + refresh(): void { this.currentItem = -1; setTimeout(() => { // Add new data. @@ -159,7 +161,7 @@ struct DataUpadteAndAnimationPage { }, 2000); } - loadMore(last: number) { + loadMore(last: number): void { setTimeout(() => { let totalCount = this.dataSource.totalCount(); if (last + 20 >= totalCount) { @@ -172,19 +174,20 @@ struct DataUpadteAndAnimationPage { } }, 1000); } + // [StartExclude section_init] - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -213,7 +216,7 @@ struct DataUpadteAndAnimationPage { let newSection: SectionOptions; let tmpIndex = 0; let sectionIndex = 0; - for(let i = 0; i < sections.length; i++) { + for (let i = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -232,6 +235,7 @@ struct DataUpadteAndAnimationPage { this.setItemSizeArray(); this.initSections(); } + // [EndExclude section_init] build() { Column({ space: 0 }) { @@ -240,16 +244,17 @@ struct DataUpadteAndAnimationPage { .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '8vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '8vp' }) } + // 2、Pull-to-refresh control. - Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh()}) { + Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh() }) { // [StartExclude water_flow_init] WaterFlow({ scroller: this.scroller, sections: this.sections }) { LazyForEach(this.dataSource, (item: number) => { FlowItem() { Stack() { - Row(){ + Row() { Button('Delete') .fontColor(Color.Red) .backgroundColor(Color.White) @@ -266,6 +271,7 @@ struct DataUpadteAndAnimationPage { .zIndex(1) .visibility(this.currentItem === item ? Visibility.Visible : Visibility.Hidden) .backgroundColor('#33000000') + ReusableFlowItem({ item: item }) } } @@ -303,4 +309,5 @@ struct DataUpadteAndAnimationPage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets index 06f953b9..cb533a3c 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ElementByOrderPage.ets @@ -34,7 +34,7 @@ struct ElementByOrderPage { ForEach(this.data1, (item: string) => { if (item === '1') { Text('item' + item + - this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height')) + ':' + + this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height').id) + ':' + this.getHeight(item).toString()) .id('item' + item) .alignRules({ @@ -46,7 +46,7 @@ struct ElementByOrderPage { .backgroundColor(this.colors[Number(item) - 1]) } else if (item === '2') { Text('item' + item + - this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height')) + ':' + + this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height').id) + ':' + this.getHeight(item).toString()) .id('item' + item) .alignRules({ @@ -58,7 +58,7 @@ struct ElementByOrderPage { .backgroundColor(this.colors[Number(item) - 1]) } else { Text('item' + item + - this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height')) + ':' + + this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.item_height').id) + ':' + this.getHeight(item).toString()) .id('item' + item) .alignRules({ diff --git a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets index 66ae7e2c..585ceced 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets @@ -23,7 +23,7 @@ import { LengthMetrics } from '@kit.ArkUI'; struct ReusableFlowItem { @State item: number = 0; - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item; } @@ -75,6 +75,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -95,7 +96,6 @@ struct FadingEdgePage { // 1、Create group information. @State sections: WaterFlowSections = new WaterFlowSections(); @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; - // 2、Create the first group. oneColumnSection: SectionOptions = { itemsCount: 3, @@ -125,16 +125,17 @@ struct FadingEdgePage { } // [StartExclude method_declare] - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } + // [EndExclude method_declare] aboutToAppear() { @@ -143,7 +144,7 @@ struct FadingEdgePage { } // 5、Initialise group data. - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -172,8 +173,9 @@ struct FadingEdgePage { .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '8vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '8vp' }) } + // 6、Link the grouping information to WaterFlow. WaterFlow({ scroller: this.scroller, sections: this.sections }) { // [StartExclude water_flow_data] @@ -194,11 +196,12 @@ struct FadingEdgePage { .height('100%') .layoutWeight(1) .scrollBar(BarState.On) - .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80)}) + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80) }) } .padding({ top: this.statusBarHeight }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets index a109868f..56763280 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets @@ -72,7 +72,8 @@ struct FlowVideoItem { }) .id('image') - Stack() {} + Stack() { + } .linearGradient({ angle: 0, colors: [['#80000000', 0.0], @@ -105,10 +106,12 @@ struct FlowVideoItem { .width('100%') .borderRadius(8) .backgroundColor(Color.Gray) + // [EndExclude image_item] } } } + // [StartExclude water_flow_init] @Entry @Component @@ -161,12 +164,12 @@ struct FlowItemAutoPlayPage { return result; } - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); @@ -197,8 +200,9 @@ struct FlowItemAutoPlayPage { .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '16vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '16vp' }) } + WaterFlow({ scroller: this.scroller, sections: this.sections }) { LazyForEach(this.dataSource, (item: MediaItem) => { FlowItem() { @@ -222,5 +226,6 @@ struct FlowItemAutoPlayPage { }) } } + // [EndExclude water_flow_init] // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets index de352726..5d6b224a 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmoveAnimationPage.ets @@ -16,6 +16,7 @@ // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -73,6 +74,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -132,7 +134,7 @@ struct FlowItemRmoveAnimationPage { .justifyContent(FlexAlign.Center) } - refresh() { + refresh(): void { this.currentItem = -1; setTimeout(() => { // Add new data. @@ -156,18 +158,18 @@ struct FlowItemRmoveAnimationPage { }, 2000); } - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -201,7 +203,7 @@ struct FlowItemRmoveAnimationPage { let newSection: SectionOptions; let tmpIndex = 0; let sectionIndex = 0; - for(let i = 0; i < sections.length; i++) { + for (let i = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -215,15 +217,16 @@ struct FlowItemRmoveAnimationPage { } this.sections.update(sectionIndex, newSection); } + // [EndExclude variable_declare] build() { Column({ space: 0 }) { - Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh()}) { + Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh() }) { WaterFlow({ scroller: this.scroller, sections: this.sections }) { LazyForEach(this.dataSource, (item: number) => { FlowItem() { Stack() { - Row(){ + Row() { Button($r('app.string.delete')) .fontColor(Color.Red) .backgroundColor(Color.White) @@ -242,6 +245,7 @@ struct FlowItemRmoveAnimationPage { .zIndex(1) .visibility(this.currentItem === item ? Visibility.Visible : Visibility.Hidden) .backgroundColor('#33000000') + ReusableFlowItem({ item: item }) // [EndExclude row_setting] } @@ -278,6 +282,7 @@ struct FlowItemRmoveAnimationPage { } }, 1000); }) + // [EndExclude water_flow_setting] } // [StartExclude water_flow_refresh] @@ -285,6 +290,7 @@ struct FlowItemRmoveAnimationPage { .onRefreshing(() => { this.refresh(); }) + // [EndExclude water_flow_refresh] } .padding({ @@ -292,4 +298,5 @@ struct FlowItemRmoveAnimationPage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets index 39fd4513..ea2e70b2 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRmovePage.ets @@ -15,6 +15,7 @@ // [Start quick_start] import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -72,13 +73,13 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component struct FlowItemRmoveAnimationPage { // 1、Select the index of the FlowItem. @State currentItem: number = -1; - // [StartExclude variable_declare] @State isRefreshing: boolean = false; @State minSize: number = 80; @@ -132,7 +133,7 @@ struct FlowItemRmoveAnimationPage { .justifyContent(FlexAlign.Center) } - refresh() { + refresh(): void { this.currentItem = -1; setTimeout(() => { // Add new data. @@ -156,18 +157,18 @@ struct FlowItemRmoveAnimationPage { }, 2000); } - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -193,6 +194,7 @@ struct FlowItemRmoveAnimationPage { this.setItemSizeArray(); this.initSections(); } + // [EndExclude variable_declare] removeItem(item: number): void { // 5、Delete source data. @@ -203,7 +205,7 @@ struct FlowItemRmoveAnimationPage { let newSection: SectionOptions; let tmpIndex = 0; let sectionIndex = 0; - for(let i = 0; i < sections.length; i++) { + for (let i = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -220,13 +222,13 @@ struct FlowItemRmoveAnimationPage { build() { Column({ space: 0 }) { - Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh()}) { + Refresh({ refreshing: $$this.isRefreshing, builder: this.headerRefresh() }) { WaterFlow({ scroller: this.scroller, sections: this.sections }) { LazyForEach(this.dataSource, (item: number) => { FlowItem() { Stack() { // 3、Delete button. - Row(){ + Row() { Button('Delete') .fontColor(Color.Red) .backgroundColor(Color.White) @@ -244,6 +246,7 @@ struct FlowItemRmoveAnimationPage { .zIndex(1) .visibility(this.currentItem === item ? Visibility.Visible : Visibility.Hidden) .backgroundColor('#33000000') + ReusableFlowItem({ item: item }) } } @@ -284,8 +287,10 @@ struct FlowItemRmoveAnimationPage { .onRefreshing(() => { this.refresh(); }) + // [EndExclude water_flow_setting] } } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets index 24ad635d..712b2c13 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets @@ -25,20 +25,22 @@ struct ForceShowOnTopLeftPage { @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; aboutToAppear(): void { - for(let i = 0; i < 80; i++) { + for (let i = 0; i < 80; i++) { this.data.pushData(i); } } + // [EndExclude data_init] build() { - Column({ space: 0}) { + Column({ space: 0 }) { Row() { Text($r('app.string.force_left_show')) .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '16vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '16vp' }) } + WaterFlow() { // 1、Add the layout content in the top left corner of WaterFlow. FlowItem() { @@ -86,4 +88,5 @@ struct ForceShowOnTopLeftPage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets index 9e259d3b..0a107c8d 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets @@ -63,19 +63,19 @@ struct MergeDoubleWaterFlowPage { } }; - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } aboutToAppear(): void { - for(let i = 0; i < 100; i++) { + for (let i = 0; i < 100; i++) { this.data.pushData(i); } this.setItemSizeArray(); @@ -85,6 +85,7 @@ struct MergeDoubleWaterFlowPage { sectionOptions.push(this.lastSection); this.sections.splice(0, 0, sectionOptions); } + // [EndExclude data_init] build() { Column({ space: 2 }) { @@ -93,8 +94,9 @@ struct MergeDoubleWaterFlowPage { .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '12vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '12vp' }) } + WaterFlow({ scroller: this.scroller, sections: this.sections }) { LazyForEach(this.data, (item: number) => { FlowItem() { @@ -136,4 +138,5 @@ struct MergeDoubleWaterFlowPage { .backgroundColor('#efefef') } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets index 86f8ec47..0200f6c8 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets @@ -16,6 +16,7 @@ // [Start quick_start] import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; + // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @@ -73,6 +74,7 @@ struct ReusableFlowItem { .backgroundColor(Color.Gray) } } + // [EndExclude flow_item_layout] @Entry @Component @@ -93,7 +95,6 @@ struct SectionOptionsUsePage { // 1、Create group information. @State sections: WaterFlowSections = new WaterFlowSections(); @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; - // 2、Create the first group. oneColumnSection: SectionOptions = { itemsCount: 3, @@ -123,16 +124,17 @@ struct SectionOptionsUsePage { } // [StartExclude method_declare] - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } + // [EndExclude method_declare] aboutToAppear() { @@ -141,7 +143,7 @@ struct SectionOptionsUsePage { } // 5、Initialise group data. - initSections() { + initSections(): void { let sectionOptions: SectionOptions[] = []; let count = 0; let oneOrTwo = 0; @@ -170,8 +172,9 @@ struct SectionOptionsUsePage { .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) - .margin({ top: '18vp', left: '16vp', bottom: '8vp'}) + .margin({ top: '18vp', left: '16vp', bottom: '8vp' }) } + // 6、Link the grouping information to WaterFlow. WaterFlow({ scroller: this.scroller, sections: this.sections }) { // [StartExclude water_flow_data] @@ -197,4 +200,5 @@ struct SectionOptionsUsePage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets index ff5b1cb6..25149c30 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets @@ -20,6 +20,7 @@ import MediaItem, { ItemType } from '../model/MediaItem'; import { StickyWaterFlowDataSource } from '../model/StickyWaterFlowDataSource'; const TAG = 'StickyPage'; + // [StartExclude item_layout] @Component struct FlowVideoItem { @@ -68,7 +69,8 @@ struct FlowVideoItem { right: { anchor: '__container__', align: HorizontalAlign.End } }) - Stack() {} + Stack() { + } .linearGradient({ angle: 0, colors: [['#80000000', 0.0], @@ -102,6 +104,7 @@ struct FlowVideoItem { } } } + // [EndExclude item_layout] @Component export struct StickyPage { @@ -147,6 +150,7 @@ export struct StickyPage { return 250; } }; + // [StartExclude section_init] getResourceStringArray(resource: Resource): Array { let result: Array = new Array(); @@ -158,12 +162,12 @@ export struct StickyPage { return result; } - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); @@ -186,6 +190,7 @@ export struct StickyPage { } this.sections.splice(-1, 0, sectionOptions); } + // [EndExclude section_init] build() { Stack({ alignContent: Alignment.TopStart }) { @@ -334,6 +339,7 @@ export struct StickyPage { right: 16 }) }.alignItems(HorizontalAlign.Start) + // [EndExclude stick_content] } .width('100%') @@ -345,6 +351,7 @@ export struct StickyPage { } } } + // [StartExclude homepage] @Entry @Component @@ -451,5 +458,6 @@ struct StickOnTopPage { }) } } + // [EndExclude homepage] // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets index f000305f..3214e0e2 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets @@ -41,6 +41,7 @@ struct ReusableItem { } } } + // [EndExclude flow_item] @Entry @Component @@ -68,12 +69,12 @@ struct ZoomChangeColumnPage { private oldColumn: number = this.columns; // [StartExclude section_init] - getSize() { + getSize(): number { let ret = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } - setItemSizeArray() { + setItemSizeArray(): void { for (let i = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); @@ -81,7 +82,7 @@ struct ZoomChangeColumnPage { } aboutToAppear(): void { - for(let i = 0; i < 100; i++) { + for (let i = 0; i < 100; i++) { this.data.pushData(i); } let lastCount = AppStorage.get('columnsCount'); @@ -90,9 +91,10 @@ struct ZoomChangeColumnPage { } this.setItemSizeArray(); } + // [EndExclude section_init] // 7、Adjust the number of columns according to the zoom ratio. - changeColumns(scale: number) { + changeColumns(scale: number): void { this.oldColumn = this.columns; if (scale > (this.columns / (this.columns - 0.5))) { this.columns--; @@ -114,6 +116,7 @@ struct ZoomChangeColumnPage { .fontWeight(FontWeight.Bold) .margin({ top: '18vp', left: '16vp', bottom: '16vp' }) } + // [EndExclude title] Stack() { // 2、Display the current screen's snapshot when zooming. @@ -213,4 +216,5 @@ struct ZoomChangeColumnPage { }) } } + // [End quick_start] \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets index 535ac139..4034146b 100644 --- a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets +++ b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets @@ -55,19 +55,27 @@ export class WindowUtil { } private static updateAvoidArea(windowObj: window.Window) { - WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, - windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); - WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, - windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)); + try { + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)); + } catch (err) { + hilog.error(0x0000, 'testTag', 'getWindowAvoidArea get exception. Cause: %{public}s', JSON.stringify(err) ?? ''); + } } // Get status bar height and indicator height. private static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { - let uiContext = WindowUtil.windowClass.getUIContext(); - if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT, uiContext.px2vp(area.topRect.height)); - } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT, uiContext.px2vp(area.bottomRect.height)); + try { + let uiContext = WindowUtil.windowClass.getUIContext(); + if (type === window.AvoidAreaType.TYPE_SYSTEM) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT, uiContext.px2vp(area.topRect.height)); + } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT, uiContext.px2vp(area.bottomRect.height)); + } + } catch (err) { + hilog.error(0x0000, 'testTag', 'getUIContext get exception. Cause: %{public}s', JSON.stringify(err) ?? ''); } } } \ No newline at end of file diff --git a/WaterFlowSample/entry/src/main/module.json5 b/WaterFlowSample/entry/src/main/module.json5 index f88d8407..3b66f735 100644 --- a/WaterFlowSample/entry/src/main/module.json5 +++ b/WaterFlowSample/entry/src/main/module.json5 @@ -5,10 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1", - "wearable" + "phone" ], "deliveryWithInstall": true, "installationFree": false, -- Gitee