From 2bc75985f1b594228f36908f592a58ebab806170 Mon Sep 17 00:00:00 2001 From: rekirt Date: Thu, 25 Sep 2025 20:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterFlowSample/README.md | 7 ++++ .../main/ets/entryability/EntryAbility.ets | 2 +- .../entrybackupability/EntryBackupAbility.ets | 2 +- .../src/main/ets/model/BasicDataSource.ets | 2 +- .../ets/model/SectionsWaterFlowDataSource.ets | 4 +-- .../ets/model/StickyWaterFlowDataSource.ets | 14 ++++---- .../main/ets/pages/CustomItemHeightPage.ets | 10 +++--- .../src/main/ets/pages/DataLoadMorePage.ets | 32 ++++++++--------- .../ets/pages/DataUpdateAndAnimationPage.ets | 30 ++++++++-------- .../src/main/ets/pages/FadingEdgePage.ets | 12 +++---- .../main/ets/pages/FlowItemAutoPlayPage.ets | 12 +++---- .../ets/pages/FlowItemRemoveAnimationPage.ets | 32 ++++++++--------- .../src/main/ets/pages/FlowItemRemovePage.ets | 34 +++++++++---------- .../main/ets/pages/ForceShowOnTopLeftPage.ets | 2 +- .../ets/pages/MergeDoubleWaterFlowPage.ets | 6 ++-- .../main/ets/pages/SectionOptionsUsePage.ets | 12 +++---- .../src/main/ets/pages/StickOnTopPage.ets | 14 ++++---- .../main/ets/pages/ZoomChangeColumnPage.ets | 12 +++---- .../entry/src/main/ets/utils/WindowUtil.ets | 8 ++--- WaterFlowSample/oh-package.json5 | 2 -- 20 files changed, 127 insertions(+), 122 deletions(-) diff --git a/WaterFlowSample/README.md b/WaterFlowSample/README.md index 90b36e1d..2496e0a5 100644 --- a/WaterFlowSample/README.md +++ b/WaterFlowSample/README.md @@ -38,6 +38,13 @@ │ └─WindowUtil.ets // 窗口工具类 └─entry/src/main/resources // 应用资源目录 ``` +### 原理 + +不涉及 + +### 使用说明 + +不涉及 ### 相关权限 diff --git a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets index b6b0dcb6..f4a3f755 100644 --- a/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets +++ b/WaterFlowSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -18,7 +18,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; import { WindowUtil } from '../utils/WindowUtil'; -const DOMAIN = 0x0000; +const DOMAIN: number = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { diff --git a/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 1fca37ec..75e36ae2 100644 --- a/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/WaterFlowSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -16,7 +16,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; -const DOMAIN = 0x0000; +const DOMAIN: number = 0x0000; export default class EntryBackupAbility extends BackupExtensionAbility { async onBackup() { diff --git a/WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets b/WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets index 05ed97fb..b20ee5ad 100644 --- a/WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets +++ b/WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets @@ -32,7 +32,7 @@ export class BasicDataSource implements IDataSource { } unregisterDataChangeListener(listener: DataChangeListener): void { - const position = this.listeners.indexOf(listener); + const position: number = this.listeners.indexOf(listener); if (position >= 0) { this.listeners.splice(position, 1); } diff --git a/WaterFlowSample/entry/src/main/ets/model/SectionsWaterFlowDataSource.ets b/WaterFlowSample/entry/src/main/ets/model/SectionsWaterFlowDataSource.ets index f3323707..75d88d17 100644 --- a/WaterFlowSample/entry/src/main/ets/model/SectionsWaterFlowDataSource.ets +++ b/WaterFlowSample/entry/src/main/ets/model/SectionsWaterFlowDataSource.ets @@ -18,7 +18,7 @@ export class SectionsWaterFlowDataSource implements IDataSource { private listeners: DataChangeListener[] = []; constructor() { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.dataArray.push(i); } } @@ -68,7 +68,7 @@ export class SectionsWaterFlowDataSource implements IDataSource { } unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); + const pos: number = this.listeners.indexOf(listener); if (pos >= 0) { this.listeners.splice(pos, 1); } diff --git a/WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets b/WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets index 50183a00..706c82e1 100644 --- a/WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets +++ b/WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets @@ -23,8 +23,8 @@ export class StickyWaterFlowDataSource implements IDataSource { private listeners: DataChangeListener[] = []; constructor() { - for (let i = 0; i < 100; i++) { - let mediaItem = this.createMediaItem(i); + for (let i: number = 0; i < 100; i++) { + let mediaItem: MediaItem = this.createMediaItem(i); this.dataArray.push(mediaItem); } } @@ -72,7 +72,7 @@ export class StickyWaterFlowDataSource implements IDataSource { * @param {DataChangeListener} listener Data change listener */ unregisterDataChangeListener(listener: DataChangeListener): void { - let pos = this.listeners.indexOf(listener); + let pos: number = this.listeners.indexOf(listener); if (pos >= 0) { this.listeners.splice(pos, 1); } @@ -89,15 +89,15 @@ export class StickyWaterFlowDataSource implements IDataSource { * */ public addLastItem() { - let mediaItem = this.createMediaItem(this.dataArray.length); + let mediaItem: MediaItem = this.createMediaItem(this.dataArray.length); this.dataArray.splice(this.dataArray.length, 0, mediaItem); this.notifyDataAdd(this.dataArray.length - 1); } createMediaItem(i: number): MediaItem { - let videoName = `video_sample${(i % 5) + 1}`; - let imageName = `${(i % 4)}`; - let type = (i % 3 === 0) ? ItemType.VIDEO : ItemType.IMAGE; + let videoName: string = `video_sample${(i % 5) + 1}`; + let imageName: string = `${(i % 4)}`; + let type: ItemType = (i % 3 === 0) ? ItemType.VIDEO : ItemType.IMAGE; return new MediaItem(i, type, $rawfile(`covers/${videoName}.png`), $rawfile(`${videoName}.mp4`), $rawfile(`sections/${imageName}.jpg`)); diff --git a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets index c72e67e6..17ac9f9c 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/CustomItemHeightPage.ets @@ -126,12 +126,12 @@ export struct CustomItemHeightPage { }; getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } @@ -143,9 +143,9 @@ export struct CustomItemHeightPage { initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets index 6e4f6f99..2fc31991 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataLoadMorePage.ets @@ -18,14 +18,14 @@ import { hilog } from "@kit.PerformanceAnalysisKit"; import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; -const TAG = 'DataLoadMorePage'; +const TAG: string = 'DataLoadMorePage'; // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @State item: number = 0; - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item; } @@ -129,7 +129,7 @@ struct DataLoadMorePage { } @Builder - headerRefresh() { + headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) @@ -145,8 +145,8 @@ struct DataLoadMorePage { setTimeout(() => { // Add new data. this.dataSource.dataArray = []; - let value = Math.floor(Math.random() * 100); - for (let i = 0; i < 100; i++) { + let value: number = Math.floor(Math.random() * 100); + for (let i: number = 0; i < 100; i++) { this.dataSource.dataArray.push(i + value); this.dataSource.notifyDataAdd(i); } @@ -165,21 +165,21 @@ struct DataLoadMorePage { } getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; @@ -198,13 +198,13 @@ struct DataLoadMorePage { } removeItem(item: number): void { - let index = this.dataSource.indexOf(item); + let index: number = this.dataSource.indexOf(item); this.dataSource.deleteItem(index); const sections: Array = this.sections.values(); let newSection: SectionOptions; - let tmpIndex = 0; - let sectionIndex = 0; - for (let i = 0; i < sections.length; i++) { + let tmpIndex: number = 0; + let sectionIndex: number = 0; + for (let i: number = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -278,11 +278,11 @@ struct DataLoadMorePage { // For better experience, pre load data. .onScrollIndex((first: number, last: number) => { // 1、Obtain the total amount of data in the waterfall flow. - let totalCount = this.dataSource.totalCount(); + let totalCount: number = this.dataSource.totalCount(); // 2、If the index of the last visible area is greater than the total amount of data, it triggers loading more. if (last + 20 >= totalCount) { // 3、Re-add 20 data entries to the waterfall. - for (let i = 0; i < 20; i++) { + for (let i: number = 0; i < 20; i++) { this.dataSource.addLastItem(); } // 4、Update the itemsCount in the group and refresh the group information. diff --git a/WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets index fe5b72f0..a8bc4a49 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets @@ -18,7 +18,7 @@ import { hilog } from "@kit.PerformanceAnalysisKit"; import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; -const TAG = 'DataUpdateAndAnimationPage'; +const TAG: string = 'DataUpdateAndAnimationPage'; // [StartExclude flow_item_layout] @Reusable @@ -128,7 +128,7 @@ struct DataUpdateAndAnimationPage { // [EndExclude variable_declare] // 1、Refresh Loading Animation Component. @Builder - headerRefresh() { + headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) @@ -145,8 +145,8 @@ struct DataUpdateAndAnimationPage { setTimeout(() => { // Add new data. this.dataSource.dataArray = []; - let value = Math.floor(Math.random() * 100); - for (let i = 0; i < 100; i++) { + let value: number = Math.floor(Math.random() * 100); + for (let i: number = 0; i < 100; i++) { this.dataSource.dataArray.push(i + value); this.dataSource.notifyDataAdd(i); } @@ -166,9 +166,9 @@ struct DataUpdateAndAnimationPage { loadMore(last: number): void { setTimeout(() => { - let totalCount = this.dataSource.totalCount(); + let totalCount: number = this.dataSource.totalCount(); if (last + 20 >= totalCount) { - for (let i = 0; i < 20; i++) { + for (let i: number = 0; i < 20; i++) { this.dataSource.addLastItem(); } // Update sections itemsCount. @@ -180,21 +180,21 @@ struct DataUpdateAndAnimationPage { // [StartExclude section_init] getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; @@ -213,13 +213,13 @@ struct DataUpdateAndAnimationPage { } removeItem(item: number): void { - let index = this.dataSource.indexOf(item); + let index: number = this.dataSource.indexOf(item); this.dataSource.deleteItem(index); const sections: Array = this.sections.values(); let newSection: SectionOptions; - let tmpIndex = 0; - let sectionIndex = 0; - for (let i = 0; i < sections.length; i++) { + let tmpIndex: number = 0; + let sectionIndex: number = 0; + for (let i: number = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; diff --git a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets index ed16509a..b5445130 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets @@ -126,19 +126,19 @@ struct FadingEdgePage { // [StartExclude method_declare] getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } // [EndExclude method_declare] - aboutToAppear() { + aboutToAppear(): void { this.setItemSizeArray(); this.initSections(); } @@ -146,9 +146,9 @@ struct FadingEdgePage { // 5、Initialise group data. initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets index 56763280..da170fc9 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemAutoPlayPage.ets @@ -19,14 +19,14 @@ import { CommonConstants } from '../common/constants/CommonConstants'; import MediaItem, { ItemType } from '../model/MediaItem'; import { StickyWaterFlowDataSource } from '../model/StickyWaterFlowDataSource'; -const TAG = 'FlowItemAutoPlayPage'; +const TAG: string = 'FlowItemAutoPlayPage'; @Component struct FlowVideoItem { @Prop item: MediaItem; controller: VideoController = new VideoController(); - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item as MediaItem; } @@ -165,12 +165,12 @@ struct FlowItemAutoPlayPage { } getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); } @@ -179,8 +179,8 @@ struct FlowItemAutoPlayPage { aboutToAppear() { this.setItemSizeArray(); let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; + let count: number = 0; + let oneOrTwo: number = 0; while (count < 100) { if (oneOrTwo++ % 2 === 0) { sectionOptions.push(this.oneColumnSection); diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemoveAnimationPage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemoveAnimationPage.ets index 8e4eb40c..08dd9279 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemoveAnimationPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemoveAnimationPage.ets @@ -18,14 +18,14 @@ import { hilog } from "@kit.PerformanceAnalysisKit"; import { CommonConstants } from "../common/constants/CommonConstants"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; -const TAG = 'FlowItemRemoveAnimationPage'; +const TAG: string = 'FlowItemRemoveAnimationPage'; // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @State item: number = 0; - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item; } @@ -126,7 +126,7 @@ struct FlowItemRemoveAnimationPage { } @Builder - headerRefresh() { + headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) @@ -142,8 +142,8 @@ struct FlowItemRemoveAnimationPage { setTimeout(() => { // Add new data. this.dataSource.dataArray = []; - let value = Math.floor(Math.random() * 100); - for (let i = 0; i < 100; i++) { + let value: number = Math.floor(Math.random() * 100); + for (let i: number = 0; i < 100; i++) { this.dataSource.dataArray.push(i + value); this.dataSource.notifyDataAdd(i); } @@ -162,21 +162,21 @@ struct FlowItemRemoveAnimationPage { } getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; @@ -200,13 +200,13 @@ struct FlowItemRemoveAnimationPage { } removeItem(item: number): void { - let index = this.dataSource.indexOf(item); + let index: number = this.dataSource.indexOf(item); this.dataSource.deleteItem(index); const sections: Array = this.sections.values(); let newSection: SectionOptions; - let tmpIndex = 0; - let sectionIndex = 0; - for (let i = 0; i < sections.length; i++) { + let tmpIndex: number = 0; + let sectionIndex: number = 0; + for (let i: number = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -278,9 +278,9 @@ struct FlowItemRemoveAnimationPage { // For better experience, pre load data. .onScrollIndex((first: number, last: number) => { setTimeout(() => { - let totalCount = this.dataSource.totalCount(); + let totalCount: number = this.dataSource.totalCount(); if (last + 20 >= totalCount) { - for (let i = 0; i < 20; i++) { + for (let i: number = 0; i < 20; i++) { this.dataSource.addLastItem(); } // Update sections itemsCount. diff --git a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemovePage.ets b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemovePage.ets index 08e17dd1..269829cb 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemovePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/FlowItemRemovePage.ets @@ -17,14 +17,14 @@ import { hilog } from "@kit.PerformanceAnalysisKit"; import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSource"; -const TAG = 'FlowItemRemovePage'; +const TAG: string = 'FlowItemRemovePage'; // [StartExclude flow_item_layout] @Reusable struct ReusableFlowItem { @State item: number = 0; - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item; } @@ -125,7 +125,7 @@ struct FlowItemRemovePage { } @Builder - headerRefresh() { + headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) @@ -141,8 +141,8 @@ struct FlowItemRemovePage { setTimeout(() => { // Add new data. this.dataSource.dataArray = []; - let value = Math.floor(Math.random() * 100); - for (let i = 0; i < 100; i++) { + let value: number = Math.floor(Math.random() * 100); + for (let i: number = 0; i < 100; i++) { this.dataSource.dataArray.push(i + value); this.dataSource.notifyDataAdd(i); } @@ -161,21 +161,21 @@ struct FlowItemRemovePage { } getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; @@ -193,7 +193,7 @@ struct FlowItemRemovePage { this.sections.splice(0, 0, sectionOptions); } - aboutToAppear() { + aboutToAppear(): void { this.setItemSizeArray(); this.initSections(); } @@ -201,14 +201,14 @@ struct FlowItemRemovePage { // [EndExclude variable_declare] removeItem(item: number): void { // 5、Delete source data. - let index = this.dataSource.indexOf(item); + let index: number = this.dataSource.indexOf(item); this.dataSource.deleteItem(index); // 6、Update the itemsCount quantity in the group and refresh. const sections: Array = this.sections.values(); let newSection: SectionOptions; - let tmpIndex = 0; - let sectionIndex = 0; - for (let i = 0; i < sections.length; i++) { + let tmpIndex: number = 0; + let sectionIndex: number = 0; + for (let i: number = 0; i < sections.length; i++) { tmpIndex += sections[i].itemsCount; if (index < tmpIndex) { sectionIndex = i; @@ -278,9 +278,9 @@ struct FlowItemRemovePage { // For better experience, pre load data. .onScrollIndex((first: number, last: number) => { setTimeout(() => { - let totalCount = this.dataSource.totalCount(); + let totalCount: number = this.dataSource.totalCount(); if (last + 20 >= totalCount) { - for (let i = 0; i < 20; i++) { + for (let i: number = 0; i < 20; i++) { this.dataSource.addLastItem(); } // Update sections itemsCount. diff --git a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets index 712b2c13..e12d5d9b 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ForceShowOnTopLeftPage.ets @@ -25,7 +25,7 @@ struct ForceShowOnTopLeftPage { @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; aboutToAppear(): void { - for (let i = 0; i < 80; i++) { + for (let i: number = 0; i < 80; i++) { this.data.pushData(i); } } diff --git a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets index 0a107c8d..19dfba6f 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/MergeDoubleWaterFlowPage.ets @@ -64,18 +64,18 @@ struct MergeDoubleWaterFlowPage { }; getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } aboutToAppear(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.data.pushData(i); } this.setItemSizeArray(); diff --git a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets index 0200f6c8..5f93de32 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/SectionOptionsUsePage.ets @@ -22,7 +22,7 @@ import { SectionsWaterFlowDataSource } from "../model/SectionsWaterFlowDataSourc struct ReusableFlowItem { @State item: number = 0; - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item; } @@ -125,12 +125,12 @@ struct SectionOptionsUsePage { // [StartExclude method_declare] getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemHeightArray.push(this.getSize()); } } @@ -145,9 +145,9 @@ struct SectionOptionsUsePage { // 5、Initialise group data. initSections(): void { let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; - let dataCount = this.dataSource.totalCount(); + let count: number = 0; + let oneOrTwo: number = 0; + let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; diff --git a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets index c659a7c7..8c00942e 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/StickOnTopPage.ets @@ -19,7 +19,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; import MediaItem, { ItemType } from '../model/MediaItem'; import { StickyWaterFlowDataSource } from '../model/StickyWaterFlowDataSource'; -const TAG = 'StickOnTopPage'; +const TAG: string = 'StickOnTopPage'; // [StartExclude item_layout] @Component @@ -27,7 +27,7 @@ struct FlowVideoItem { @Prop item: MediaItem; controller: VideoController = new VideoController(); - aboutToReuse(params: Record) { + aboutToReuse(params: Record): void { this.item = params.item as MediaItem; } @@ -163,12 +163,12 @@ export struct StickyPage { } getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); } @@ -177,8 +177,8 @@ export struct StickyPage { aboutToAppear() { this.setItemSizeArray(); let sectionOptions: SectionOptions[] = []; - let count = 0; - let oneOrTwo = 0; + let count: number = 0; + let oneOrTwo: number = 0; while (count < 100) { if (oneOrTwo++ % 2 === 0) { sectionOptions.push(this.oneColumnSection); @@ -364,7 +364,7 @@ struct StickOnTopPage { @StorageProp(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; @Builder - tabBuilder(index: number, name: string | Resource) { + tabBuilder(index: number, name: string | Resource): void { Row() { Text(name) .constraintSize({ minWidth: 56 }) diff --git a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets index 19c61ba3..c68d10d2 100644 --- a/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets +++ b/WaterFlowSample/entry/src/main/ets/pages/ZoomChangeColumnPage.ets @@ -19,7 +19,7 @@ import { image } from '@kit.ImageKit'; import { CommonConstants } from '../common/constants/CommonConstants'; import { MyDataSource } from '../model/MyDataSource' -const TAG = 'StickOnTopPage'; +const TAG: string = 'StickOnTopPage'; // [StartExclude flow_item] @Reusable @@ -73,22 +73,22 @@ struct ZoomChangeColumnPage { // [StartExclude section_init] getSize(): number { - let ret = Math.floor(Math.random() * this.maxSize); + let ret: number = Math.floor(Math.random() * this.maxSize); return (ret > this.minSize ? ret : this.minSize); } setItemSizeArray(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.itemWidthArray.push(this.getSize()); this.itemHeightArray.push(this.getSize()); } } aboutToAppear(): void { - for (let i = 0; i < 100; i++) { + for (let i: number = 0; i < 100; i++) { this.data.pushData(i); } - let lastCount = AppStorage.get('columnsCount'); + let lastCount: number| undefined = AppStorage.get('columnsCount'); if (typeof lastCount != 'undefined') { this.columns = lastCount; } @@ -182,7 +182,7 @@ struct ZoomChangeColumnPage { } this.pinchTime = event.timestamp; // 6.2、Calculate the scaling ratio. - let maxScale = this.oldColumn / (this.oldColumn - 1); + let maxScale: number = this.oldColumn / (this.oldColumn - 1); this.itemScale = event.scale > maxScale ? maxScale : event.scale; this.imageScale = event.scale > maxScale ? maxScale : event.scale; this.itemOpacity = (this.itemScale > 1) ? (this.itemScale - 1) : (1 - this.itemScale); diff --git a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets index 4034146b..80037339 100644 --- a/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets +++ b/WaterFlowSample/entry/src/main/ets/utils/WindowUtil.ets @@ -48,13 +48,13 @@ export class WindowUtil { } } - private static registerBreakPoint() { + private static registerBreakPoint(): void { WindowUtil.updateAvoidArea(WindowUtil.windowClass); WindowUtil.windowClass.on('avoidAreaChange', (avoidAreaOption) => WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area)); } - private static updateAvoidArea(windowObj: window.Window) { + private static updateAvoidArea(windowObj: window.Window): void { try { WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); @@ -66,9 +66,9 @@ export class WindowUtil { } // Get status bar height and indicator height. - private static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { + private static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea): void { try { - let uiContext = WindowUtil.windowClass.getUIContext(); + let uiContext: 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) { diff --git a/WaterFlowSample/oh-package.json5 b/WaterFlowSample/oh-package.json5 index ad660aa2..25e152b9 100644 --- a/WaterFlowSample/oh-package.json5 +++ b/WaterFlowSample/oh-package.json5 @@ -4,7 +4,5 @@ "dependencies": { }, "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" } } -- Gitee