From 8a1429a8713e6002774232bf01af17b478c01a7d Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Fri, 27 Sep 2024 14:58:46 +0300 Subject: [PATCH 01/37] modified swiper and textInput pages --- .../pages/tests/swiper/SwiperCase1Page.ets | 19 +++++++++++-------- .../pages/tests/swiper/SwiperCase2Page.ets | 19 +++++++++++-------- .../pages/tests/swiper/SwiperCase3Page.ets | 19 +++++++++++-------- .../pages/tests/swiper/SwiperCase4Page.ets | 19 +++++++++++-------- .../tests/textInput/TextInputCase1Page.ets | 2 +- .../tests/textInput/TextInputCase2Page.ets | 2 +- .../tests/textInput/TextInputCase3Page.ets | 2 +- .../tests/textInput/TextInputCase4Page.ets | 2 +- 8 files changed, 48 insertions(+), 36 deletions(-) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets index d6c70ed..056cc2e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets @@ -28,34 +28,37 @@ struct SwiperCase1Page { ForEach(this.data, (item: string) => { Swiper() { Text(item + '-1') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + '-2') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + '-3') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) } - .margin({ bottom: 5 }) + .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) .loop(true) + .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor)) + .color(this.dotColor) + .itemWidth(3) + .itemHeight(3)) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets index 1ddfc1f..4b0207d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets @@ -28,34 +28,37 @@ struct SwiperCase2Page { WithTheme({ theme: this.customTheme }) { Swiper() { Text(item + '-1') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + '-2') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + '-3') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) } - .margin({ bottom: 5 }) + .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) .loop(true) + .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor)) + .color(this.dotColor) + .itemWidth(3) + .itemHeight(3)) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets index 1d4ac33..340761e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets @@ -107,34 +107,37 @@ struct SwiperCase3Page { ListItem() { Swiper() { Text(item + ' index = ' + index + '-1') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + ' index = ' + index + '-2') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + ' index = ' + index + '-3') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) } - .margin({ bottom: 5 }) + .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) .loop(true) + .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor)) + .color(this.dotColor) + .itemWidth(3) + .itemHeight(3)) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets index 5c576ec..48ec057 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets @@ -107,34 +107,37 @@ struct SwiperCase4Page { WithTheme({ theme: this.customTheme }) { Swiper() { Text(item + ' index = ' + index + '-1') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + ' index = ' + index + '-2') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) Text(item + ' index = ' + index + '-3') - .width('90%') - .height(50) + .width('30%') + .height(35) .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) .fontColor(this.fontColor) } - .margin({ bottom: 5 }) + .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) .loop(true) + .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor)) + .color(this.dotColor) + .itemWidth(3) + .itemHeight(3)) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets index 111b2a4..32b85d3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets @@ -27,7 +27,7 @@ struct TextInputCase1Page { TextInput({ placeholder: item }) .fontColor(this.textColor) .backgroundColor(this.bkgColor) - .width('90%') + .width('30%') }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets index f62e13b..ad52491 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets @@ -27,7 +27,7 @@ struct TextInputCase2Page { TextInput({ placeholder: item }) .fontColor(this.textColor) .backgroundColor(this.bkgColor) - .width('90%') + .width('30%') } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets index bf07319..3ecb205 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets @@ -106,7 +106,7 @@ struct TextInputCase3Page { TextInput({ placeholder: item + ' index = ' + index }) .fontColor(this.textColor) .backgroundColor(this.bkgColor) - .width('90%') + .width('30%') }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets index ccfdb96..435e4e0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets @@ -106,7 +106,7 @@ struct TextInputCase4Page { TextInput({ placeholder: item + ' index = ' + index }) .fontColor(this.textColor) .backgroundColor(this.bkgColor) - .width('90%') + .width('30%') } }.width('100%') }, (item: string) => item) -- Gitee From 0aaede20d5e5bbd897cc0c4cd4a50fab44872d15 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 30 Sep 2024 19:39:10 +0300 Subject: [PATCH 02/37] divider page added --- .../ability/divider/DividerCase1Ability.ets | 43 ++++++++++++++++++ .../ability/divider/DividerCase2Ability.ets | 43 ++++++++++++++++++ .../ability/divider/DividerCase3Ability.ets | 43 ++++++++++++++++++ .../ability/divider/DividerCase4Ability.ets | 44 +++++++++++++++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 ++ .../resources/base/profile/main_pages.json | 7 ++- 6 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase4Ability.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase1Ability.ets new file mode 100644 index 0000000..3e58a68 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase2Ability.ets new file mode 100644 index 0000000..69b7476 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase3Ability.ets new file mode 100644 index 0000000..7946710 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase4Ability.ets new file mode 100644 index 0000000..84e0ffd --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 14d86f0..aabc74a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -41,6 +41,10 @@ struct TestsNavigationPage { title: 'Swiper', page: 'pages/tests/swiper/SwiperNavigationPage' }, + { + title: 'Divider', + page: 'pages/tests/divider/DividerNavigationPage' + }, ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 234526e..4d81331 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -49,6 +49,11 @@ "pages/tests/swiper/SwiperCase2Page", "pages/tests/swiper/SwiperCase3Page", "pages/tests/swiper/SwiperCase4Page", - "pages/tests/swiper/SwiperNavigationPage" + "pages/tests/swiper/SwiperNavigationPage", + "pages/tests/divider/DividerCase1Page", + "pages/tests/divider/DividerCase2Page", + "pages/tests/divider/DividerCase3Page", + "pages/tests/divider/DividerCase4Page", + "pages/tests/divider/DividerNavigationPage" ] } \ No newline at end of file -- Gitee From ac2c1e3d240782b9649a2b93a13b699018b06ea3 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 30 Sep 2024 20:01:40 +0300 Subject: [PATCH 03/37] fix divider pages --- .../pages/tests/divider/DividerCase1Page.ets | 65 ++++++++ .../pages/tests/divider/DividerCase2Page.ets | 65 ++++++++ .../pages/tests/divider/DividerCase3Page.ets | 144 ++++++++++++++++++ .../pages/tests/divider/DividerCase4Page.ets | 144 ++++++++++++++++++ .../tests/divider/DividerNavigationPage.ets | 55 +++++++ .../entry/src/main/module.json5 | 40 +++++ 6 files changed, 513 insertions(+) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets new file mode 100644 index 0000000..e997cac --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets @@ -0,0 +1,65 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DividerCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + Divider() + .color(this.textColor) + .strokeWidth(10) + .vertical(false) + .width('30%') + .margin({ bottom: 15 }) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets new file mode 100644 index 0000000..eaaba75 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets @@ -0,0 +1,65 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DividerCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Divider() + .color(this.textColor) + .strokeWidth(10) + .vertical(false) + .width('30%') + .margin({ bottom: 15 }) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets new file mode 100644 index 0000000..6535f71 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets @@ -0,0 +1,144 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DividerCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Divider() + .color(this.textColor) + .strokeWidth(10) + .vertical(false) + .width('30%') + .margin({ bottom: 15 }) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets new file mode 100644 index 0000000..2fa3798 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets @@ -0,0 +1,144 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DividerCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Divider() + .color(this.textColor) + .strokeWidth(10) + .vertical(false) + .width('30%') + .margin({ bottom: 15 }) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets new file mode 100644 index 0000000..e52b82e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct DividerNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Dividers', + ability: 'DividerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Dividers', + ability: 'DividerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Dividers', + ability: 'DividerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Dividers', + ability: 'DividerCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 4fd47a2..2020bc6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -411,6 +411,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase1Ability", + "srcEntry": "./ets/ability/divider/DividerCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase2Ability", + "srcEntry": "./ets/ability/divider/DividerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase3Ability", + "srcEntry": "./ets/ability/divider/DividerCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase4Ability", + "srcEntry": "./ets/ability/divider/DividerCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } -- Gitee From 3801af3f499124cbcf65dc1711643bb71bfce366 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 30 Sep 2024 20:42:51 +0300 Subject: [PATCH 04/37] textClock pages added --- .../textClock/TextClockCase1Ability.ets | 43 ++++++ .../textClock/TextClockCase2Ability.ets | 43 ++++++ .../textClock/TextClockCase3Ability.ets | 43 ++++++ .../textClock/TextClockCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../tests/textClock/TextClockCase1Page.ets | 64 ++++++++ .../tests/textClock/TextClockCase2Page.ets | 64 ++++++++ .../tests/textClock/TextClockCase3Page.ets | 143 ++++++++++++++++++ .../tests/textClock/TextClockCase4Page.ets | 143 ++++++++++++++++++ .../textClock/TextClockNavigationPage.ets | 55 +++++++ .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 692 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets new file mode 100644 index 0000000..33267bc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets new file mode 100644 index 0000000..cdc2627 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets new file mode 100644 index 0000000..be2677c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets new file mode 100644 index 0000000..9b4f4df --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index aabc74a..0cdf8cf 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -45,6 +45,10 @@ struct TestsNavigationPage { title: 'Divider', page: 'pages/tests/divider/DividerNavigationPage' }, + { + title: 'textClock', + page: 'pages/tests/textClock/textClockNavigationPage' + }, ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets new file mode 100644 index 0000000..67a4b8e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets @@ -0,0 +1,64 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets new file mode 100644 index 0000000..2228344 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets @@ -0,0 +1,64 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets new file mode 100644 index 0000000..7feb34c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets @@ -0,0 +1,143 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets new file mode 100644 index 0000000..28c21f0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets @@ -0,0 +1,143 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets new file mode 100644 index 0000000..1d8ff83 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct TextClockNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 TClocks', + ability: 'TextClockCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 TClocks', + ability: 'TextClockCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TClocks', + ability: 'TextClockCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TClocks', + ability: 'TextClockCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 2020bc6..0fc0c33 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -451,6 +451,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase1Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase2Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase3Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase4Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 4d81331..6ccdcbc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -54,6 +54,11 @@ "pages/tests/divider/DividerCase2Page", "pages/tests/divider/DividerCase3Page", "pages/tests/divider/DividerCase4Page", - "pages/tests/divider/DividerNavigationPage" + "pages/tests/divider/DividerNavigationPage", + "pages/tests/textClock/TextClockCase1Page", + "pages/tests/textClock/TextClockCase2Page", + "pages/tests/textClock/TextClockCase3Page", + "pages/tests/textClock/TextClockCase4Page", + "pages/tests/textClock/TextClockNavigationPage" ] } \ No newline at end of file -- Gitee From 21732d8d2e904fc42aa222a9edb4d7d68c82e871 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 30 Sep 2024 20:42:51 +0300 Subject: [PATCH 05/37] textClock pages added --- .../textClock/TextClockCase1Ability.ets | 43 ++++++ .../textClock/TextClockCase2Ability.ets | 43 ++++++ .../textClock/TextClockCase3Ability.ets | 43 ++++++ .../textClock/TextClockCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../tests/textClock/TextClockCase1Page.ets | 64 ++++++++ .../tests/textClock/TextClockCase2Page.ets | 64 ++++++++ .../tests/textClock/TextClockCase3Page.ets | 143 ++++++++++++++++++ .../tests/textClock/TextClockCase4Page.ets | 143 ++++++++++++++++++ .../textClock/TextClockNavigationPage.ets | 55 +++++++ .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 692 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets new file mode 100644 index 0000000..33267bc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets new file mode 100644 index 0000000..cdc2627 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets new file mode 100644 index 0000000..be2677c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets new file mode 100644 index 0000000..9b4f4df --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index aabc74a..238f196 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -45,6 +45,10 @@ struct TestsNavigationPage { title: 'Divider', page: 'pages/tests/divider/DividerNavigationPage' }, + { + title: 'textClock', + page: 'pages/tests/textClock/TextClockNavigationPage' + }, ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets new file mode 100644 index 0000000..67a4b8e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets @@ -0,0 +1,64 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets new file mode 100644 index 0000000..2228344 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets @@ -0,0 +1,64 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets new file mode 100644 index 0000000..7feb34c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets @@ -0,0 +1,143 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets new file mode 100644 index 0000000..28c21f0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets @@ -0,0 +1,143 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TextClock() + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + .width('30%') + .margin({ bottom: 20 }) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets new file mode 100644 index 0000000..1d8ff83 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct TextClockNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 TClocks', + ability: 'TextClockCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 TClocks', + ability: 'TextClockCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TClocks', + ability: 'TextClockCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TClocks', + ability: 'TextClockCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 2020bc6..0fc0c33 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -451,6 +451,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase1Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase2Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase3Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase4Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 4d81331..6ccdcbc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -54,6 +54,11 @@ "pages/tests/divider/DividerCase2Page", "pages/tests/divider/DividerCase3Page", "pages/tests/divider/DividerCase4Page", - "pages/tests/divider/DividerNavigationPage" + "pages/tests/divider/DividerNavigationPage", + "pages/tests/textClock/TextClockCase1Page", + "pages/tests/textClock/TextClockCase2Page", + "pages/tests/textClock/TextClockCase3Page", + "pages/tests/textClock/TextClockCase4Page", + "pages/tests/textClock/TextClockNavigationPage" ] } \ No newline at end of file -- Gitee From f5e0f478e8eb235fb55b38915429c1ca9dcf8622 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Thu, 3 Oct 2024 21:17:16 +0300 Subject: [PATCH 06/37] QRCode page added --- .../ets/ability/QRCode/QRCodeCase1Ability.ets | 43 ++++++ .../ets/ability/QRCode/QRCodeCase2Ability.ets | 43 ++++++ .../ets/ability/QRCode/QRCodeCase3Ability.ets | 43 ++++++ .../ets/ability/QRCode/QRCodeCase4Ability.ets | 44 ++++++ .../pages/tests/QRCode/QRCodeCase1Page.ets | 61 ++++++++ .../pages/tests/QRCode/QRCodeCase2Page.ets | 61 ++++++++ .../pages/tests/QRCode/QRCodeCase3Page.ets | 140 ++++++++++++++++++ .../pages/tests/QRCode/QRCodeCase4Page.ets | 140 ++++++++++++++++++ .../tests/QRCode/QRCodeNavigationPage.ets | 55 +++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../entry/src/main/module.json5 | 40 +++++ 11 files changed, 674 insertions(+) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase1Ability.ets new file mode 100644 index 0000000..b2928df --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase2Ability.ets new file mode 100644 index 0000000..39b805b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase3Ability.ets new file mode 100644 index 0000000..e58699d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase4Ability.ets new file mode 100644 index 0000000..d4697b5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets new file mode 100644 index 0000000..e777c66 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets @@ -0,0 +1,61 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct QRCodeCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + QRCode("hello world").width(38).height(38) + .backgroundColor(this.bkgColor) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets new file mode 100644 index 0000000..2f3d8f3 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets @@ -0,0 +1,61 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct QRCodeCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + QRCode("hello world").width(38).height(38) + .backgroundColor(this.bkgColor) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets new file mode 100644 index 0000000..12383fe --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets @@ -0,0 +1,140 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct QRCodeCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + QRCode("hello world").width(38).height(38) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets new file mode 100644 index 0000000..b5788fb --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets @@ -0,0 +1,140 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct QRCodeCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + QRCode("hello world").width(38).height(38) + .backgroundColor(this.bkgColor) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets new file mode 100644 index 0000000..2eb9a62 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct QRCodeNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 TIs', + ability: 'QRCodeCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 TIs', + ability: 'QRCodeCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TIs', + ability: 'QRCodeCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TIs', + ability: 'QRCodeCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 0cdf8cf..6f0e74d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -49,6 +49,10 @@ struct TestsNavigationPage { title: 'textClock', page: 'pages/tests/textClock/textClockNavigationPage' }, + { + title: 'QRCode', + page: 'pages/tests/QRCode/QRCodeNavigationPage' + }, ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 0fc0c33..b17b22f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -491,6 +491,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase1Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase2Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase3Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase4Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } -- Gitee From 4eb3b08c4effe0ea4a951d945d6f6962664e2587 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Thu, 3 Oct 2024 22:53:41 +0300 Subject: [PATCH 07/37] PatternLock pages added --- .../PatternLock/PatternLockCase1Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase2Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase3Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase4Ability.ets | 44 ++++++ .../PatternLock/PatternLockCase1Page.ets | 61 ++++++++ .../PatternLock/PatternLockCase2Page.ets | 61 ++++++++ .../PatternLock/PatternLockCase3Page.ets | 140 ++++++++++++++++++ .../PatternLock/PatternLockCase4Page.ets | 140 ++++++++++++++++++ .../PatternLock/PatternLockNavigationPage.ets | 55 +++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 680 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase1Ability.ets new file mode 100644 index 0000000..7aeae87 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase2Ability.ets new file mode 100644 index 0000000..9c3027b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase3Ability.ets new file mode 100644 index 0000000..b4f9f7b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase4Ability.ets new file mode 100644 index 0000000..3ea3e6c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets new file mode 100644 index 0000000..2c59789 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets @@ -0,0 +1,61 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct PatternLockCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + PatternLock().sideLength(38) + .backgroundColor(this.bkgColor) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets new file mode 100644 index 0000000..ef5f168 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets @@ -0,0 +1,61 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct PatternLockCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + PatternLock().sideLength(38) + .backgroundColor(this.bkgColor) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets new file mode 100644 index 0000000..81a1d18 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets @@ -0,0 +1,140 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct PatternLockCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + PatternLock().sideLength(38) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets new file mode 100644 index 0000000..82dc445 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets @@ -0,0 +1,140 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct PatternLockCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + PatternLock().sideLength(38) + .backgroundColor(this.bkgColor) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets new file mode 100644 index 0000000..3bc024c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct PatternLockNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 TIs', + ability: 'PatternLockCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 TIs', + ability: 'PatternLockCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TIs', + ability: 'PatternLockCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TIs', + ability: 'PatternLockCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 31ece37..c6db444 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -53,6 +53,10 @@ struct TestsNavigationPage { title: 'QRCode', page: 'pages/tests/QRCode/QRCodeNavigationPage' }, + { + title: 'PatternLock', + page: 'pages/tests/PatternLock/PatternLockNavigationPage' + } ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index b17b22f..b301149 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -531,6 +531,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase1Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase2Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase3Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase4Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index f8cf6ec..0313900 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -64,6 +64,11 @@ "pages/tests/QRCode/QRCodeCase2Page", "pages/tests/QRCode/QRCodeCase3Page", "pages/tests/QRCode/QRCodeCase4Page", - "pages/tests/QRCode/QRCodeNavigationPage" + "pages/tests/QRCode/QRCodeNavigationPage", + "pages/tests/PatternLock/PatternLockCase1Page", + "pages/tests/PatternLock/PatternLockCase2Page", + "pages/tests/PatternLock/PatternLockCase3Page", + "pages/tests/PatternLock/PatternLockCase4Page", + "pages/tests/PatternLock/PatternLockNavigationPage" ] } \ No newline at end of file -- Gitee From 3544c3e46dd9954bef000a88409d5919c8253d14 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 7 Oct 2024 21:21:05 +0300 Subject: [PATCH 08/37] select page added --- .../ets/ability/select/SelectCase1Ability.ets | 43 ++++++ .../ets/ability/select/SelectCase2Ability.ets | 43 ++++++ .../ets/ability/select/SelectCase3Ability.ets | 43 ++++++ .../ets/ability/select/SelectCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../pages/tests/select/SelectCase1Page.ets | 65 ++++++++ .../pages/tests/select/SelectCase2Page.ets | 65 ++++++++ .../pages/tests/select/SelectCase3Page.ets | 144 ++++++++++++++++++ .../pages/tests/select/SelectCase4Page.ets | 144 ++++++++++++++++++ .../tests/select/SelectNavigationPage.ets | 55 +++++++ .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 696 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase1Ability.ets new file mode 100644 index 0000000..7d705e7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase2Ability.ets new file mode 100644 index 0000000..4469785 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase3Ability.ets new file mode 100644 index 0000000..0518013 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase4Ability.ets new file mode 100644 index 0000000..51f863b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index c6db444..930c375 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -56,6 +56,10 @@ struct TestsNavigationPage { { title: 'PatternLock', page: 'pages/tests/PatternLock/PatternLockNavigationPage' + }, + { + title: 'Select', + page: 'pages/tests/select/SelectNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets new file mode 100644 index 0000000..7ab625b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets @@ -0,0 +1,65 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SelectCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value('SELECT ' + item) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets new file mode 100644 index 0000000..5dc5838 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets @@ -0,0 +1,65 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SelectCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value('SELECT ' + item) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets new file mode 100644 index 0000000..83ba7d5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets @@ -0,0 +1,144 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SelectCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value('SELECT ' + item) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets new file mode 100644 index 0000000..323be51 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets @@ -0,0 +1,144 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SelectCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value('SELECT ' + item) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets new file mode 100644 index 0000000..3c04993 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct SelectNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Selects', + ability: 'SelectCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Selects', + ability: 'SelectCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Selects', + ability: 'SelectCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Selects', + ability: 'SelectCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index b301149..5a9c0a5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -571,6 +571,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase1Ability", + "srcEntry": "./ets/ability/select/SelectCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase2Ability", + "srcEntry": "./ets/ability/select/SelectCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase3Ability", + "srcEntry": "./ets/ability/select/SelectCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase4Ability", + "srcEntry": "./ets/ability/select/SelectCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 0313900..04bd8f9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -69,6 +69,11 @@ "pages/tests/PatternLock/PatternLockCase2Page", "pages/tests/PatternLock/PatternLockCase3Page", "pages/tests/PatternLock/PatternLockCase4Page", - "pages/tests/PatternLock/PatternLockNavigationPage" + "pages/tests/PatternLock/PatternLockNavigationPage", + "pages/tests/select/SelectCase1Page", + "pages/tests/select/SelectCase2Page", + "pages/tests/select/SelectCase3Page", + "pages/tests/select/SelectCase4Page", + "pages/tests/select/SelectNavigationPage" ] } \ No newline at end of file -- Gitee From f56a19ddb209ed6a1bcbad9210e5c5359230bce4 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 7 Oct 2024 22:11:46 +0300 Subject: [PATCH 09/37] AlphabetIndexer page added --- .../AlphabetIndexerCase1Ability.ets | 43 +++++ .../AlphabetIndexerCase2Ability.ets | 43 +++++ .../AlphabetIndexerCase3Ability.ets | 43 +++++ .../AlphabetIndexerCase4Ability.ets | 44 ++++++ .../AlphabetIndexerCase1Page.ets | 69 ++++++++ .../AlphabetIndexerCase2Page.ets | 69 ++++++++ .../AlphabetIndexerCase3Page.ets | 148 ++++++++++++++++++ .../AlphabetIndexerCase4Page.ets | 148 ++++++++++++++++++ .../AlphabetIndexerNavigationPage.ets | 55 +++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 712 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets new file mode 100644 index 0000000..2c91b2f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase2Ability.ets new file mode 100644 index 0000000..7770948 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase3Ability.ets new file mode 100644 index 0000000..687865f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase4Ability.ets new file mode 100644 index 0000000..e0e44ed --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets new file mode 100644 index 0000000..aa4a45f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets @@ -0,0 +1,69 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct AlphabetIndexerCase1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets new file mode 100644 index 0000000..b610021 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets @@ -0,0 +1,69 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct AlphabetIndexerCase2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + } + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets new file mode 100644 index 0000000..0518ba0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets @@ -0,0 +1,148 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct AlphabetIndexerCase3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets new file mode 100644 index 0000000..b509b70 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets @@ -0,0 +1,148 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct AlphabetIndexerCase4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(30) + } + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets new file mode 100644 index 0000000..7a95750 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct AlphabetIndexerNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 AlphabetIndexers', + ability: 'AlphabetIndexerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 AlphabetIndexers', + ability: 'AlphabetIndexerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 AlphabetIndexers', + ability: 'AlphabetIndexerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 AlphabetIndexers', + ability: 'AlphabetIndexerCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 930c375..6b7b046 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -60,6 +60,10 @@ struct TestsNavigationPage { { title: 'Select', page: 'pages/tests/select/SelectNavigationPage' + }, + { + title: 'AlphabetIndexer', + page: 'pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 5a9c0a5..62ed87f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -611,6 +611,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase1Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase2Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase3Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase4Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 04bd8f9..811e568 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -74,6 +74,11 @@ "pages/tests/select/SelectCase2Page", "pages/tests/select/SelectCase3Page", "pages/tests/select/SelectCase4Page", - "pages/tests/select/SelectNavigationPage" + "pages/tests/select/SelectNavigationPage", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage" ] } \ No newline at end of file -- Gitee From 13edb49de3468c4de4eb77e71e0f36c883180de3 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Wed, 9 Oct 2024 21:54:46 +0300 Subject: [PATCH 10/37] remove custom color attributes from components --- .../AlphabetIndexerCase1Page.ets | 15 ++----- .../AlphabetIndexerCase2Page.ets | 9 ---- .../AlphabetIndexerCase3Page.ets | 8 ---- .../AlphabetIndexerCase4Page.ets | 11 +---- .../PatternLock/PatternLockCase1Page.ets | 12 +----- .../PatternLock/PatternLockCase2Page.ets | 12 +----- .../PatternLock/PatternLockCase3Page.ets | 14 +------ .../PatternLock/PatternLockCase4Page.ets | 16 ++----- .../pages/tests/QRCode/QRCodeCase1Page.ets | 16 ++----- .../pages/tests/QRCode/QRCodeCase2Page.ets | 12 +----- .../pages/tests/QRCode/QRCodeCase3Page.ets | 12 +----- .../pages/tests/QRCode/QRCodeCase4Page.ets | 16 ++----- .../pages/tests/button/ButtonCase1Page.ets | 40 ------------------ .../pages/tests/button/ButtonCase2Page.ets | 42 +------------------ .../pages/tests/button/ButtonCase3Page.ets | 40 ------------------ .../pages/tests/button/ButtonCase4Page.ets | 40 ------------------ .../tests/checkbox/CheckboxCase1Page.ets | 20 +-------- .../tests/checkbox/CheckboxCase2Page.ets | 18 +------- .../tests/checkbox/CheckboxCase3Page.ets | 19 +-------- .../tests/checkbox/CheckboxCase4Page.ets | 20 +-------- .../pages/tests/divider/DividerCase1Page.ets | 14 +------ .../pages/tests/divider/DividerCase2Page.ets | 12 +----- .../pages/tests/divider/DividerCase3Page.ets | 11 +---- .../pages/tests/divider/DividerCase4Page.ets | 10 ----- .../LoadingProgressCase1Page.ets | 18 +------- .../LoadingProgressCase2Page.ets | 20 +-------- .../LoadingProgressCase3Page.ets | 16 ------- .../LoadingProgressCase4Page.ets | 16 ------- .../tests/progress/ProgressCase1Page.ets | 17 +------- .../tests/progress/ProgressCase2Page.ets | 17 +------- .../tests/progress/ProgressCase3Page.ets | 19 ++------- .../tests/progress/ProgressCase4Page.ets | 15 +------ .../ets/pages/tests/radio/RadioCase1Page.ets | 13 +----- .../ets/pages/tests/radio/RadioCase2Page.ets | 15 +------ .../ets/pages/tests/radio/RadioCase3Page.ets | 17 ++------ .../ets/pages/tests/radio/RadioCase4Page.ets | 15 +------ .../pages/tests/select/SelectCase1Page.ets | 13 +----- .../pages/tests/select/SelectCase2Page.ets | 11 +---- .../pages/tests/select/SelectCase3Page.ets | 13 +----- .../pages/tests/select/SelectCase4Page.ets | 11 +---- .../pages/tests/swiper/SwiperCase1Page.ets | 30 +++---------- .../pages/tests/swiper/SwiperCase2Page.ets | 34 ++++----------- .../pages/tests/swiper/SwiperCase3Page.ets | 26 ++---------- .../pages/tests/swiper/SwiperCase4Page.ets | 24 +---------- .../ets/pages/tests/text/TextCase1Page.ets | 15 +------ .../ets/pages/tests/text/TextCase2Page.ets | 13 +----- .../ets/pages/tests/text/TextCase3Page.ets | 19 ++------- .../ets/pages/tests/text/TextCase4Page.ets | 13 +----- .../tests/textClock/TextClockCase1Page.ets | 17 ++------ .../tests/textClock/TextClockCase2Page.ets | 15 +------ .../tests/textClock/TextClockCase3Page.ets | 15 +------ .../tests/textClock/TextClockCase4Page.ets | 15 +------ .../tests/textInput/TextInputCase1Page.ets | 15 +------ .../tests/textInput/TextInputCase2Page.ets | 13 +----- .../tests/textInput/TextInputCase3Page.ets | 13 +----- .../tests/textInput/TextInputCase4Page.ets | 15 +------ .../src/main/ets/theme/CustomColorsImlp.ets | 36 ++++++++++++++++ 57 files changed, 132 insertions(+), 881 deletions(-) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets index aa4a45f..d0b576e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets @@ -1,15 +1,12 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct AlphabetIndexerCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - count = 0 + count = 0 data: string[] = [] aboutToAppear() { @@ -48,19 +45,13 @@ struct AlphabetIndexerCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets index b610021..b4eb53e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct AlphabetIndexerCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -49,19 +46,13 @@ struct AlphabetIndexerCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets index 0518ba0..f6cceb9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets @@ -86,8 +86,6 @@ class MyDataSource extends BasicDataSource { @Component struct AlphabetIndexerCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -127,19 +125,13 @@ struct AlphabetIndexerCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets index b509b70..91f7865 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct AlphabetIndexerCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -128,19 +125,13 @@ struct AlphabetIndexerCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets index 2c59789..3b1bc6f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct PatternLockCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,7 +22,6 @@ struct PatternLockCase1Page { Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { PatternLock().sideLength(38) - .backgroundColor(this.bkgColor) }, (item: string) => item) } } @@ -40,19 +36,13 @@ struct PatternLockCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets index ef5f168..59e191c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct PatternLockCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,7 +22,6 @@ struct PatternLockCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { PatternLock().sideLength(38) - .backgroundColor(this.bkgColor) } }, (item: string) => item) } @@ -41,19 +37,13 @@ struct PatternLockCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets index 81a1d18..6df69d4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct PatternLockCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,7 @@ struct PatternLockCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { PatternLock().sideLength(38) - .backgroundColor(this.bkgColor) - }.width('100%') + }.width('100%') }, (item: string) => item) } .width('100%') @@ -119,19 +115,13 @@ struct PatternLockCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets index 82dc445..e406a58 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct PatternLockCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,7 @@ struct PatternLockCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { PatternLock().sideLength(38) - .backgroundColor(this.bkgColor) - } + } }.width('100%') }, (item: string) => item) } @@ -120,20 +116,14 @@ struct PatternLockCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets index e777c66..f48b078 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct QRCodeCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,8 +22,7 @@ struct QRCodeCase1Page { Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { QRCode("hello world").width(38).height(38) - .backgroundColor(this.bkgColor) - }, (item: string) => item) + }, (item: string) => item) } } .width('100%') @@ -40,20 +36,14 @@ struct QRCodeCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets index 2f3d8f3..d017dc9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct QRCodeCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,7 +22,6 @@ struct QRCodeCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { QRCode("hello world").width(38).height(38) - .backgroundColor(this.bkgColor) } }, (item: string) => item) } @@ -41,19 +37,13 @@ struct QRCodeCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets index 12383fe..09c7924 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct QRCodeCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,7 +101,6 @@ struct QRCodeCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { QRCode("hello world").width(38).height(38) - .backgroundColor(this.bkgColor) }.width('100%') }, (item: string) => item) } @@ -119,19 +115,13 @@ struct QRCodeCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets index b5788fb..e01c40a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct QRCodeCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,7 @@ struct QRCodeCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { QRCode("hello world").width(38).height(38) - .backgroundColor(this.bkgColor) - } + } }.width('100%') }, (item: string) => item) } @@ -120,20 +116,14 @@ struct QRCodeCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets index bd7de4e..26953c2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets @@ -1,16 +1,11 @@ /* ForEach List with 100 Buttons as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct ButtonCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State bkgColorPressed: ResourceColor = RedThemeColors.interactivePressed - @State outlineClr: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -20,23 +15,6 @@ struct ButtonCase1Page { } } - @Styles - normalButton() { - .backgroundColor(this.bkgColor) - .outlineWidth('0vp') - } - - @Styles - pressedButton() { - .backgroundColor(this.bkgColorPressed) - } - - @Styles - focusedButton() { - .outlineColor(this.outlineClr) - .outlineWidth('2vp') - } - build() { WithTheme({ theme: this.customTheme }) { Row() { @@ -44,12 +22,6 @@ struct ButtonCase1Page { Column({ space: '8vp' }) { ForEach(this.data, (item: string) => { Button(item) - .fontColor(this.textColor) - .stateStyles({ - normal: this.normalButton, - pressed: this.pressedButton, - focused: this.focusedButton - }) }, (item: string) => item) } } @@ -64,25 +36,13 @@ struct ButtonCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.bkgColorPressed = RedThemeColors.interactivePressed - this.outlineClr = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.bkgColorPressed = GreenThemeColors.interactivePressed - this.outlineClr = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.bkgColorPressed = BrownThemeColors.interactivePressed - this.outlineClr = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets index 9f35baa..e499be1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets @@ -1,36 +1,14 @@ /* ForEach List with 100 Buttons as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct ButtonCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State bkgColorPressed: ResourceColor = RedThemeColors.interactivePressed - @State outlineClr: ResourceColor = RedThemeColors.interactiveFocus - count = 0 + count = 0 data: string[] = [] - @Styles - normalButton() { - .backgroundColor(this.bkgColor) - .outlineWidth('0vp') - } - - @Styles - pressedButton() { - .backgroundColor(this.bkgColorPressed) - } - - @Styles - focusedButton() { - .outlineColor(this.outlineClr) - .outlineWidth('2vp') - } - aboutToAppear() { for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) @@ -44,12 +22,6 @@ struct ButtonCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Button(item) - .fontColor(this.textColor) - .stateStyles({ - normal: this.normalButton, - pressed: this.pressedButton, - focused: this.focusedButton - }) } }, (item: string) => item) } @@ -65,25 +37,13 @@ struct ButtonCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.bkgColorPressed = RedThemeColors.interactivePressed - this.outlineClr = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.bkgColorPressed = GreenThemeColors.interactivePressed - this.outlineClr = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.bkgColorPressed = BrownThemeColors.interactivePressed - this.outlineClr = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets index 61a7b0a..c4a44d9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Buttons as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,30 +85,9 @@ class MyDataSource extends BasicDataSource { @Component struct ButtonCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State bkgColorPressed: ResourceColor = RedThemeColors.interactivePressed - @State outlineClr: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); - @Styles - normalButton() { - .backgroundColor(this.bkgColor) - .outlineWidth('0vp') - } - - @Styles - pressedButton() { - .backgroundColor(this.bkgColorPressed) - } - - @Styles - focusedButton() { - .outlineColor(this.outlineClr) - .outlineWidth('2vp') - } - aboutToAppear() { for (let i = 0; i < 2000; i++) { this.data.pushData('Item #' + i) @@ -123,12 +101,6 @@ struct ButtonCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Button(item + ' index = ' + index) - .fontColor(this.textColor) - .stateStyles({ - normal: this.normalButton, - pressed: this.pressedButton, - focused: this.focusedButton - }) }.width('100%') }, (item: string) => item) } @@ -143,25 +115,13 @@ struct ButtonCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.bkgColorPressed = RedThemeColors.interactivePressed - this.outlineClr = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.bkgColorPressed = GreenThemeColors.interactivePressed - this.outlineClr = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.bkgColorPressed = BrownThemeColors.interactivePressed - this.outlineClr = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets index 0264b9e..4ab9acc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Buttons as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,30 +85,9 @@ class MyDataSource extends BasicDataSource { @Component struct ButtonCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State bkgColorPressed: ResourceColor = RedThemeColors.interactivePressed - @State outlineClr: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); - @Styles - normalButton() { - .backgroundColor(this.bkgColor) - .outlineWidth('0vp') - } - - @Styles - pressedButton() { - .backgroundColor(this.bkgColorPressed) - } - - @Styles - focusedButton() { - .outlineColor(this.outlineClr) - .outlineWidth('2vp') - } - aboutToAppear() { for (let i = 0; i < 2000; i++) { this.data.pushData('Item #' + i) @@ -123,12 +101,6 @@ struct ButtonCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { Button(item + ' index = ' + index) - .fontColor(this.textColor) - .stateStyles({ - normal: this.normalButton, - pressed: this.pressedButton, - focused: this.focusedButton - }) } }.width('100%') }, (item: string) => item) @@ -144,25 +116,13 @@ struct ButtonCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.bkgColorPressed = RedThemeColors.interactivePressed - this.outlineClr = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.bkgColorPressed = GreenThemeColors.interactivePressed - this.outlineClr = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.bkgColorPressed = BrownThemeColors.interactivePressed - this.outlineClr = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets index 17f86c6..0a567d6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct CheckboxCase1Page { @State customTheme: CustomTheme = RedTheme - @State selectedColor: ResourceColor = RedThemeColors.fontOnPrimary - @State unselectedColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State markStrokeColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -27,9 +23,6 @@ struct CheckboxCase1Page { ForEach(this.data, (item: string) => { Checkbox() .select(true) - .selectedColor(this.selectedColor) - .unselectedColor(this.unselectedColor) - .mark({ strokeColor: this.markStrokeColor }) }, (item: string) => item) } } @@ -44,23 +37,14 @@ struct CheckboxCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.selectedColor = RedThemeColors.fontOnPrimary - this.unselectedColor = RedThemeColors.backgroundEmphasize - this.markStrokeColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.selectedColor = GreenThemeColors.fontOnPrimary - this.unselectedColor = GreenThemeColors.backgroundEmphasize - this.markStrokeColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.selectedColor = BrownThemeColors.fontOnPrimary - this.unselectedColor = BrownThemeColors.backgroundEmphasize - this.markStrokeColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets index 3006447..ce8bd57 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct CheckboxCase2Page { @State customTheme: CustomTheme = RedTheme - @State selectedColor: ResourceColor = RedThemeColors.fontOnPrimary - @State unselectedColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State markStrokeColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -27,9 +23,6 @@ struct CheckboxCase2Page { WithTheme({ theme: this.customTheme }) { Checkbox() .select(true) - .selectedColor(this.selectedColor) - .unselectedColor(this.unselectedColor) - .mark({ strokeColor: this.markStrokeColor }) } }, (item: string) => item) } @@ -45,22 +38,13 @@ struct CheckboxCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.selectedColor = RedThemeColors.fontOnPrimary - this.unselectedColor = RedThemeColors.backgroundEmphasize - this.markStrokeColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.selectedColor = GreenThemeColors.fontOnPrimary - this.unselectedColor = GreenThemeColors.backgroundEmphasize - this.markStrokeColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.selectedColor = BrownThemeColors.fontOnPrimary - this.unselectedColor = BrownThemeColors.backgroundEmphasize - this.markStrokeColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets index 7a356ed..9fb0174 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets @@ -86,9 +86,6 @@ class MyDataSource extends BasicDataSource { @Component struct CheckboxCase3Page { @State customTheme: CustomTheme = RedTheme - @State selectedColor: ResourceColor = RedThemeColors.fontOnPrimary - @State unselectedColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State markStrokeColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -106,9 +103,6 @@ struct CheckboxCase3Page { ListItem() { Checkbox() .select(true) - .selectedColor(this.selectedColor) - .unselectedColor(this.unselectedColor) - .mark({ strokeColor: this.markStrokeColor }) }.width('100%') }, (item: string) => item) } @@ -123,23 +117,14 @@ struct CheckboxCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.selectedColor = RedThemeColors.fontOnPrimary - this.unselectedColor = RedThemeColors.backgroundEmphasize - this.markStrokeColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.selectedColor = GreenThemeColors.fontOnPrimary - this.unselectedColor = GreenThemeColors.backgroundEmphasize - this.markStrokeColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.selectedColor = BrownThemeColors.fontOnPrimary - this.unselectedColor = BrownThemeColors.backgroundEmphasize - this.markStrokeColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets index eec366f..a4d405b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct CheckboxCase4Page { @State customTheme: CustomTheme = RedTheme - @State selectedColor: ResourceColor = RedThemeColors.fontOnPrimary - @State unselectedColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State markStrokeColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -106,9 +102,6 @@ struct CheckboxCase4Page { WithTheme({ theme: this.customTheme }) { Checkbox() .select(true) - .selectedColor(this.selectedColor) - .unselectedColor(this.unselectedColor) - .mark({ strokeColor: this.markStrokeColor }) } }.width('100%') }, (item: string) => item) @@ -124,23 +117,14 @@ struct CheckboxCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.selectedColor = RedThemeColors.fontOnPrimary - this.unselectedColor = RedThemeColors.backgroundEmphasize - this.markStrokeColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.selectedColor = GreenThemeColors.fontOnPrimary - this.unselectedColor = GreenThemeColors.backgroundEmphasize - this.markStrokeColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.selectedColor = BrownThemeColors.fontOnPrimary - this.unselectedColor = BrownThemeColors.backgroundEmphasize - this.markStrokeColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets index e997cac..b486c67 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct DividerCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,7 +22,6 @@ struct DividerCase1Page { Column({ space: '30vp' }) { ForEach(this.data, (item: string) => { Divider() - .color(this.textColor) .strokeWidth(10) .vertical(false) .width('30%') @@ -44,20 +40,14 @@ struct DividerCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets index eaaba75..1571220 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct DividerCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,7 +22,6 @@ struct DividerCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Divider() - .color(this.textColor) .strokeWidth(10) .vertical(false) .width('30%') @@ -45,19 +41,13 @@ struct DividerCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets index 6535f71..9c02955 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets @@ -86,8 +86,6 @@ class MyDataSource extends BasicDataSource { @Component struct DividerCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,7 +102,6 @@ struct DividerCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Divider() - .color(this.textColor) .strokeWidth(10) .vertical(false) .width('30%') @@ -123,19 +120,13 @@ struct DividerCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets index 2fa3798..aa4826a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct DividerCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,7 +101,6 @@ struct DividerCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { Divider() - .color(this.textColor) .strokeWidth(10) .vertical(false) .width('30%') @@ -124,19 +120,13 @@ struct DividerCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets index f04affd..ebec005 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct LoadingProgressCase1Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -40,9 +36,6 @@ struct LoadingProgressCase1Page { Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { LoadingProgress() - .color(this.color) - .backgroundColor(this.bkgColor) - .borderColor(this.customBorderColor) .height(43) }, (item: string) => item) @@ -59,22 +52,13 @@ struct LoadingProgressCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets index 4b966bb..8906ca9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct LoadingProgressCase2Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -40,9 +36,6 @@ struct LoadingProgressCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { LoadingProgress() - .color(this.color) - .backgroundColor(this.bkgColor) - .borderColor(this.customBorderColor) .height(43) } }, (item: string) => item) @@ -59,22 +52,13 @@ struct LoadingProgressCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets index 95a2a46..36a50f6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct LoadingProgressCase3Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -120,9 +116,6 @@ struct LoadingProgressCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { LoadingProgress() - .color(this.color) - .backgroundColor(this.bkgColor) - .borderColor(this.customBorderColor) .height(43) }.width('100%') }, (item: string) => item) @@ -138,22 +131,13 @@ struct LoadingProgressCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets index e7b8511..5b4a88e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct LoadingProgressCase4Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -118,9 +114,6 @@ struct LoadingProgressCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { LoadingProgress() - .color(this.color) - .backgroundColor(this.bkgColor) - .borderColor(this.customBorderColor) .height(43) } }.width('100%') @@ -137,22 +130,13 @@ struct LoadingProgressCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets index 1b1c0b7..eb8df4a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct ProgressCase1Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -59,23 +55,14 @@ struct ProgressCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets index 1f13f26..7ab06da 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct ProgressCase2Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 data: string[] = [] @@ -59,22 +55,13 @@ struct ProgressCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets index 8dd6985..d4d449b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct ProgressCase3Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -138,23 +134,14 @@ struct ProgressCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus - break + break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus - break + break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets index e5d42f0..c2877a9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct ProgressCase4Page { @State customTheme: CustomTheme = RedTheme - @State color: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customBorderColor: ResourceColor = RedThemeColors.interactiveFocus count = 0 private data: MyDataSource = new MyDataSource(); @@ -137,23 +133,14 @@ struct ProgressCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.color = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - this.customBorderColor = RedThemeColors.interactiveFocus break case 1: this.customTheme = GreenTheme - this.color = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - this.customBorderColor = GreenThemeColors.interactiveFocus break case 2: default: this.customTheme = BrownTheme - this.color = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - this.customBorderColor = BrownThemeColors.interactiveFocus - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets index 74a8114..98470c9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct RadioCase1Page { @State customTheme: CustomTheme = RedTheme - @State customBorderColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customForegroundColor: ResourceColor = RedThemeColors.fontOnPrimary count = 0 data: string[] = [] @@ -26,8 +23,6 @@ struct RadioCase1Page { ForEach(this.data, (item: string) => { Radio({ value: item, group: item }) .checked(true) - .borderColor(this.customBorderColor) - .foregroundColor(this.customForegroundColor) }, (item: string) => item) } } @@ -42,20 +37,14 @@ struct RadioCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.customBorderColor = RedThemeColors.backgroundEmphasize - this.customForegroundColor = RedThemeColors.fontOnPrimary break case 1: this.customTheme = GreenTheme - this.customBorderColor = GreenThemeColors.backgroundEmphasize - this.customForegroundColor = GreenThemeColors.fontOnPrimary break case 2: default: this.customTheme = BrownTheme - this.customBorderColor = BrownThemeColors.backgroundEmphasize - this.customForegroundColor = BrownThemeColors.fontOnPrimary - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets index dd9310a..1e95214 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct RadioCase2Page { @State customTheme: CustomTheme = RedTheme - @State customBorderColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customForegroundColor: ResourceColor = RedThemeColors.fontOnPrimary count = 0 data: string[] = [] @@ -26,8 +23,6 @@ struct RadioCase2Page { WithTheme({ theme: this.customTheme }) { Radio({ value: item, group: item }) .checked(true) - .borderColor(this.customBorderColor) - .foregroundColor(this.customForegroundColor) } }, (item: string) => item) } @@ -43,19 +38,13 @@ struct RadioCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.customBorderColor = RedThemeColors.backgroundEmphasize - this.customForegroundColor = RedThemeColors.fontOnPrimary - break + break case 1: this.customTheme = GreenTheme - this.customBorderColor = GreenThemeColors.backgroundEmphasize - this.customForegroundColor = GreenThemeColors.fontOnPrimary - break + break case 2: default: this.customTheme = BrownTheme - this.customBorderColor = BrownThemeColors.backgroundEmphasize - this.customForegroundColor = BrownThemeColors.fontOnPrimary break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets index c7698b1..ac87580 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,7 @@ class MyDataSource extends BasicDataSource { @Component struct RadioCase3Page { @State customTheme: CustomTheme = RedTheme - @State customBorderColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customForegroundColor: ResourceColor = RedThemeColors.fontOnPrimary - count = 0 + count = 0 private data: MyDataSource = new MyDataSource(); aboutToAppear() { @@ -105,9 +102,7 @@ struct RadioCase3Page { ListItem() { Radio({ value: item, group: item }) .checked(true) - .borderColor(this.customBorderColor) - .foregroundColor(this.customForegroundColor) - }.width('100%') + }.width('100%') }, (item: string) => item) } .width('100%') @@ -121,19 +116,13 @@ struct RadioCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.customBorderColor = RedThemeColors.backgroundEmphasize - this.customForegroundColor = RedThemeColors.fontOnPrimary - break + break case 1: this.customTheme = GreenTheme - this.customBorderColor = GreenThemeColors.backgroundEmphasize - this.customForegroundColor = GreenThemeColors.fontOnPrimary break case 2: default: this.customTheme = BrownTheme - this.customBorderColor = BrownThemeColors.backgroundEmphasize - this.customForegroundColor = BrownThemeColors.fontOnPrimary break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets index 375d0d1..6b72110 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct RadioCase4Page { @State customTheme: CustomTheme = RedTheme - @State customBorderColor: ResourceColor = RedThemeColors.backgroundEmphasize - @State customForegroundColor: ResourceColor = RedThemeColors.fontOnPrimary count = 0 private data: MyDataSource = new MyDataSource(); @@ -105,8 +102,6 @@ struct RadioCase4Page { WithTheme({ theme: this.customTheme }) { Radio({ value: item, group: item }) .checked(true) - .borderColor(this.customBorderColor) - .foregroundColor(this.customForegroundColor) } }.width('100%') }, (item: string) => item) @@ -122,20 +117,14 @@ struct RadioCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.customBorderColor = RedThemeColors.backgroundEmphasize - this.customForegroundColor = RedThemeColors.fontOnPrimary break case 1: this.customTheme = GreenTheme - this.customBorderColor = GreenThemeColors.backgroundEmphasize - this.customForegroundColor = GreenThemeColors.fontOnPrimary - break + break case 2: default: this.customTheme = BrownTheme - this.customBorderColor = BrownThemeColors.backgroundEmphasize - this.customForegroundColor = BrownThemeColors.fontOnPrimary - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets index 7ab625b..7f620d9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct SelectCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -44,19 +41,13 @@ struct SelectCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets index 5dc5838..e1d5c3d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct SelectCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -45,19 +42,13 @@ struct SelectCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets index 83ba7d5..2051499 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct SelectCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -123,20 +120,14 @@ struct SelectCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets index 323be51..01aa27b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct SelectCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -124,19 +121,13 @@ struct SelectCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets index 056cc2e..c0552d7 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets @@ -1,15 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct SwiperCase1Page { @State customTheme: CustomTheme = RedTheme - @State fontColor: ResourceColor = RedThemeColors.fontOnPrimary - @State dotColor: ResourceColor = RedThemeColors.interactivePressed - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] dotIndicator: DotIndicator = new DotIndicator() @@ -30,24 +26,18 @@ struct SwiperCase1Page { Text(item + '-1') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + '-2') .width('30%') .height(35) - .backgroundColor(this.bkgColor) - .textAlign(TextAlign.Center) + .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) - Text(item + '-3') + Text(item + '-3') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) } .margin({ bottom: 20 }) .autoPlay(true) @@ -56,8 +46,7 @@ struct SwiperCase1Page { .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor) - .itemWidth(3) + .itemWidth(3) .itemHeight(3)) }, (item: string) => item) } @@ -73,23 +62,14 @@ struct SwiperCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.fontColor = RedThemeColors.fontOnPrimary - this.dotColor = RedThemeColors.interactivePressed - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.fontColor = GreenThemeColors.fontOnPrimary - this.dotColor = GreenThemeColors.interactivePressed - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.fontColor = BrownThemeColors.fontOnPrimary - this.dotColor = BrownThemeColors.interactivePressed - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets index 4b0207d..e7ab266 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets @@ -1,16 +1,12 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct SwiperCase2Page { @State customTheme: CustomTheme = RedTheme - @State fontColor: ResourceColor = RedThemeColors.fontOnPrimary - @State dotColor: ResourceColor = RedThemeColors.interactivePressed - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - count = 0 + count = 0 data: string[] = [] dotIndicator: DotIndicator = new DotIndicator() @@ -30,25 +26,19 @@ struct SwiperCase2Page { Text(item + '-1') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + '-2') .width('30%') .height(35) - .backgroundColor(this.bkgColor) - .textAlign(TextAlign.Center) + .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) - Text(item + '-3') + Text(item + '-3') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) - } + } .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) @@ -56,7 +46,6 @@ struct SwiperCase2Page { .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor) .itemWidth(3) .itemHeight(3)) } @@ -74,23 +63,14 @@ struct SwiperCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.fontColor = RedThemeColors.fontOnPrimary - this.dotColor = RedThemeColors.interactivePressed - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.fontColor = GreenThemeColors.fontOnPrimary - this.dotColor = GreenThemeColors.interactivePressed - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.fontColor = BrownThemeColors.fontOnPrimary - this.dotColor = BrownThemeColors.interactivePressed - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets index 340761e..9570f55 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct SwiperCase3Page { @State customTheme: CustomTheme = RedTheme - @State fontColor: ResourceColor = RedThemeColors.fontOnPrimary - @State dotColor: ResourceColor = RedThemeColors.interactivePressed - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); dotIndicator: DotIndicator = new DotIndicator() @@ -109,25 +105,19 @@ struct SwiperCase3Page { Text(item + ' index = ' + index + '-1') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + ' index = ' + index + '-2') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + ' index = ' + index + '-3') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) - } + } .margin({ bottom: 20 }) .autoPlay(true) .interval(4000) @@ -135,8 +125,7 @@ struct SwiperCase3Page { .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor) - .itemWidth(3) + .itemWidth(3) .itemHeight(3)) }.width('100%') }, (item: string) => item) @@ -152,22 +141,13 @@ struct SwiperCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.fontColor = RedThemeColors.fontOnPrimary - this.dotColor = RedThemeColors.interactivePressed - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.fontColor = GreenThemeColors.fontOnPrimary - this.dotColor = GreenThemeColors.interactivePressed - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.fontColor = BrownThemeColors.fontOnPrimary - this.dotColor = BrownThemeColors.interactivePressed - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets index 48ec057..e9ab535 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,9 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct SwiperCase4Page { @State customTheme: CustomTheme = RedTheme - @State fontColor: ResourceColor = RedThemeColors.fontOnPrimary - @State dotColor: ResourceColor = RedThemeColors.interactivePressed - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource() dotIndicator: DotIndicator = new DotIndicator() @@ -109,24 +105,18 @@ struct SwiperCase4Page { Text(item + ' index = ' + index + '-1') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + ' index = ' + index + '-2') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) Text(item + ' index = ' + index + '-3') .width('30%') .height(35) - .backgroundColor(this.bkgColor) .textAlign(TextAlign.Center) .fontSize(10) - .fontColor(this.fontColor) } .margin({ bottom: 20 }) .autoPlay(true) @@ -135,7 +125,6 @@ struct SwiperCase4Page { .vertical(true) .duration(1000) .indicator(this.dotIndicator - .color(this.dotColor) .itemWidth(3) .itemHeight(3)) } @@ -153,22 +142,13 @@ struct SwiperCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.fontColor = RedThemeColors.fontOnPrimary - this.dotColor = RedThemeColors.interactivePressed - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.fontColor = GreenThemeColors.fontOnPrimary - this.dotColor = GreenThemeColors.interactivePressed - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.fontColor = BrownThemeColors.fontOnPrimary - this.dotColor = BrownThemeColors.interactivePressed - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets index cb4bb22..87293c0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,9 +22,7 @@ struct TextCase1Page { Column({ space: '30vp' }) { ForEach(this.data, (item: string) => { Text(item) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) - }, (item: string) => item) + }, (item: string) => item) } } .width('100%') @@ -41,19 +36,13 @@ struct TextCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets index 589fba2..b3e3c00 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,8 +22,6 @@ struct TextCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Text(item) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) } }, (item: string) => item) } @@ -42,19 +37,13 @@ struct TextCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets index 12513b4..2a3bc44 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,9 +101,7 @@ struct TextCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Text(item + ' index = ' + index) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) - }.width('100%') + }.width('100%') }, (item: string) => item) } .width('100%') @@ -120,20 +115,14 @@ struct TextCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets index 9a9ec4b..917df46 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,6 @@ struct TextCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { Text(item + ' index = ' + index) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) } }.width('100%') }, (item: string) => item) @@ -121,19 +116,13 @@ struct TextCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets index 67a4b8e..fe54538 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextClockCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,9 +22,7 @@ struct TextClockCase1Page { Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { TextClock() - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) - .width('30%') + .width('30%') .margin({ bottom: 20 }) }, (item: string) => item) } @@ -43,19 +38,13 @@ struct TextClockCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets index 2228344..83723c1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextClockCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,8 +22,6 @@ struct TextClockCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { TextClock() - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') .margin({ bottom: 20 }) } @@ -44,20 +39,14 @@ struct TextClockCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets index 7feb34c..dae8f0d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextClockCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,9 +101,7 @@ struct TextClockCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { TextClock() - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) - .width('30%') + .width('30%') .margin({ bottom: 20 }) }.width('100%') }, (item: string) => item) @@ -122,19 +117,13 @@ struct TextClockCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets index 28c21f0..17bc38f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextClockCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,6 @@ struct TextClockCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { TextClock() - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') .margin({ bottom: 20 }) } @@ -123,19 +118,13 @@ struct TextClockCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize - break + break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets index 32b85d3..ff3a049 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets @@ -1,15 +1,12 @@ /* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextInputCase1Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize - count = 0 + count = 0 data: string[] = [] aboutToAppear() { @@ -25,8 +22,6 @@ struct TextInputCase1Page { Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { TextInput({ placeholder: item }) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') }, (item: string) => item) } @@ -42,19 +37,13 @@ struct TextInputCase1Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets index ad52491..08732b7 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets @@ -1,14 +1,11 @@ /* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme' -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct TextInputCase2Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] @@ -25,8 +22,6 @@ struct TextInputCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { TextInput({ placeholder: item }) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') } }, (item: string) => item) @@ -43,19 +38,13 @@ struct TextInputCase2Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets index 3ecb205..4d252b6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextInputCase3Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,6 @@ struct TextInputCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { TextInput({ placeholder: item + ' index = ' + index }) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') }.width('100%') }, (item: string) => item) @@ -121,20 +116,14 @@ struct TextInputCase3Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets index 435e4e0..48b5440 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets @@ -1,6 +1,5 @@ /* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ import { CustomTheme } from '@ohos.arkui.theme'; -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { @@ -86,8 +85,6 @@ class MyDataSource extends BasicDataSource { @Component struct TextInputCase4Page { @State customTheme: CustomTheme = RedTheme - @State textColor: ResourceColor = RedThemeColors.fontOnPrimary - @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 private data: MyDataSource = new MyDataSource(); @@ -104,8 +101,6 @@ struct TextInputCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { TextInput({ placeholder: item + ' index = ' + index }) - .fontColor(this.textColor) - .backgroundColor(this.bkgColor) .width('30%') } }.width('100%') @@ -122,20 +117,14 @@ struct TextInputCase4Page { switch (this.count) { case 0: this.customTheme = RedTheme - this.textColor = RedThemeColors.fontOnPrimary - this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: this.customTheme = GreenTheme - this.textColor = GreenThemeColors.fontOnPrimary - this.bkgColor = GreenThemeColors.backgroundEmphasize - break + break case 2: default: this.customTheme = BrownTheme - this.textColor = BrownThemeColors.fontOnPrimary - this.bkgColor = BrownThemeColors.backgroundEmphasize - break + break } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets index 5648b25..7aec396 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets @@ -1,42 +1,78 @@ import { CustomColors } from '@ohos.arkui.theme' export class RedColors implements CustomColors { + fontPrimary = '#ffec0a0a' + fontSecondary = '#ffec0a0a' fontOnPrimary = '#ffecd6d6' backgroundEmphasize = '#FFD00000' interactivePressed = '#e5e5e5' interactiveFocus = '#ffff0000' iconOnPrimary = '#ffe77777' + iconSecondary = '#FFD00000' iconFourth = '#fff31a1a' + iconPrimary = '#FFD00060' compBackgroundEmphasize = '#ffb11919' compEmphasizeSecondary = '#ffec0a0a' compBackgroundTertiary = '#ffe37979' compBackgroundSecondary = '#ffe37979' + backgroundPrimary = '#ffe37979' + backgroundSecondary = '#ffe37979' + backgroundTertiary = '#ffe37979' + backgroundFourth = '#ffe37979' + compBackgroundPrimaryTran = '#ffe37979' + brand = '#FFD00060' + compBackgroundNeutral = '#ffe37979' + compDivider = '#FFD00000' } export class GreenColors implements CustomColors { + fontPrimary = '#ff1b8807' + fontSecondary = '#ff1b8807' fontOnPrimary = '#ffcfe2c2' backgroundEmphasize = '#FF00541F' interactivePressed = '#e5e5e5' interactiveFocus = '#ff00ba45' + iconSecondary = '#ff1b8807' + iconPrimary = '#ff1b8807' iconOnPrimary = '#ff9ee777' iconFourth = '#ff49f31a' compBackgroundEmphasize = '#ff53b119' compEmphasizeSecondary = '#ff1b8807' compBackgroundTertiary = '#ff8ce379' compBackgroundSecondary = '#ff8ce379' + compBackgroundPrimaryTran = '#ff8ce379' + backgroundPrimary = '#ff53b119' + backgroundSecondary = '#ff53b119' + backgroundTertiary = '#ff53b119' + backgroundFourth = '#ff53b119' + brand = '#FF005460' + compBackgroundNeutral = '#ff00ba45' + compDivider = '#FF00541F' } export class BrownColors implements CustomColors { + fontPrimary = '#ff4a4060' + fontSecondary = '#ff4a4060' fontOnPrimary = '#ffc6b2b2' backgroundEmphasize = '#ff4a4039' interactivePressed = '#e5e5e5' interactiveFocus = '#ff664535' + iconPrimary = '#ff643e3e' iconOnPrimary = '#ff735b58' + iconSecondary = '#ff735b58' iconFourth = '#ff643e3e' compBackgroundEmphasize = '#ff4a2525' compEmphasizeSecondary = '#ff450f0f' compBackgroundTertiary = '#ff886161' compBackgroundSecondary = '#ff886161' + compBackgroundPrimaryTran = '#ff886161' + backgroundPrimary = '#ff886161' + backgroundSecondary = '#ff886161' + backgroundTertiary = '#ff886161' + backgroundFourth = '#ff886161' + brand = '#ff4a4060' + compBackgroundNeutral = '#ff664535' + compDivider = '#ff450f0f' } export const RedThemeColors = new RedColors() -- Gitee From 3543f2380b928d82961a7f6e31a162e53b871118 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 14 Oct 2024 12:34:10 +0300 Subject: [PATCH 11/37] slider page added --- .../ets/ability/slider/SliderCase1Ability.ets | 43 ++++++ .../ets/ability/slider/SliderCase2Ability.ets | 43 ++++++ .../ets/ability/slider/SliderCase3Ability.ets | 43 ++++++ .../ets/ability/slider/SliderCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../pages/tests/slider/SliderCase1Page.ets | 53 +++++++ .../pages/tests/slider/SliderCase2Page.ets | 53 +++++++ .../pages/tests/slider/SliderCase3Page.ets | 132 ++++++++++++++++++ .../pages/tests/slider/SliderCase4Page.ets | 132 ++++++++++++++++++ .../tests/slider/SliderNavigationPage.ets | 55 ++++++++ .../entry/src/main/module.json5 | 40 ++++++ .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 648 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase1Ability.ets new file mode 100644 index 0000000..ed143db --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase2Ability.ets new file mode 100644 index 0000000..7f251ed --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase3Ability.ets new file mode 100644 index 0000000..c485e8e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase4Ability.ets new file mode 100644 index 0000000..3ffb6d5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 6b7b046..3794134 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -64,6 +64,10 @@ struct TestsNavigationPage { { title: 'AlphabetIndexer', page: 'pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage' + }, + { + title: 'slider', + page: 'pages/tests/slider/SliderNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets new file mode 100644 index 0000000..c486a2f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets @@ -0,0 +1,53 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SliderCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + Slider() + .width('60%') + .trackThickness(10) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets new file mode 100644 index 0000000..6377ce4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets @@ -0,0 +1,53 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Slider() + .width('60%') + .trackThickness(10) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets new file mode 100644 index 0000000..6df8f63 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets @@ -0,0 +1,132 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Slider() + .width('60%') + .trackThickness(10) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets new file mode 100644 index 0000000..2ac958d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets @@ -0,0 +1,132 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Slider() + .width('60%') + .trackThickness(10) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets new file mode 100644 index 0000000..690ecee --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct SliderNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Texts', + ability: 'SliderCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Texts', + ability: 'SliderCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Texts', + ability: 'SliderCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts', + ability: 'SliderCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 62ed87f..5e3a38d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -651,6 +651,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase1Ability", + "srcEntry": "./ets/ability/slider/SliderCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase2Ability", + "srcEntry": "./ets/ability/slider/SliderCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase3Ability", + "srcEntry": "./ets/ability/slider/SliderCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase4Ability", + "srcEntry": "./ets/ability/slider/SliderCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 811e568..8516ccb 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -79,6 +79,11 @@ "pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page", "pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page", "pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page", - "pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage" + "pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage", + "pages/tests/slider/SliderCase1Page", + "pages/tests/slider/SliderCase2Page", + "pages/tests/slider/SliderCase3Page", + "pages/tests/slider/SliderCase4Page", + "pages/tests/slider/SliderNavigationPage" ] } \ No newline at end of file -- Gitee From 807fe425da3e3e74438da460c2b9d4260b953c43 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 14 Oct 2024 13:00:33 +0300 Subject: [PATCH 12/37] add text picker pages --- .../textPicker/TextPickerCase1Ability.ets | 43 ++++++ .../textPicker/TextPickerCase2Ability.ets | 43 ++++++ .../textPicker/TextPickerCase3Ability.ets | 43 ++++++ .../textPicker/TextPickerCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 6 +- .../pages/tests/slider/SliderCase2Page.ets | 2 +- .../pages/tests/slider/SliderCase3Page.ets | 2 +- .../pages/tests/slider/SliderCase4Page.ets | 2 +- .../tests/textPicker/TextPickerCase1Page.ets | 56 ++++++++ .../tests/textPicker/TextPickerCase2Page.ets | 56 ++++++++ .../tests/textPicker/TextPickerCase3Page.ets | 135 ++++++++++++++++++ .../tests/textPicker/TextPickerCase4Page.ets | 135 ++++++++++++++++++ .../textPicker/TextPickerNavigationPage.ets | 55 +++++++ .../entry/src/main/module.json5 | 40 ++++++ .../resources/base/profile/main_pages.json | 7 +- 15 files changed, 664 insertions(+), 5 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase1Ability.ets new file mode 100644 index 0000000..6124163 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase2Ability.ets new file mode 100644 index 0000000..7409b6f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase3Ability.ets new file mode 100644 index 0000000..bcef95f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase4Ability.ets new file mode 100644 index 0000000..3badca3 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 3794134..01f4841 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -66,8 +66,12 @@ struct TestsNavigationPage { page: 'pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage' }, { - title: 'slider', + title: 'Slider', page: 'pages/tests/slider/SliderNavigationPage' + }, + { + title: 'textPicker', + page: 'pages/tests/textPicker/TextPickerNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets index 6377ce4..5a99660 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets @@ -4,7 +4,7 @@ import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl @Entry @Component -struct TextCase2Page { +struct SliderCase2Page { @State customTheme: CustomTheme = RedTheme count = 0 data: string[] = [] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets index 6df8f63..6ba8ae5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets @@ -83,7 +83,7 @@ class MyDataSource extends BasicDataSource { @Entry @Component -struct TextCase3Page { +struct SliderCase3Page { @State customTheme: CustomTheme = RedTheme count = 0 private data: MyDataSource = new MyDataSource(); diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets index 2ac958d..de48590 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets @@ -83,7 +83,7 @@ class MyDataSource extends BasicDataSource { @Entry @Component -struct TextCase4Page { +struct SliderCase4Page { @State customTheme: CustomTheme = RedTheme count = 0 private data: MyDataSource = new MyDataSource(); diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets new file mode 100644 index 0000000..79737be --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets @@ -0,0 +1,56 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextPickerCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + TextPicker({ range: this.multi }) + .width('60%') + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets new file mode 100644 index 0000000..c8efdd0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets @@ -0,0 +1,56 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextPickerCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TextPicker({ range: this.multi }) + .width('60%') + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets new file mode 100644 index 0000000..de7e230 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets @@ -0,0 +1,135 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextPickerCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TextPicker({ range: this.multi }) + .width('60%') + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets new file mode 100644 index 0000000..0946a95 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets @@ -0,0 +1,135 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextPickerCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TextPicker({ range: this.multi }) + .width('60%') + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets new file mode 100644 index 0000000..6e59dfa --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct TextPickerNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Texts', + ability: 'TextPickerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Texts', + ability: 'TextPickerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Texts', + ability: 'TextPickerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts', + ability: 'TextPickerCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 5e3a38d..f7da26e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -691,6 +691,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase1Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase2Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase3Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase4Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 8516ccb..3680b82 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -84,6 +84,11 @@ "pages/tests/slider/SliderCase2Page", "pages/tests/slider/SliderCase3Page", "pages/tests/slider/SliderCase4Page", - "pages/tests/slider/SliderNavigationPage" + "pages/tests/slider/SliderNavigationPage", + "pages/tests/textPicker/TextPickerCase1Page", + "pages/tests/textPicker/TextPickerCase2Page", + "pages/tests/textPicker/TextPickerCase3Page", + "pages/tests/textPicker/TextPickerCase4Page", + "pages/tests/textPicker/TextPickerNavigationPage" ] } \ No newline at end of file -- Gitee From 91099b19217b842bda10341c5faf97a77116f2d6 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Mon, 14 Oct 2024 14:26:48 +0300 Subject: [PATCH 13/37] text picker Button changed --- .../entry/src/main/ets/pages/tests/TestsNavigationPage.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 01f4841..c2d5c63 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -70,7 +70,7 @@ struct TestsNavigationPage { page: 'pages/tests/slider/SliderNavigationPage' }, { - title: 'textPicker', + title: 'TextPicker', page: 'pages/tests/textPicker/TextPickerNavigationPage' } ] -- Gitee From 732ebcf9c95ac719a0c9fc40f7f8735970dac4c2 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 23 Oct 2024 21:58:12 +0300 Subject: [PATCH 14/37] DataPanel pages added --- .../DataPanel/DataPanelCase1Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase2Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase3Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase4Ability.ets | 44 ++++++ .../tests/DataPanel/DataPanelCase1Page.ets | 55 +++++++ .../tests/DataPanel/DataPanelCase2Page.ets | 55 +++++++ .../tests/DataPanel/DataPanelCase3Page.ets | 135 ++++++++++++++++++ .../tests/DataPanel/DataPanelCase4Page.ets | 134 +++++++++++++++++ .../DataPanel/DataPanelNavigationPage.ets | 55 +++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../entry/src/main/module.json5 | 44 +++++- .../resources/base/profile/main_pages.json | 7 +- 12 files changed, 659 insertions(+), 3 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase1Ability.ets new file mode 100644 index 0000000..310d447 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase2Ability.ets new file mode 100644 index 0000000..e3c8acb --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase3Ability.ets new file mode 100644 index 0000000..e77f61b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase4Ability.ets new file mode 100644 index 0000000..f5ab061 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets new file mode 100644 index 0000000..79d3273 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DataPanelCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('60%') + .height(35) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets new file mode 100644 index 0000000..a2b80f7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DataPanelCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('60%') + .height(35) + } + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets new file mode 100644 index 0000000..d5a46cf --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets @@ -0,0 +1,135 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DataPanelCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('60%') + .height(35) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets new file mode 100644 index 0000000..6ac1e9f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DataPanelCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('60%') + .height(35) + } + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets new file mode 100644 index 0000000..81034b3 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct DataPanelNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 DataPanels', + ability: 'DataPanelCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 DataPanels', + ability: 'DataPanelCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 DataPanels', + ability: 'DataPanelCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 DataPanels', + ability: 'DataPanelCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index c2d5c63..6ba3fd5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -72,6 +72,10 @@ struct TestsNavigationPage { { title: 'TextPicker', page: 'pages/tests/textPicker/TextPickerNavigationPage' + }, + { + title: 'DataPanel', + page: 'pages/tests/DataPanel/DataPanelNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index f7da26e..08f165e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -714,7 +714,7 @@ }, { "name": "TextPickerCase3Ability", - "srcEntry": "./ets/ability/textPicker/TextPickerCase2Ability.ets", + "srcEntry": "./ets/ability/textPicker/TextPickerCase3Ability.ets", "description": "$string:Demo1Case1Ability_desc", "icon": "$media:icon", "label": "$string:Demo1Case1Ability_label", @@ -724,7 +724,47 @@ }, { "name": "TextPickerCase4Ability", - "srcEntry": "./ets/ability/textPicker/TextPickerCase2Ability.ets", + "srcEntry": "./ets/ability/textPicker/TextPickerCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase1Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase2Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase3Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase4Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase4Ability.ets", "description": "$string:Demo1Case1Ability_desc", "icon": "$media:icon", "label": "$string:Demo1Case1Ability_label", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 3680b82..13fb72c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -89,6 +89,11 @@ "pages/tests/textPicker/TextPickerCase2Page", "pages/tests/textPicker/TextPickerCase3Page", "pages/tests/textPicker/TextPickerCase4Page", - "pages/tests/textPicker/TextPickerNavigationPage" + "pages/tests/textPicker/TextPickerNavigationPage", + "pages/tests/DataPanel/DataPanelCase1Page", + "pages/tests/DataPanel/DataPanelCase2Page", + "pages/tests/DataPanel/DataPanelCase3Page", + "pages/tests/DataPanel/DataPanelCase4Page", + "pages/tests/DataPanel/DataPanelNavigationPage" ] } \ No newline at end of file -- Gitee From b56238434ed2671ce25749c8c87a80243e36e9a5 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 23 Oct 2024 22:50:10 +0300 Subject: [PATCH 15/37] add DatePicker page --- .../DatePicker/DatePickerCase1Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase2Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase3Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase4Ability.ets | 44 ++++++ .../tests/DatePicker/DatePickerCase1Page.ets | 54 +++++++ .../tests/DatePicker/DatePickerCase2Page.ets | 54 +++++++ .../tests/DatePicker/DatePickerCase3Page.ets | 134 ++++++++++++++++++ .../tests/DatePicker/DatePickerCase4Page.ets | 133 +++++++++++++++++ .../DatePicker/DatePickerNavigationPage.ets | 55 +++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../src/main/ets/theme/CustomColorsImlp.ets | 3 + .../entry/src/main/module.json5 | 40 ++++++ .../resources/base/profile/main_pages.json | 7 +- 13 files changed, 656 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase1Ability.ets new file mode 100644 index 0000000..c11a916 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase2Ability.ets new file mode 100644 index 0000000..8a20e1f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase3Ability.ets new file mode 100644 index 0000000..6f2e7fe --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase4Ability.ets new file mode 100644 index 0000000..d934eb4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets new file mode 100644 index 0000000..f149e9b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets @@ -0,0 +1,54 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DatePickerCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + Row() { + DatePicker() + .width('60%') + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets new file mode 100644 index 0000000..59d5745 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets @@ -0,0 +1,54 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DatePickerCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + DatePicker() + .width('60%') + } + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets new file mode 100644 index 0000000..93dc3f6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DatePickerCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + DatePicker() + .width('60%') + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets new file mode 100644 index 0000000..1497ef4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets @@ -0,0 +1,133 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DatePickerCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + DatePicker() + .width('60%') + } + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets new file mode 100644 index 0000000..12d47c6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct DatePickerNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 DatePickers', + ability: 'DatePickerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 DatePickers', + ability: 'DatePickerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 DatePickers', + ability: 'DatePickerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 DatePickers', + ability: 'DatePickerCase4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 6ba3fd5..4f51a11 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -76,6 +76,10 @@ struct TestsNavigationPage { { title: 'DataPanel', page: 'pages/tests/DataPanel/DataPanelNavigationPage' + }, + { + title: 'DatePicker', + page: 'pages/tests/DatePicker/DatePickerNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets index 7aec396..c5f1186 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets @@ -3,6 +3,7 @@ import { CustomColors } from '@ohos.arkui.theme' export class RedColors implements CustomColors { fontPrimary = '#ffec0a0a' fontSecondary = '#ffec0a0a' + fontEmphasize = '#FFD00060' fontOnPrimary = '#ffecd6d6' backgroundEmphasize = '#FFD00000' interactivePressed = '#e5e5e5' @@ -28,6 +29,7 @@ export class RedColors implements CustomColors { export class GreenColors implements CustomColors { fontPrimary = '#ff1b8807' fontSecondary = '#ff1b8807' + fontEmphasize = '#FF00541F' fontOnPrimary = '#ffcfe2c2' backgroundEmphasize = '#FF00541F' interactivePressed = '#e5e5e5' @@ -54,6 +56,7 @@ export class BrownColors implements CustomColors { fontPrimary = '#ff4a4060' fontSecondary = '#ff4a4060' fontOnPrimary = '#ffc6b2b2' + fontEmphasize = '#ff450f0f' backgroundEmphasize = '#ff4a4039' interactivePressed = '#e5e5e5' interactiveFocus = '#ff664535' diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 08f165e..797ec51 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -771,6 +771,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase1Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase2Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase3Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase4Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 13fb72c..c3254eb 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -94,6 +94,11 @@ "pages/tests/DataPanel/DataPanelCase2Page", "pages/tests/DataPanel/DataPanelCase3Page", "pages/tests/DataPanel/DataPanelCase4Page", - "pages/tests/DataPanel/DataPanelNavigationPage" + "pages/tests/DataPanel/DataPanelNavigationPage", + "pages/tests/DatePicker/DatePickerCase1Page", + "pages/tests/DatePicker/DatePickerCase2Page", + "pages/tests/DatePicker/DatePickerCase3Page", + "pages/tests/DatePicker/DatePickerCase4Page", + "pages/tests/DatePicker/DatePickerNavigationPage" ] } \ No newline at end of file -- Gitee From e3fe7a3d79a7004a7e592f869a64ea23ebb48327 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Fri, 1 Nov 2024 20:49:33 +0300 Subject: [PATCH 16/37] modified button page --- .../ability/button/ButtonCase11Ability.ets | 43 ++++++ .../ability/button/ButtonCase21Ability.ets | 43 ++++++ .../ability/button/ButtonCase31Ability.ets | 43 ++++++ .../ability/button/ButtonCase41Ability.ets | 43 ++++++ .../pages/tests/button/ButtonCase11Page.ets | 54 +++++++ .../pages/tests/button/ButtonCase1Page.ets | 7 +- .../pages/tests/button/ButtonCase21Page.ets | 54 +++++++ .../pages/tests/button/ButtonCase2Page.ets | 7 +- .../pages/tests/button/ButtonCase31Page.ets | 133 ++++++++++++++++++ .../pages/tests/button/ButtonCase3Page.ets | 7 +- .../pages/tests/button/ButtonCase41Page.ets | 133 ++++++++++++++++++ .../pages/tests/button/ButtonCase4Page.ets | 7 +- .../tests/button/ButtonNavigationPage.ets | 16 +++ .../entry/src/main/module.json5 | 40 ++++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 626 insertions(+), 8 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase11Ability.ets new file mode 100644 index 0000000..9ecf4be --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ButtonCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/button/ButtonCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase21Ability.ets new file mode 100644 index 0000000..3a23c65 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ButtonCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/button/ButtonCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase31Ability.ets new file mode 100644 index 0000000..b1ced9f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ButtonCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/button/ButtonCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase41Ability.ets new file mode 100644 index 0000000..9b65b57 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/button/ButtonCase41Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ButtonCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/button/ButtonCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets new file mode 100644 index 0000000..5f73dae --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets @@ -0,0 +1,54 @@ +/* ForEach List with 100 Buttons as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct ButtonCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets index 26953c2..63e87fe 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets @@ -19,9 +19,12 @@ struct ButtonCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '8vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { - Button(item) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets new file mode 100644 index 0000000..25106db --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets @@ -0,0 +1,54 @@ +/* ForEach List with 100 Buttons as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct ButtonCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets index e499be1..30404fe 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets @@ -18,10 +18,13 @@ struct ButtonCase2Page { build() { Row() { Scroll() { - Column({ space: '8vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Button(item) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets new file mode 100644 index 0000000..732bfb3 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets @@ -0,0 +1,133 @@ +/* LazyForEach List with 2000 Buttons as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct ButtonCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets index c4a44d9..1418f76 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets @@ -97,10 +97,13 @@ struct ButtonCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '8vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Button(item + ' index = ' + index) + Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets new file mode 100644 index 0000000..748ed4d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets @@ -0,0 +1,133 @@ +/* LazyForEach List with 2000 Buttons as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct ButtonCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets index 4ab9acc..4e86ec2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets @@ -96,11 +96,14 @@ struct ButtonCase4Page { build() { Row() { - List({ space: '8vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Button(item + ' index = ' + index) + Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) + .width('70%') + .height(36) + .margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonNavigationPage.ets index 4dc5a62..eccfe15 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonNavigationPage.ets @@ -26,6 +26,22 @@ struct ButtonNavigationPage { title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Buttons', ability: 'ButtonCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Buttons, theme changing on touch', + ability: 'ButtonCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Buttons, theme changing on touch', + ability: 'ButtonCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Buttons, theme changing on touch', + ability: 'ButtonCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Buttons, theme changing on touch', + ability: 'ButtonCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 797ec51..620f92f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -811,6 +811,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ButtonCase11Ability", + "srcEntry": "./ets/ability/button/ButtonCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ButtonCase21Ability", + "srcEntry": "./ets/ability/button/ButtonCase21Ability.ets", + "description": "$string:Demo1Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ButtonCase31Ability", + "srcEntry": "./ets/ability/button/ButtonCase31Ability.ets", + "description": "$string:Demo3Case3Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case3Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ButtonCase41Ability", + "srcEntry": "./ets/ability/button/ButtonCase41Ability.ets", + "description": "$string:Demo3Case4Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case4Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index c3254eb..4a2c540 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -13,6 +13,10 @@ "pages/tests/button/ButtonCase2Page", "pages/tests/button/ButtonCase3Page", "pages/tests/button/ButtonCase4Page", + "pages/tests/button/ButtonCase11Page", + "pages/tests/button/ButtonCase21Page", + "pages/tests/button/ButtonCase31Page", + "pages/tests/button/ButtonCase41Page", "pages/tests/button/ButtonNavigationPage", "pages/tests/TestsNavigationPage", "pages/tests/text/TextCase1Page", -- Gitee From 25470e4981c0ecb6a2ba0b0ed114301d82379bcf Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Fri, 1 Nov 2024 22:42:01 +0300 Subject: [PATCH 17/37] checkbox modified --- .../checkbox/CheckboxCase11Ability.ets | 43 ++++++ .../checkbox/CheckboxCase21Ability.ets | 43 ++++++ .../checkbox/CheckboxCase31Ability.ets | 43 ++++++ .../checkbox/CheckboxCase41Ability.ets | 44 ++++++ .../pages/tests/button/ButtonCase11Page.ets | 52 ++++--- .../pages/tests/button/ButtonCase1Page.ets | 18 ++- .../pages/tests/button/ButtonCase21Page.ets | 52 ++++--- .../pages/tests/button/ButtonCase2Page.ets | 18 ++- .../pages/tests/button/ButtonCase31Page.ets | 52 ++++--- .../pages/tests/button/ButtonCase3Page.ets | 20 ++- .../pages/tests/button/ButtonCase41Page.ets | 52 ++++--- .../pages/tests/button/ButtonCase4Page.ets | 18 ++- .../tests/checkbox/CheckboxCase11Page.ets | 66 ++++++++ .../tests/checkbox/CheckboxCase1Page.ets | 18 ++- .../tests/checkbox/CheckboxCase21Page.ets | 66 ++++++++ .../tests/checkbox/CheckboxCase2Page.ets | 18 ++- .../tests/checkbox/CheckboxCase31Page.ets | 146 ++++++++++++++++++ .../tests/checkbox/CheckboxCase3Page.ets | 18 ++- .../tests/checkbox/CheckboxCase41Page.ets | 145 +++++++++++++++++ .../tests/checkbox/CheckboxCase4Page.ets | 18 ++- .../tests/checkbox/CheckboxNavigationPage.ets | 16 ++ .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 23 files changed, 885 insertions(+), 125 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase11Ability.ets new file mode 100644 index 0000000..88ae07e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CheckboxCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/checkbox/CheckboxCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase21Ability.ets new file mode 100644 index 0000000..3193709 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CheckboxCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/checkbox/CheckboxCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase31Ability.ets new file mode 100644 index 0000000..2aae538 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CheckboxCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/checkbox/CheckboxCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase41Ability.ets new file mode 100644 index 0000000..9fce59a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/checkbox/CheckboxCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CheckboxCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/checkbox/CheckboxCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets index 5f73dae..04af23b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase11Page.ets @@ -11,7 +11,7 @@ struct ButtonCase11Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } @@ -19,34 +19,42 @@ struct ButtonCase11Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '4vp' }) { + Column({ space: '3vp' }) { ForEach(this.data, (item: string) => { - Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) }, (item: string) => item) } } .width('100%') } .height('100%') - .onTouch(() => { - this.count++ - if (this.count > 2) { - this.count = 0 - } - switch (this.count) { - case 0: - this.customTheme = RedTheme - break - case 1: - this.customTheme = GreenTheme - break - case 2: - default: - this.customTheme = BrownTheme - break + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets index 63e87fe..3010db1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase1Page.ets @@ -11,7 +11,7 @@ struct ButtonCase1Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } @@ -19,12 +19,18 @@ struct ButtonCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '4vp' }) { + Column({ space: '3vp' }) { ForEach(this.data, (item: string) => { - Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets index 25106db..4702287 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase21Page.ets @@ -11,20 +11,26 @@ struct ButtonCase21Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } build() { Row() { Scroll() { - Column({ space: '4vp' }) { + Column({ space: '3vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) } }, (item: string) => item) } @@ -32,22 +38,24 @@ struct ButtonCase21Page { .width('100%') } .height('100%') - .onTouch(() => { - this.count++ - if (this.count > 2) { - this.count = 0 - } - switch (this.count) { - case 0: - this.customTheme = RedTheme - break - case 1: - this.customTheme = GreenTheme - break - case 2: - default: - this.customTheme = BrownTheme - break + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets index 30404fe..7a028c9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase2Page.ets @@ -11,20 +11,26 @@ struct ButtonCase2Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } build() { Row() { Scroll() { - Column({ space: '4vp' }) { + Column({ space: '3vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets index 732bfb3..9f6890c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase31Page.ets @@ -90,42 +90,50 @@ struct ButtonCase31Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '4vp' }) { + List({ space: '3vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } .width('100%') } .height('100%') - .onTouch(() => { - this.count++ - if (this.count > 2) { - this.count = 0 - } - switch (this.count) { - case 0: - this.customTheme = RedTheme - break - case 1: - this.customTheme = GreenTheme - break - case 2: - default: - this.customTheme = BrownTheme - break + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets index 1418f76..9a3c70b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase3Page.ets @@ -90,20 +90,26 @@ struct ButtonCase3Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '4vp' }) { - LazyForEach(this.data, (item: string, index: number) => { + List({ space: '3vp' }) { + LazyForEach(this.data, (item: string) => { ListItem() { - Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row() { + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets index 748ed4d..c1d8ccc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase41Page.ets @@ -90,20 +90,26 @@ struct ButtonCase41Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { Row() { - List({ space: '4vp' }) { + List({ space: '3vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row(){ + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) @@ -111,22 +117,24 @@ struct ButtonCase41Page { .width('100%') } .height('100%') - .onTouch(() => { - this.count++ - if (this.count > 2) { - this.count = 0 - } - switch (this.count) { - case 0: - this.customTheme = RedTheme - break - case 1: - this.customTheme = GreenTheme - break - case 2: - default: - this.customTheme = BrownTheme - break + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } } }) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets index 4e86ec2..6d9198f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/button/ButtonCase4Page.ets @@ -90,20 +90,26 @@ struct ButtonCase4Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { Row() { - List({ space: '4vp' }) { + List({ space: '3vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Button(item + ' index = ' + index).buttonStyle(ButtonStyleMode.EMPHASIZED) - .width('70%') - .height(36) - .margin({right:'100vp'}) + Row() { + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + Button(item).buttonStyle(ButtonStyleMode.EMPHASIZED) + .height(36) + }.margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase11Page.ets new file mode 100644 index 0000000..f7efab7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase11Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CheckboxCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets index 0a567d6..2908671 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase1Page.ets @@ -19,10 +19,22 @@ struct CheckboxCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '25vp' }) { + Column() { ForEach(this.data, (item: string) => { - Checkbox() - .select(true) + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase21Page.ets new file mode 100644 index 0000000..5d9f023 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase21Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CheckboxCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets index ce8bd57..577c8f8 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase2Page.ets @@ -18,11 +18,23 @@ struct CheckboxCase2Page { build() { Row() { Scroll() { - Column({ space: '25vp' }) { + Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Checkbox() - .select(true) + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase31Page.ets new file mode 100644 index 0000000..e468f43 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase31Page.ets @@ -0,0 +1,146 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CheckboxCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets index 9fb0174..d001339 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase3Page.ets @@ -98,11 +98,23 @@ struct CheckboxCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '25vp' }) { + List({ }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Checkbox() - .select(true) + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase41Page.ets new file mode 100644 index 0000000..6027a87 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase41Page.ets @@ -0,0 +1,145 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CheckboxCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets index a4d405b..6dc835b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxCase4Page.ets @@ -96,12 +96,24 @@ struct CheckboxCase4Page { build() { Row() { - List({ space: '25vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Checkbox() - .select(true) + Row(){ + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + Checkbox() + .select(true) + .width(30) + }.margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxNavigationPage.ets index c3c4452..926501f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/checkbox/CheckboxNavigationPage.ets @@ -26,6 +26,22 @@ struct CheckboxNavigationPage { title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Checkboxes', ability: 'CheckboxCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Checkboxes, theme changing on touch', + ability: 'CheckboxCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Checkboxes, theme changing on touch', + ability: 'CheckboxCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Checkboxes, theme changing on touch', + ability: 'CheckboxCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Checkboxes, theme changing on touch', + ability: 'CheckboxCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 620f92f..9366fe2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -851,6 +851,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CheckboxCase11Ability", + "srcEntry": "./ets/ability/checkbox/CheckboxCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CheckboxCase21Ability", + "srcEntry": "./ets/ability/checkbox/CheckboxCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CheckboxCase31Ability", + "srcEntry": "./ets/ability/checkbox/CheckboxCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CheckboxCase41Ability", + "srcEntry": "./ets/ability/checkbox/CheckboxCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 4a2c540..058584e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -33,6 +33,10 @@ "pages/tests/checkbox/CheckboxCase2Page", "pages/tests/checkbox/CheckboxCase3Page", "pages/tests/checkbox/CheckboxCase4Page", + "pages/tests/checkbox/CheckboxCase11Page", + "pages/tests/checkbox/CheckboxCase21Page", + "pages/tests/checkbox/CheckboxCase31Page", + "pages/tests/checkbox/CheckboxCase41Page", "pages/tests/checkbox/CheckboxNavigationPage", "pages/tests/progress/ProgressCase1Page", "pages/tests/progress/ProgressCase2Page", -- Gitee From c910ea240443def244355e9c149f2d188453a79e Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 6 Nov 2024 22:03:36 +0300 Subject: [PATCH 18/37] divider pages modified x4 --- .../ability/divider/DividerCase11Ability.ets | 43 +++++ .../ability/divider/DividerCase21Ability.ets | 43 +++++ .../ability/divider/DividerCase31Ability.ets | 43 +++++ .../ability/divider/DividerCase41Ability.ets | 43 +++++ .../pages/tests/divider/DividerCase11Page.ets | 74 +++++++++ .../pages/tests/divider/DividerCase1Page.ets | 27 ++- .../pages/tests/divider/DividerCase21Page.ets | 74 +++++++++ .../pages/tests/divider/DividerCase2Page.ets | 27 ++- .../pages/tests/divider/DividerCase31Page.ets | 154 ++++++++++++++++++ .../pages/tests/divider/DividerCase3Page.ets | 27 ++- .../pages/tests/divider/DividerCase41Page.ets | 153 +++++++++++++++++ .../pages/tests/divider/DividerCase4Page.ets | 27 ++- .../tests/divider/DividerNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 779 insertions(+), 24 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase11Ability.ets new file mode 100644 index 0000000..67531a5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase21Ability.ets new file mode 100644 index 0000000..8327818 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase31Ability.ets new file mode 100644 index 0000000..9c96da7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase41Ability.ets new file mode 100644 index 0000000..457ef39 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/divider/DividerCase41Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DividerCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/divider/DividerCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase11Page.ets new file mode 100644 index 0000000..56c6b1c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase11Page.ets @@ -0,0 +1,74 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DividerCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets index b486c67..27b0c8e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase1Page.ets @@ -21,11 +21,28 @@ struct DividerCase1Page { Scroll() { Column({ space: '30vp' }) { ForEach(this.data, (item: string) => { - Divider() - .strokeWidth(10) - .vertical(false) - .width('30%') - .margin({ bottom: 15 }) + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase21Page.ets new file mode 100644 index 0000000..c3aeecc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase21Page.ets @@ -0,0 +1,74 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DividerCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '30vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets index 1571220..d7b8fef 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase2Page.ets @@ -21,11 +21,28 @@ struct DividerCase2Page { Column({ space: '30vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Divider() - .strokeWidth(10) - .vertical(false) - .width('30%') - .margin({ bottom: 15 }) + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase31Page.ets new file mode 100644 index 0000000..b473334 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase31Page.ets @@ -0,0 +1,154 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DividerCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets index 9c02955..0e81c89 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase3Page.ets @@ -101,11 +101,28 @@ struct DividerCase3Page { List({ space: '30vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Divider() - .strokeWidth(10) - .vertical(false) - .width('30%') - .margin({ bottom: 15 }) + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase41Page.ets new file mode 100644 index 0000000..d9af84b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase41Page.ets @@ -0,0 +1,153 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DividerCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '30vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets index aa4826a..30495c1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerCase4Page.ets @@ -100,11 +100,28 @@ struct DividerCase4Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Divider() - .strokeWidth(10) - .vertical(false) - .width('30%') - .margin({ bottom: 15 }) + Row() { + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + Divider() + .strokeWidth(10) + .vertical(false) + .width('20%') + .margin({right:'3vp'}) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets index e52b82e..b696afa 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/divider/DividerNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct DividerNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Dividers', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Dividers', ability: 'DividerCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Dividers', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Dividers', ability: 'DividerCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Dividers', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Dividers', ability: 'DividerCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Dividers', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Dividers', ability: 'DividerCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Dividers, theme changing on touch', + ability: 'DividerCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Dividers, theme changing on touch', + ability: 'DividerCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Dividers, theme changing on touch', + ability: 'DividerCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Dividers, theme changing on touch', + ability: 'DividerCase41Ability' + } ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 9366fe2..216eae0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -891,6 +891,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Divider11Ability", + "srcEntry": "./ets/ability/divider/DividerCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase21Ability", + "srcEntry": "./ets/ability/divider/DividerCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase31Ability", + "srcEntry": "./ets/ability/divider/DividerCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DividerCase41Ability", + "srcEntry": "./ets/ability/divider/DividerCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 058584e..9b59f80 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -62,6 +62,10 @@ "pages/tests/divider/DividerCase2Page", "pages/tests/divider/DividerCase3Page", "pages/tests/divider/DividerCase4Page", + "pages/tests/divider/DividerCase11Page", + "pages/tests/divider/DividerCase21Page", + "pages/tests/divider/DividerCase31Page", + "pages/tests/divider/DividerCase41Page", "pages/tests/divider/DividerNavigationPage", "pages/tests/textClock/TextClockCase1Page", "pages/tests/textClock/TextClockCase2Page", -- Gitee From 06d78318df5d62531898f2c39e0a920cc7694539 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 6 Nov 2024 22:45:57 +0300 Subject: [PATCH 19/37] radio pages added x4 --- .../ets/ability/radio/RadioCase11Ability.ets | 43 ++++++ .../ets/ability/radio/RadioCase21Ability.ets | 43 ++++++ .../ets/ability/radio/RadioCase31Ability.ets | 43 ++++++ .../ets/ability/radio/RadioCase41Ability.ets | 44 ++++++ .../ets/pages/tests/radio/RadioCase11Page.ets | 62 ++++++++ .../ets/pages/tests/radio/RadioCase1Page.ets | 14 +- .../ets/pages/tests/radio/RadioCase21Page.ets | 62 ++++++++ .../ets/pages/tests/radio/RadioCase2Page.ets | 14 +- .../ets/pages/tests/radio/RadioCase31Page.ets | 141 ++++++++++++++++++ .../ets/pages/tests/radio/RadioCase3Page.ets | 14 +- .../ets/pages/tests/radio/RadioCase41Page.ets | 141 ++++++++++++++++++ .../ets/pages/tests/radio/RadioCase4Page.ets | 14 +- .../pages/tests/radio/RadioNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 687 insertions(+), 16 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase11Ability.ets new file mode 100644 index 0000000..e268a81 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class RadioCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/radio/RadioCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase21Ability.ets new file mode 100644 index 0000000..3772ca5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class RadioCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/radio/RadioCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase31Ability.ets new file mode 100644 index 0000000..6e27dae --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class RadioCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/radio/RadioCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase41Ability.ets new file mode 100644 index 0000000..11a11ac --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/radio/RadioCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class RadioCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/radio/RadioCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase11Page.ets new file mode 100644 index 0000000..ed72765 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase11Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct RadioCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets index 98470c9..f920749 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase1Page.ets @@ -19,10 +19,18 @@ struct RadioCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '25vp' }) { + Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { - Radio({ value: item, group: item }) - .checked(true) + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase21Page.ets new file mode 100644 index 0000000..f0880b7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase21Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct RadioCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '10vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets index 1e95214..0f124e5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase2Page.ets @@ -18,11 +18,19 @@ struct RadioCase2Page { build() { Row() { Scroll() { - Column({ space: '25vp' }) { + Column({ space: '10vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Radio({ value: item, group: item }) - .checked(true) + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase31Page.ets new file mode 100644 index 0000000..d950ab5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase31Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct RadioCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets index ac87580..e24d9a3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase3Page.ets @@ -97,11 +97,19 @@ struct RadioCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '25vp' }) { + List({ space: '10vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Radio({ value: item, group: item }) - .checked(true) + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase41Page.ets new file mode 100644 index 0000000..788f684 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase41Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct RadioCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '10vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets index 6b72110..3bcab17 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioCase4Page.ets @@ -96,12 +96,20 @@ struct RadioCase4Page { build() { Row() { - List({ space: '25vp' }) { + List({ space: '10vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Radio({ value: item, group: item }) - .checked(true) + Row() { + Radio({ value: item, group: item + 1 }) + .checked(true) + Radio({ value: item, group: item + 2 }) + .checked(true) + Radio({ value: item, group: item + 3 }) + .checked(true) + Radio({ value: item, group: item + 4 }) + .checked(true) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioNavigationPage.ets index 3e79fb3..5fd14ce 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/radio/RadioNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct RadioNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Radios', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Radios', ability: 'RadioCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Radios', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Radios', ability: 'RadioCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Radios', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Radios', ability: 'RadioCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Radios', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Radios', ability: 'RadioCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Radios, theme changing on touch', + ability: 'RadioCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Radios, theme changing on touch', + ability: 'RadioCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Radios, theme changing on touch', + ability: 'RadioCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Radios, theme changing on touch', + ability: 'RadioCase41Ability' + } ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 216eae0..8c4f4e1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -931,6 +931,46 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "RadioCase11Ability", + "srcEntry": "./ets/ability/radio/RadioCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "RadioCase21Ability", + "srcEntry": "./ets/ability/radio/RadioCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "RadioCase31Ability", + "srcEntry": "./ets/ability/radio/RadioCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "RadioCase41Ability", + "srcEntry": "./ets/ability/radio/RadioCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 9b59f80..415d42c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -52,6 +52,10 @@ "pages/tests/radio/RadioCase2Page", "pages/tests/radio/RadioCase3Page", "pages/tests/radio/RadioCase4Page", + "pages/tests/radio/RadioCase11Page", + "pages/tests/radio/RadioCase21Page", + "pages/tests/radio/RadioCase31Page", + "pages/tests/radio/RadioCase41Page", "pages/tests/radio/RadioNavigationPage", "pages/tests/swiper/SwiperCase1Page", "pages/tests/swiper/SwiperCase2Page", -- Gitee From 10383c5da0776a885c1e9e0bcd13225b47e6caa4 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 13:22:51 +0300 Subject: [PATCH 20/37] patternlock pages changed x4 --- .../PatternLock/PatternLockCase11Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase21Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase31Ability.ets | 43 ++++++ .../PatternLock/PatternLockCase41Ability.ets | 44 ++++++ .../PatternLock/PatternLockCase11Page.ets | 58 ++++++++ .../PatternLock/PatternLockCase1Page.ets | 9 +- .../PatternLock/PatternLockCase21Page.ets | 58 ++++++++ .../PatternLock/PatternLockCase2Page.ets | 9 +- .../PatternLock/PatternLockCase31Page.ets | 137 ++++++++++++++++++ .../PatternLock/PatternLockCase3Page.ets | 9 +- .../PatternLock/PatternLockCase41Page.ets | 137 ++++++++++++++++++ .../PatternLock/PatternLockCase4Page.ets | 9 +- .../PatternLock/PatternLockNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 655 insertions(+), 12 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase11Ability.ets new file mode 100644 index 0000000..10949eb --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase21Ability.ets new file mode 100644 index 0000000..5fea966 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase31Ability.ets new file mode 100644 index 0000000..0d73630 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase41Ability.ets new file mode 100644 index 0000000..6636106 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/PatternLock/PatternLockCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class PatternLockCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/PatternLock/PatternLockCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase11Page.ets new file mode 100644 index 0000000..d9f18ed --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase11Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct PatternLockCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets index 3b1bc6f..8535342 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase1Page.ets @@ -19,9 +19,14 @@ struct PatternLockCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { - PatternLock().sideLength(38) + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase21Page.ets new file mode 100644 index 0000000..1502382 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase21Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct PatternLockCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets index 59e191c..273b430 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase2Page.ets @@ -18,10 +18,15 @@ struct PatternLockCase2Page { build() { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - PatternLock().sideLength(38) + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase31Page.ets new file mode 100644 index 0000000..6414bf5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase31Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct PatternLockCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets index 6df69d4..c382138 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase3Page.ets @@ -97,10 +97,15 @@ struct PatternLockCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - PatternLock().sideLength(38) + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase41Page.ets new file mode 100644 index 0000000..f77d1df --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase41Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct PatternLockCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets index e406a58..1979099 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockCase4Page.ets @@ -96,11 +96,16 @@ struct PatternLockCase4Page { build() { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - PatternLock().sideLength(38) + Row(){ + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + PatternLock().sideLength(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets index 3bc024c..3a4a8ed 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/PatternLock/PatternLockNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct PatternLockNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs', ability: 'PatternLockCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs', ability: 'PatternLockCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs', ability: 'PatternLockCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs', ability: 'PatternLockCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs, theme changing on scroll', + ability: 'PatternLockCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs, theme changing on scroll', + ability: 'PatternLockCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs, theme changing on scroll', + ability: 'PatternLockCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs, theme changing on scroll', + ability: 'PatternLockCase41Ability' + } ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 8c4f4e1..0e36730 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -572,6 +572,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "PatternLockCase11Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase21Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase31Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "PatternLockCase41Ability", + "srcEntry": "./ets/ability/PatternLock/PatternLockCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "SelectCase1Ability", "srcEntry": "./ets/ability/select/SelectCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 415d42c..18a341c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -85,6 +85,10 @@ "pages/tests/PatternLock/PatternLockCase2Page", "pages/tests/PatternLock/PatternLockCase3Page", "pages/tests/PatternLock/PatternLockCase4Page", + "pages/tests/PatternLock/PatternLockCase11Page", + "pages/tests/PatternLock/PatternLockCase21Page", + "pages/tests/PatternLock/PatternLockCase31Page", + "pages/tests/PatternLock/PatternLockCase41Page", "pages/tests/PatternLock/PatternLockNavigationPage", "pages/tests/select/SelectCase1Page", "pages/tests/select/SelectCase2Page", -- Gitee From 5fdc4a8eb9d952bd31efdeb386d4dbfedfe37da3 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 13:48:44 +0300 Subject: [PATCH 21/37] qrcode pages modified x4 --- .../ability/QRCode/QRCodeCase11Ability.ets | 43 ++++++ .../ability/QRCode/QRCodeCase21Ability.ets | 43 ++++++ .../ability/QRCode/QRCodeCase31Ability.ets | 43 ++++++ .../ability/QRCode/QRCodeCase41Ability.ets | 44 ++++++ .../pages/tests/QRCode/QRCodeCase11Page.ets | 58 ++++++++ .../pages/tests/QRCode/QRCodeCase1Page.ets | 9 +- .../pages/tests/QRCode/QRCodeCase21Page.ets | 58 ++++++++ .../pages/tests/QRCode/QRCodeCase2Page.ets | 9 +- .../pages/tests/QRCode/QRCodeCase31Page.ets | 137 ++++++++++++++++++ .../pages/tests/QRCode/QRCodeCase3Page.ets | 9 +- .../pages/tests/QRCode/QRCodeCase41Page.ets | 137 ++++++++++++++++++ .../pages/tests/QRCode/QRCodeCase4Page.ets | 9 +- .../tests/QRCode/QRCodeNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 655 insertions(+), 12 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase11Ability.ets new file mode 100644 index 0000000..6cfe862 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase21Ability.ets new file mode 100644 index 0000000..352d725 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase31Ability.ets new file mode 100644 index 0000000..53f29af --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase41Ability.ets new file mode 100644 index 0000000..8110cbe --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/QRCode/QRCodeCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class QRCodeCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/QRCode/QRCodeCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase11Page.ets new file mode 100644 index 0000000..4d76d58 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase11Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct QRCodeCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets index f48b078..e9a3d30 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase1Page.ets @@ -19,9 +19,14 @@ struct QRCodeCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { - QRCode("hello world").width(38).height(38) + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase21Page.ets new file mode 100644 index 0000000..115140b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase21Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct QRCodeCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets index d017dc9..f6d10b1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase2Page.ets @@ -18,10 +18,15 @@ struct QRCodeCase2Page { build() { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - QRCode("hello world").width(38).height(38) + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase31Page.ets new file mode 100644 index 0000000..054a161 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase31Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct QRCodeCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets index 09c7924..11d35e2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase3Page.ets @@ -97,10 +97,15 @@ struct QRCodeCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - QRCode("hello world").width(38).height(38) + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase41Page.ets new file mode 100644 index 0000000..ecee9b7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase41Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct QRCodeCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets index e01c40a..9a8254e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeCase4Page.ets @@ -96,11 +96,16 @@ struct QRCodeCase4Page { build() { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - QRCode("hello world").width(38).height(38) + Row(){ + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + QRCode("hello world").width(35).height(35).margin({right:'10vp'}) + }.margin({right:'100vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets index 2eb9a62..8fe839c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/QRCode/QRCodeNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct QRCodeNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs', ability: 'QRCodeCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs', ability: 'QRCodeCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs', ability: 'QRCodeCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs', ability: 'QRCodeCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs, theme changing on scroll', + ability: 'QRCodeCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs, theme changing on scroll', + ability: 'QRCodeCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs, theme changing on scroll', + ability: 'QRCodeCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs, theme changing on scroll', + ability: 'QRCodeCase41Ability' + } ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 0e36730..a02c010 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -532,6 +532,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "QRCodeCase11Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase21Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase31Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "QRCodeCase41Ability", + "srcEntry": "./ets/ability/QRCode/QRCodeCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "PatternLockCase1Ability", "srcEntry": "./ets/ability/PatternLock/PatternLockCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 18a341c..c976cc5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -80,6 +80,10 @@ "pages/tests/QRCode/QRCodeCase2Page", "pages/tests/QRCode/QRCodeCase3Page", "pages/tests/QRCode/QRCodeCase4Page", + "pages/tests/QRCode/QRCodeCase11Page", + "pages/tests/QRCode/QRCodeCase21Page", + "pages/tests/QRCode/QRCodeCase31Page", + "pages/tests/QRCode/QRCodeCase41Page", "pages/tests/QRCode/QRCodeNavigationPage", "pages/tests/PatternLock/PatternLockCase1Page", "pages/tests/PatternLock/PatternLockCase2Page", -- Gitee From a7cca8131fde6dee7f31e433939e15d56b410ccb Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 21:06:52 +0300 Subject: [PATCH 22/37] DataPanel pages modified x4 --- .../DataPanel/DataPanelCase11Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase21Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase31Ability.ets | 43 ++++++ .../DataPanel/DataPanelCase41Ability.ets | 44 ++++++ .../tests/DataPanel/DataPanelCase11Page.ets | 66 ++++++++ .../tests/DataPanel/DataPanelCase1Page.ets | 15 +- .../tests/DataPanel/DataPanelCase21Page.ets | 66 ++++++++ .../tests/DataPanel/DataPanelCase2Page.ets | 13 +- .../tests/DataPanel/DataPanelCase31Page.ets | 146 ++++++++++++++++++ .../tests/DataPanel/DataPanelCase3Page.ets | 13 +- .../tests/DataPanel/DataPanelCase41Page.ets | 145 +++++++++++++++++ .../tests/DataPanel/DataPanelCase4Page.ets | 13 +- .../DataPanel/DataPanelNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 705 insertions(+), 13 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets new file mode 100644 index 0000000..310d447 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets new file mode 100644 index 0000000..e3c8acb --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets new file mode 100644 index 0000000..e77f61b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets new file mode 100644 index 0000000..f5ab061 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DataPanelCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase11Page.ets new file mode 100644 index 0000000..2983f3c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase11Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DataPanelCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets index 79d3273..a4ec40d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase1Page.ets @@ -19,13 +19,22 @@ struct DataPanelCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '15vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { Row() { DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) - .width('60%') + .width('20%') .height(35) - } + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets new file mode 100644 index 0000000..7dcccfa --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DataPanelCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets index a2b80f7..bb6ec33 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets @@ -23,9 +23,18 @@ struct DataPanelCase2Page { WithTheme({ theme: this.customTheme }) { Row() { DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) - .width('60%') + .width('20%') .height(35) - } + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets new file mode 100644 index 0000000..8052826 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets @@ -0,0 +1,146 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DataPanelCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets index d5a46cf..449efa2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets @@ -103,9 +103,18 @@ struct DataPanelCase3Page { ListItem() { Row() { DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) - .width('60%') + .width('20%') .height(35) - } + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets new file mode 100644 index 0000000..e1fd56f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets @@ -0,0 +1,145 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DataPanelCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets index 6ac1e9f..f7e834d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets @@ -102,9 +102,18 @@ struct DataPanelCase4Page { WithTheme({ theme: this.customTheme }) { Row() { DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) - .width('60%') + .width('20%') .height(35) - } + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Line }) + .width('20%') + .height(35) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets index 81034b3..0b7eca8 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct DataPanelNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 DataPanels', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 DataPanels', ability: 'DataPanelCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 DataPanels', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 DataPanels', ability: 'DataPanelCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 DataPanels', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 DataPanels', ability: 'DataPanelCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 DataPanels', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 DataPanels', ability: 'DataPanelCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 DataPanels, theme changing on scroll', + ability: 'DataPanelCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 DataPanels, theme changing on scroll', + ability: 'DataPanelCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 DataPanels, theme changing on scroll', + ability: 'DataPanelCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 DataPanels, theme changing on scroll', + ability: 'DataPanelCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index a02c010..a092625 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -852,6 +852,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "DataPanelCase11Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase21Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase31Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DataPanelCase41Ability", + "srcEntry": "./ets/ability/DataPanel/DataPanelCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "DatePickerCase1Ability", "srcEntry": "./ets/ability/DatePicker/DatePickerCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index c976cc5..ed76c04 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -118,6 +118,10 @@ "pages/tests/DataPanel/DataPanelCase2Page", "pages/tests/DataPanel/DataPanelCase3Page", "pages/tests/DataPanel/DataPanelCase4Page", + "pages/tests/DataPanel/DataPanelCase11Page", + "pages/tests/DataPanel/DataPanelCase21Page", + "pages/tests/DataPanel/DataPanelCase31Page", + "pages/tests/DataPanel/DataPanelCase41Page", "pages/tests/DataPanel/DataPanelNavigationPage", "pages/tests/DatePicker/DatePickerCase1Page", "pages/tests/DatePicker/DatePickerCase2Page", -- Gitee From 27aec21ca50081b13e39395935cfb13e30e06be8 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 21:41:22 +0300 Subject: [PATCH 23/37] DatePicker pages modified x2 --- .../DatePicker/DatePickerCase11Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase21Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase31Ability.ets | 43 ++++++ .../DatePicker/DatePickerCase41Ability.ets | 44 ++++++ .../tests/DataPanel/DataPanelCase21Page.ets | 2 +- .../tests/DataPanel/DataPanelCase2Page.ets | 2 +- .../tests/DataPanel/DataPanelCase31Page.ets | 2 +- .../tests/DataPanel/DataPanelCase3Page.ets | 2 +- .../tests/DataPanel/DataPanelCase41Page.ets | 2 +- .../tests/DataPanel/DataPanelCase4Page.ets | 2 +- .../tests/DatePicker/DatePickerCase11Page.ets | 60 ++++++++ .../tests/DatePicker/DatePickerCase1Page.ets | 12 +- .../tests/DatePicker/DatePickerCase21Page.ets | 60 ++++++++ .../tests/DatePicker/DatePickerCase2Page.ets | 12 +- .../tests/DatePicker/DatePickerCase31Page.ets | 140 ++++++++++++++++++ .../tests/DatePicker/DatePickerCase3Page.ets | 12 +- .../tests/DatePicker/DatePickerCase41Page.ets | 139 +++++++++++++++++ .../tests/DatePicker/DatePickerCase4Page.ets | 12 +- .../DatePicker/DatePickerNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 21 files changed, 674 insertions(+), 26 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets new file mode 100644 index 0000000..c11a916 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets new file mode 100644 index 0000000..8a20e1f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets new file mode 100644 index 0000000..6f2e7fe --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets new file mode 100644 index 0000000..d934eb4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class DatePickerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets index 7dcccfa..8a7090a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase21Page.ets @@ -18,7 +18,7 @@ struct DataPanelCase21Page { build() { Row() { Scroll() { - Column({ space: '15vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets index bb6ec33..981fa52 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase2Page.ets @@ -18,7 +18,7 @@ struct DataPanelCase2Page { build() { Row() { Scroll() { - Column({ space: '15vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets index 8052826..25af62d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase31Page.ets @@ -98,7 +98,7 @@ struct DataPanelCase31Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '15vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets index 449efa2..ca8afb2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase3Page.ets @@ -98,7 +98,7 @@ struct DataPanelCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '15vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets index e1fd56f..778b462 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase41Page.ets @@ -96,7 +96,7 @@ struct DataPanelCase41Page { build() { Row() { - List({ space: '15vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets index f7e834d..8d5c3ec 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DataPanel/DataPanelCase4Page.ets @@ -96,7 +96,7 @@ struct DataPanelCase4Page { build() { Row() { - List({ space: '15vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets new file mode 100644 index 0000000..8e05306 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets @@ -0,0 +1,60 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DatePickerCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '1vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + DatePicker() + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets index f149e9b..cb409af 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets @@ -19,12 +19,16 @@ struct DatePickerCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '15vp' }) { + Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { - Row() { + Row(){ DatePicker() - .width('60%') - } + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets new file mode 100644 index 0000000..0504d94 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets @@ -0,0 +1,60 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct DatePickerCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '1vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + DatePicker() + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets index 59d5745..7ba83e6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets @@ -18,13 +18,17 @@ struct DatePickerCase2Page { build() { Row() { Scroll() { - Column({ space: '15vp' }) { + Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Row() { + Row(){ DatePicker() - .width('60%') - } + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets new file mode 100644 index 0000000..a9b51b8 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets @@ -0,0 +1,140 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DatePickerCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '1vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + DatePicker() + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets index 93dc3f6..83ade20 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets @@ -98,13 +98,17 @@ struct DatePickerCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '15vp' }) { + List({ space: '1vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Row() { + Row(){ DatePicker() - .width('60%') - } + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets new file mode 100644 index 0000000..2956221 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets @@ -0,0 +1,139 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct DatePickerCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '1vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + DatePicker() + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets index 1497ef4..d8459f4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets @@ -96,14 +96,18 @@ struct DatePickerCase4Page { build() { Row() { - List({ space: '15vp' }) { + List({ space: '1vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Row() { + Row(){ DatePicker() - .width('60%') - } + .width('45%') + .height(38) + DatePicker() + .width('45%') + .height(38) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets index 12d47c6..78ef2a0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct DatePickerNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 DatePickers', + title: 'ForEach (attrs & CustomTheme for all items) List with 200 DatePickers', ability: 'DatePickerCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 DatePickers', + title: 'ForEach (attrs & CustomTheme for every item) List with 200 DatePickers', ability: 'DatePickerCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 DatePickers', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 4000 DatePickers', ability: 'DatePickerCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 DatePickers', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 4000 DatePickers', ability: 'DatePickerCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 200 DatePickers, theme changing on scroll', + ability: 'DatePickerCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 200 DatePickers, theme changing on scroll', + ability: 'DatePickerCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 4000 DatePickers, theme changing on scroll', + ability: 'DatePickerCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 4000 DatePickers, theme changing on scroll', + ability: 'DatePickerCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index a092625..c73a7a8 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -932,6 +932,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "DatePickerCase11Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase21Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase31Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "DatePickerCase41Ability", + "srcEntry": "./ets/ability/DatePicker/DatePickerCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "ButtonCase11Ability", "srcEntry": "./ets/ability/button/ButtonCase11Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index ed76c04..1d97d19 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -127,6 +127,10 @@ "pages/tests/DatePicker/DatePickerCase2Page", "pages/tests/DatePicker/DatePickerCase3Page", "pages/tests/DatePicker/DatePickerCase4Page", + "pages/tests/DatePicker/DatePickerCase11Page", + "pages/tests/DatePicker/DatePickerCase21Page", + "pages/tests/DatePicker/DatePickerCase31Page", + "pages/tests/DatePicker/DatePickerCase41Page", "pages/tests/DatePicker/DatePickerNavigationPage" ] } \ No newline at end of file -- Gitee From d10c7c1e4f79e66a602e082eda570277e7ac25b2 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 23:02:01 +0300 Subject: [PATCH 24/37] loadingProgress pages modified x4 --- .../LoadingProgressCase11Ability.ets | 43 +++++ .../LoadingProgressCase21Ability.ets | 43 +++++ .../LoadingProgressCase31Ability.ets | 43 +++++ .../LoadingProgressCase41Ability.ets | 44 +++++ .../LoadingProgressCase11Page.ets | 77 +++++++++ .../LoadingProgressCase1Page.ets | 14 +- .../LoadingProgressCase21Page.ets | 76 +++++++++ .../LoadingProgressCase2Page.ets | 14 +- .../LoadingProgressCase31Page.ets | 156 ++++++++++++++++++ .../LoadingProgressCase3Page.ets | 14 +- .../LoadingProgressCase41Page.ets | 154 +++++++++++++++++ .../LoadingProgressCase4Page.ets | 14 +- .../LoadingProgressNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 744 insertions(+), 16 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase11Ability.ets new file mode 100644 index 0000000..1cafca7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class LoadingProgressCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/loadingProgress/LoadingProgressCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase21Ability.ets new file mode 100644 index 0000000..66b234d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class LoadingProgressCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/loadingProgress/LoadingProgressCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase31Ability.ets new file mode 100644 index 0000000..19826de --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class LoadingProgressCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/loadingProgress/LoadingProgressCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase41Ability.ets new file mode 100644 index 0000000..fc820d5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/loadingProgress/LoadingProgressCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class LoadingProgressCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/loadingProgress/LoadingProgressCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase11Page.ets new file mode 100644 index 0000000..d463591 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase11Page.ets @@ -0,0 +1,77 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct LoadingProgressCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) + }, (item: string) => item) + + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets index ebec005..56659cd 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase1Page.ets @@ -33,10 +33,18 @@ struct LoadingProgressCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { - LoadingProgress() - .height(43) + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase21Page.ets new file mode 100644 index 0000000..06716f0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase21Page.ets @@ -0,0 +1,76 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct LoadingProgressCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '4vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets index 8906ca9..805ffde 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase2Page.ets @@ -32,11 +32,19 @@ struct LoadingProgressCase2Page { build() { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '4vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - LoadingProgress() - .height(43) + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase31Page.ets new file mode 100644 index 0000000..a872a0c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase31Page.ets @@ -0,0 +1,156 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct LoadingProgressCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets index 36a50f6..6bf0e16 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase3Page.ets @@ -112,11 +112,19 @@ struct LoadingProgressCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - LoadingProgress() - .height(43) + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase41Page.ets new file mode 100644 index 0000000..0217098 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase41Page.ets @@ -0,0 +1,154 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct LoadingProgressCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + build() { + Row() { + List({ space: '4vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets index 5b4a88e..da9c3aa 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressCase4Page.ets @@ -109,12 +109,20 @@ struct LoadingProgressCase4Page { } build() { Row() { - List({ space: '10vp' }) { + List({ space: '4vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - LoadingProgress() - .height(43) + Row() { + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + LoadingProgress() + .height(35) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressNavigationPage.ets index 70a6086..910d211 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/loadingProgress/LoadingProgressNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct LoadingProgressNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 LPs', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 LPs', ability: 'LoadingProgressCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 LPs', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 LPs', ability: 'LoadingProgressCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 LPs', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 LPs', ability: 'LoadingProgressCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 LPs', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 LPs', ability: 'LoadingProgressCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 LPs, theme changing on scroll', + ability: 'LoadingProgressCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 LPs, theme changing on scroll', + ability: 'LoadingProgressCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 LPs, theme changing on scroll', + ability: 'LoadingProgressCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 LPs, theme changing on scroll', + ability: 'LoadingProgressCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index c73a7a8..fe1a7d0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -332,6 +332,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "LoadingProgressCase11Ability", + "srcEntry": "./ets/ability/loadingProgress/LoadingProgressCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "LoadingProgressCase21Ability", + "srcEntry": "./ets/ability/loadingProgress/LoadingProgressCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "LoadingProgressCase31Ability", + "srcEntry": "./ets/ability/loadingProgress/LoadingProgressCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "LoadingProgressCase41Ability", + "srcEntry": "./ets/ability/loadingProgress/LoadingProgressCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "RadioCase1Ability", "srcEntry": "./ets/ability/radio/RadioCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 1d97d19..a6d7813 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -47,6 +47,10 @@ "pages/tests/loadingProgress/LoadingProgressCase2Page", "pages/tests/loadingProgress/LoadingProgressCase3Page", "pages/tests/loadingProgress/LoadingProgressCase4Page", + "pages/tests/loadingProgress/LoadingProgressCase11Page", + "pages/tests/loadingProgress/LoadingProgressCase21Page", + "pages/tests/loadingProgress/LoadingProgressCase31Page", + "pages/tests/loadingProgress/LoadingProgressCase41Page", "pages/tests/loadingProgress/LoadingProgressNavigationPage", "pages/tests/radio/RadioCase1Page", "pages/tests/radio/RadioCase2Page", -- Gitee From 61b8880b6202ff09c6a6c7da9ac32c54fddad102 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Sun, 10 Nov 2024 23:20:15 +0300 Subject: [PATCH 25/37] Progress page modified x4 --- .../progress/ProgressCase11Ability.ets | 43 +++++ .../progress/ProgressCase21Ability.ets | 43 +++++ .../progress/ProgressCase31Ability.ets | 43 +++++ .../progress/ProgressCase41Ability.ets | 44 +++++ .../tests/progress/ProgressCase11Page.ets | 92 ++++++++++ .../tests/progress/ProgressCase1Page.ets | 34 +++- .../tests/progress/ProgressCase21Page.ets | 92 ++++++++++ .../tests/progress/ProgressCase2Page.ets | 33 +++- .../tests/progress/ProgressCase31Page.ets | 172 ++++++++++++++++++ .../tests/progress/ProgressCase3Page.ets | 33 +++- .../tests/progress/ProgressCase41Page.ets | 170 +++++++++++++++++ .../tests/progress/ProgressCase4Page.ets | 33 +++- .../tests/progress/ProgressNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 ++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 871 insertions(+), 29 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase11Ability.ets new file mode 100644 index 0000000..21df23e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ProgressCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/progress/ProgressCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase21Ability.ets new file mode 100644 index 0000000..0d5a9b2 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ProgressCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/progress/ProgressCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase31Ability.ets new file mode 100644 index 0000000..052f3d6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ProgressCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/progress/ProgressCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase41Ability.ets new file mode 100644 index 0000000..28a5fd7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/progress/ProgressCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class ProgressCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/progress/ProgressCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase11Page.ets new file mode 100644 index 0000000..5aee498 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase11Page.ets @@ -0,0 +1,92 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct ProgressCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '35vp' }) { + ForEach(this.data, (item: string) => { + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets index eb8df4a..1a5cc1f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase1Page.ets @@ -33,15 +33,35 @@ struct ProgressCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '50vp' }) { + Column({ space: '35vp' }) { ForEach(this.data, (item: string) => { - Progress({ - value: this.progress, - total: 100, - type: ProgressType.Linear - }) + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) }, (item: string) => item) - } } .width('100%') diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase21Page.ets new file mode 100644 index 0000000..2405e96 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase21Page.ets @@ -0,0 +1,92 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct ProgressCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '35vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets index 7ab06da..d07ca3e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase2Page.ets @@ -32,14 +32,35 @@ struct ProgressCase2Page { build() { Row() { Scroll() { - Column({ space: '50vp' }) { + Column({ space: '35vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Progress({ - value: this.progress, - total: 100, - type: ProgressType.Linear - }) + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase31Page.ets new file mode 100644 index 0000000..826c213 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase31Page.ets @@ -0,0 +1,172 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct ProgressCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '35vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets index d4d449b..1e498a3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase3Page.ets @@ -112,14 +112,35 @@ struct ProgressCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '50vp' }) { + List({ space: '35vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Progress({ - value: this.progress, - total: 100, - type: ProgressType.Linear - }) + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase41Page.ets new file mode 100644 index 0000000..fdc9bf7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase41Page.ets @@ -0,0 +1,170 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct ProgressCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + @State progress: number = 0 + fdTimer = -1 + increaseValue = 100 + duration = 2000 + + onPageShow() { + this.fdTimer = setInterval(() => { + this.progress += this.increaseValue; + if (this.progress >= 100 || this.progress <= 0) { + this.increaseValue = -this.increaseValue + } + }, this.duration, Number.MAX_VALUE) + } + build() { + Row() { + List({ space: '35vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets index c2877a9..375d116 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressCase4Page.ets @@ -109,15 +109,36 @@ struct ProgressCase4Page { } build() { Row() { - List({ space: '50vp' }) { + List({ space: '35vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Progress({ - value: this.progress, - total: 100, - type: ProgressType.Linear - }) + Row() { + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + Progress({ + value: this.progress, + total: 100, + type: ProgressType.Linear + }).width('20%') + .margin({right:'2vp'}) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressNavigationPage.ets index f3b7e5e..a84832b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/progress/ProgressNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct ProgressNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Progresses', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Progresses', ability: 'ProgressCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Progresses', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Progresses', ability: 'ProgressCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Progresses', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Progresses', ability: 'ProgressCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Progresses', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Progresses', ability: 'ProgressCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Progresses, theme changing on scroll', + ability: 'ProgressCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Progresses, theme changing on scroll', + ability: 'ProgressCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Progresses, theme changing on scroll', + ability: 'ProgressCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Progresses, theme changing on scroll', + ability: 'ProgressCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index fe1a7d0..0507d38 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -292,6 +292,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "ProgressCase11Ability", + "srcEntry": "./ets/ability/progress/ProgressCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ProgressCase21Ability", + "srcEntry": "./ets/ability/progress/ProgressCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ProgressCase31Ability", + "srcEntry": "./ets/ability/progress/ProgressCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "ProgressCase41Ability", + "srcEntry": "./ets/ability/progress/ProgressCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "LoadingProgressCase1Ability", "srcEntry": "./ets/ability/loadingProgress/LoadingProgressCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index a6d7813..1fe8651 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -42,6 +42,10 @@ "pages/tests/progress/ProgressCase2Page", "pages/tests/progress/ProgressCase3Page", "pages/tests/progress/ProgressCase4Page", + "pages/tests/progress/ProgressCase11Page", + "pages/tests/progress/ProgressCase21Page", + "pages/tests/progress/ProgressCase31Page", + "pages/tests/progress/ProgressCase41Page", "pages/tests/progress/ProgressNavigationPage", "pages/tests/loadingProgress/LoadingProgressCase1Page", "pages/tests/loadingProgress/LoadingProgressCase2Page", -- Gitee From ab17e74cc4b9b58b37174e262829c401a8d28cad Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 13 Nov 2024 20:44:53 +0300 Subject: [PATCH 26/37] select page modified x4 --- .../ability/select/SelectCase11Ability.ets | 43 +++++ .../ability/select/SelectCase21Ability.ets | 43 +++++ .../ability/select/SelectCase31Ability.ets | 43 +++++ .../ability/select/SelectCase41Ability.ets | 44 +++++ .../pages/tests/select/SelectCase11Page.ets | 78 +++++++++ .../pages/tests/select/SelectCase1Page.ets | 36 +++- .../pages/tests/select/SelectCase21Page.ets | 78 +++++++++ .../pages/tests/select/SelectCase2Page.ets | 36 +++- .../pages/tests/select/SelectCase31Page.ets | 157 ++++++++++++++++++ .../pages/tests/select/SelectCase3Page.ets | 36 +++- .../pages/tests/select/SelectCase41Page.ets | 157 ++++++++++++++++++ .../pages/tests/select/SelectCase4Page.ets | 36 +++- .../tests/select/SelectNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 42 ++++- .../resources/base/profile/main_pages.json | 4 + 15 files changed, 820 insertions(+), 37 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase11Ability.ets new file mode 100644 index 0000000..01f2cd6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase21Ability.ets new file mode 100644 index 0000000..a135ae0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase31Ability.ets new file mode 100644 index 0000000..2c39d64 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase41Ability.ets new file mode 100644 index 0000000..b5c5656 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/select/SelectCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SelectCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/select/SelectCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets new file mode 100644 index 0000000..afeb47c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets @@ -0,0 +1,78 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SelectCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('#' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets index 7f620d9..7de9793 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets @@ -11,7 +11,7 @@ struct SelectCase1Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } @@ -19,14 +19,34 @@ struct SelectCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '30vp' }) { + Column() { ForEach(this.data, (item: string) => { - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value('SELECT ' + item) + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets new file mode 100644 index 0000000..ed90e6f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets @@ -0,0 +1,78 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SelectCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('#' + i) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets index e1d5c3d..45e886c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets @@ -11,22 +11,42 @@ struct SelectCase2Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push('#' + i) } } build() { Row() { Scroll() { - Column({ space: '30vp' }) { + Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value('SELECT ' + item) + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets new file mode 100644 index 0000000..922bd1b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets @@ -0,0 +1,157 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SelectCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('#' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets index 2051499..05556fb 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets @@ -90,22 +90,42 @@ struct SelectCase3Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '30vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value('SELECT ' + item) + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets new file mode 100644 index 0000000..6135e69 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets @@ -0,0 +1,157 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SelectCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('#' + i) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets index 01aa27b..6209b0c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets @@ -90,22 +90,42 @@ struct SelectCase4Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData('#' + i) } } build() { Row() { - List({ space: '30vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value('SELECT ' + item) + Row(){ + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("1") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("2") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("3") + Select([{value:'aaa'}, + {value:'bbb'}, + {value:'ccc'}, + {value:'ddd'}]) + .selected(2) + .value("4") + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets index 3c04993..daaca3a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct SelectNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Selects', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Selects', ability: 'SelectCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Selects', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Selects', ability: 'SelectCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Selects', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Selects', ability: 'SelectCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Selects', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Selects', ability: 'SelectCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Selects, theme changing on scroll', + ability: 'SelectCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Selects, theme changing on scroll', + ability: 'SelectCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Selects, theme changing on scroll', + ability: 'SelectCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Selects, theme changing on scroll', + ability: 'SelectCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 0507d38..7a5daa6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -772,6 +772,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "SelectCase11Ability", + "srcEntry": "./ets/ability/select/SelectCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase21Ability", + "srcEntry": "./ets/ability/select/SelectCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase31Ability", + "srcEntry": "./ets/ability/select/SelectCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SelectCase41Ability", + "srcEntry": "./ets/ability/select/SelectCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "AlphabetIndexerCase1Ability", "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase1Ability.ets", @@ -1133,7 +1173,7 @@ "startWindowBackground": "$color:start_window_background" }, { - "name": "Divider11Ability", + "name": "DividerCase11Ability", "srcEntry": "./ets/ability/divider/DividerCase11Ability.ets", "description": "$string:Demo1Case1Ability_desc", "icon": "$media:icon", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 1fe8651..d8befff 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -106,6 +106,10 @@ "pages/tests/select/SelectCase2Page", "pages/tests/select/SelectCase3Page", "pages/tests/select/SelectCase4Page", + "pages/tests/select/SelectCase11Page", + "pages/tests/select/SelectCase21Page", + "pages/tests/select/SelectCase31Page", + "pages/tests/select/SelectCase41Page", "pages/tests/select/SelectNavigationPage", "pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page", "pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page", -- Gitee From f0086d2f0ff5dcaae53806aa8dc98631abda9a2d Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 13 Nov 2024 21:45:30 +0300 Subject: [PATCH 27/37] slider pages modified x4 --- .../ability/slider/SliderCase11Ability.ets | 43 ++++++ .../ability/slider/SliderCase21Ability.ets | 43 ++++++ .../ability/slider/SliderCase31Ability.ets | 43 ++++++ .../ability/slider/SliderCase41Ability.ets | 44 ++++++ .../pages/tests/slider/SliderCase11Page.ets | 66 ++++++++ .../pages/tests/slider/SliderCase1Page.ets | 19 ++- .../pages/tests/slider/SliderCase21Page.ets | 66 ++++++++ .../pages/tests/slider/SliderCase2Page.ets | 19 ++- .../pages/tests/slider/SliderCase31Page.ets | 145 ++++++++++++++++++ .../pages/tests/slider/SliderCase3Page.ets | 19 ++- .../pages/tests/slider/SliderCase41Page.ets | 145 ++++++++++++++++++ .../pages/tests/slider/SliderCase4Page.ets | 19 ++- .../tests/slider/SliderNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 719 insertions(+), 20 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase11Ability.ets new file mode 100644 index 0000000..562ad66 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase21Ability.ets new file mode 100644 index 0000000..30882e7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase31Ability.ets new file mode 100644 index 0000000..fc8a8e6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase41Ability.ets new file mode 100644 index 0000000..c5da287 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/slider/SliderCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SliderCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/slider/SliderCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets new file mode 100644 index 0000000..2ab006c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SliderCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets index c486a2f..87a45b5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets @@ -19,11 +19,22 @@ struct SliderCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '13vp' }) { + Column() { ForEach(this.data, (item: string) => { - Slider() - .width('60%') - .trackThickness(10) + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets new file mode 100644 index 0000000..18fcaca --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets @@ -0,0 +1,66 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SliderCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets index 5a99660..b2f38e4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets @@ -18,12 +18,23 @@ struct SliderCase2Page { build() { Row() { Scroll() { - Column({ space: '13vp' }) { + Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Slider() - .width('60%') - .trackThickness(10) + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets new file mode 100644 index 0000000..b44e82d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets @@ -0,0 +1,145 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SliderCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets index 6ba8ae5..2baeeb1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets @@ -97,12 +97,23 @@ struct SliderCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '13vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Slider() - .width('60%') - .trackThickness(10) + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets new file mode 100644 index 0000000..ad40613 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets @@ -0,0 +1,145 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SliderCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets index de48590..a0f8e42 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets @@ -96,13 +96,24 @@ struct SliderCase4Page { build() { Row() { - List({ space: '13vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Slider() - .width('60%') - .trackThickness(10) + Row(){ + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + Slider() + .width('22%') + .trackThickness(4) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets index 690ecee..a6294f4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct SliderNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Texts', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Sliders', ability: 'SliderCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Texts', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Sliders', ability: 'SliderCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Texts', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Sliders', ability: 'SliderCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Sliders', ability: 'SliderCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Sliders, theme changing on scroll', + ability: 'SliderCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Sliders, theme changing on scroll', + ability: 'SliderCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Sliders, theme changing on scroll', + ability: 'SliderCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Sliders, theme changing on scroll', + ability: 'SliderCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 7a5daa6..88c1721 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -892,6 +892,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "SliderCase11Ability", + "srcEntry": "./ets/ability/slider/SliderCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase21Ability", + "srcEntry": "./ets/ability/slider/SliderCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase31Ability", + "srcEntry": "./ets/ability/slider/SliderCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SliderCase41Ability", + "srcEntry": "./ets/ability/slider/SliderCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "TextPickerCase1Ability", "srcEntry": "./ets/ability/textPicker/TextPickerCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index d8befff..1a8e5b5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -120,6 +120,10 @@ "pages/tests/slider/SliderCase2Page", "pages/tests/slider/SliderCase3Page", "pages/tests/slider/SliderCase4Page", + "pages/tests/slider/SliderCase11Page", + "pages/tests/slider/SliderCase21Page", + "pages/tests/slider/SliderCase31Page", + "pages/tests/slider/SliderCase41Page", "pages/tests/slider/SliderNavigationPage", "pages/tests/textPicker/TextPickerCase1Page", "pages/tests/textPicker/TextPickerCase2Page", -- Gitee From bb01460a0ea8f37320f0bae6de55c4b8cb79ba3b Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 13 Nov 2024 22:12:26 +0300 Subject: [PATCH 28/37] swiper pages modified x4 --- .../ability/swiper/SwiperCase11Ability.ets | 43 ++++ .../ability/swiper/SwiperCase21Ability.ets | 43 ++++ .../ability/swiper/SwiperCase31Ability.ets | 43 ++++ .../ability/swiper/SwiperCase41Ability.ets | 44 ++++ .../pages/tests/swiper/SwiperCase11Page.ets | 159 ++++++++++++ .../pages/tests/swiper/SwiperCase1Page.ets | 132 ++++++++-- .../pages/tests/swiper/SwiperCase21Page.ets | 159 ++++++++++++ .../pages/tests/swiper/SwiperCase2Page.ets | 132 ++++++++-- .../pages/tests/swiper/SwiperCase31Page.ets | 238 ++++++++++++++++++ .../pages/tests/swiper/SwiperCase3Page.ets | 132 ++++++++-- .../pages/tests/swiper/SwiperCase41Page.ets | 238 ++++++++++++++++++ .../pages/tests/swiper/SwiperCase4Page.ets | 132 ++++++++-- .../tests/swiper/SwiperNavigationPage.ets | 24 +- .../entry/src/main/module.json5 | 40 +++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 1455 insertions(+), 108 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase11Ability.ets new file mode 100644 index 0000000..596fa36 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SwiperCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/swiper/SwiperCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase21Ability.ets new file mode 100644 index 0000000..15873e4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SwiperCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/swiper/SwiperCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase31Ability.ets new file mode 100644 index 0000000..87d60b0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SwiperCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/swiper/SwiperCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase41Ability.ets new file mode 100644 index 0000000..9e2fa43 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/swiper/SwiperCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class SwiperCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/swiper/SwiperCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase11Page.ets new file mode 100644 index 0000000..4bd7191 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase11Page.ets @@ -0,0 +1,159 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SwiperCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + dotIndicator: DotIndicator = new DotIndicator() + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets index c0552d7..485291d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase1Page.ets @@ -22,32 +22,112 @@ struct SwiperCase1Page { Scroll() { Column() { ForEach(this.data, (item: string) => { - Swiper() { - Text(item + '-1') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + '-2') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + '-3') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - } - .margin({ bottom: 20 }) - .autoPlay(true) - .interval(4000) - .loop(true) - .vertical(true) - .duration(1000) - .indicator(this.dotIndicator - .itemWidth(3) - .itemHeight(3)) + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase21Page.ets new file mode 100644 index 0000000..73bdd10 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase21Page.ets @@ -0,0 +1,159 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct SwiperCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + dotIndicator: DotIndicator = new DotIndicator() + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets index e7ab266..4eb7c75 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase2Page.ets @@ -22,32 +22,112 @@ struct SwiperCase2Page { Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Swiper() { - Text(item + '-1') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + '-2') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + '-3') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - } - .margin({ bottom: 20 }) - .autoPlay(true) - .interval(4000) - .loop(true) - .vertical(true) - .duration(1000) - .indicator(this.dotIndicator - .itemWidth(3) - .itemHeight(3)) + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase31Page.ets new file mode 100644 index 0000000..b2b629f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase31Page.ets @@ -0,0 +1,238 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SwiperCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + dotIndicator: DotIndicator = new DotIndicator() + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets index 9570f55..ea435e0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase3Page.ets @@ -101,32 +101,112 @@ struct SwiperCase3Page { List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Swiper() { - Text(item + ' index = ' + index + '-1') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + ' index = ' + index + '-2') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + ' index = ' + index + '-3') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - } - .margin({ bottom: 20 }) - .autoPlay(true) - .interval(4000) - .loop(true) - .vertical(true) - .duration(1000) - .indicator(this.dotIndicator - .itemWidth(3) - .itemHeight(3)) + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase41Page.ets new file mode 100644 index 0000000..83bbde8 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase41Page.ets @@ -0,0 +1,238 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct SwiperCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource() + dotIndicator: DotIndicator = new DotIndicator() + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets index e9ab535..bc00ed4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperCase4Page.ets @@ -101,32 +101,112 @@ struct SwiperCase4Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Swiper() { - Text(item + ' index = ' + index + '-1') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + ' index = ' + index + '-2') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - Text(item + ' index = ' + index + '-3') - .width('30%') - .height(35) - .textAlign(TextAlign.Center) - .fontSize(10) - } - .margin({ bottom: 20 }) - .autoPlay(true) - .interval(4000) - .loop(true) - .vertical(true) - .duration(1000) - .indicator(this.dotIndicator - .itemWidth(3) - .itemHeight(3)) + Row() { + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + Swiper() { + Text(item + '-1') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-2') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + Text(item + '-3') + .width('20%') + .height(30) + .textAlign(TextAlign.Center) + .fontSize(10) + } + .margin({ bottom: 10 }) + .autoPlay(true) + .interval(4000) + .loop(true) + .vertical(true) + .duration(1000) + .indicator(this.dotIndicator + .itemWidth(3) + .itemHeight(3)) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperNavigationPage.ets index 5f4bf7a..af651ad 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/swiper/SwiperNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct SwiperNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Swipers', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Swipers', ability: 'SwiperCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Swipers', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Swipers', ability: 'SwiperCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Swipers', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Swipers', ability: 'SwiperCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Swipers', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Swipers', ability: 'SwiperCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Swipers, theme changing on scroll', + ability: 'SwiperCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Swipers, theme changing on scroll', + ability: 'SwiperCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Swipers, theme changing on scroll', + ability: 'SwiperCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Swipers, theme changing on scroll', + ability: 'SwiperCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 88c1721..59948e9 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -492,6 +492,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "SwiperCase11Ability", + "srcEntry": "./ets/ability/swiper/SwiperCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SwiperCase21Ability", + "srcEntry": "./ets/ability/swiper/SwiperCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SwiperCase31Ability", + "srcEntry": "./ets/ability/swiper/SwiperCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "SwiperCase41Ability", + "srcEntry": "./ets/ability/swiper/SwiperCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "DividerCase1Ability", "srcEntry": "./ets/ability/divider/DividerCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 1a8e5b5..37c4fee 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -69,6 +69,10 @@ "pages/tests/swiper/SwiperCase2Page", "pages/tests/swiper/SwiperCase3Page", "pages/tests/swiper/SwiperCase4Page", + "pages/tests/swiper/SwiperCase11Page", + "pages/tests/swiper/SwiperCase21Page", + "pages/tests/swiper/SwiperCase31Page", + "pages/tests/swiper/SwiperCase41Page", "pages/tests/swiper/SwiperNavigationPage", "pages/tests/divider/DividerCase1Page", "pages/tests/divider/DividerCase2Page", -- Gitee From 494fac7a0078d085174553e8bba7ff6c7f24b0c9 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Wed, 13 Nov 2024 23:12:40 +0300 Subject: [PATCH 29/37] text pages modified x4 --- .../ets/ability/text/TextCase11Ability.ets | 43 ++++++ .../ets/ability/text/TextCase21Ability.ets | 43 ++++++ .../ets/ability/text/TextCase31Ability.ets | 43 ++++++ .../ets/ability/text/TextCase41Ability.ets | 44 ++++++ .../ets/pages/tests/text/TextCase11Page.ets | 58 ++++++++ .../ets/pages/tests/text/TextCase1Page.ets | 9 +- .../ets/pages/tests/text/TextCase21Page.ets | 58 ++++++++ .../ets/pages/tests/text/TextCase2Page.ets | 9 +- .../ets/pages/tests/text/TextCase31Page.ets | 137 ++++++++++++++++++ .../ets/pages/tests/text/TextCase3Page.ets | 9 +- .../ets/pages/tests/text/TextCase41Page.ets | 137 ++++++++++++++++++ .../ets/pages/tests/text/TextCase4Page.ets | 9 +- .../pages/tests/text/TextNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 655 insertions(+), 12 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase11Ability.ets new file mode 100644 index 0000000..eca86d7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/text/TextCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase21Ability.ets new file mode 100644 index 0000000..e1ac935 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/text/TextCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase31Ability.ets new file mode 100644 index 0000000..cd534d9 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/text/TextCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase41Ability.ets new file mode 100644 index 0000000..0275278 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/text/TextCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/text/TextCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase11Page.ets new file mode 100644 index 0000000..3f7089f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase11Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets index 87293c0..77f9e5b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase1Page.ets @@ -19,9 +19,14 @@ struct TextCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '30vp' }) { + Column({ space: '20vp' }) { ForEach(this.data, (item: string) => { - Text(item) + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase21Page.ets new file mode 100644 index 0000000..20e2b53 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase21Page.ets @@ -0,0 +1,58 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets index b3e3c00..19a8f3f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase2Page.ets @@ -18,10 +18,15 @@ struct TextCase2Page { build() { Row() { Scroll() { - Column({ space: '30vp' }) { + Column({ space: '20vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Text(item) + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase31Page.ets new file mode 100644 index 0000000..81ba9c6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase31Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets index 2a3bc44..13daa5f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase3Page.ets @@ -97,10 +97,15 @@ struct TextCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '30vp' }) { + List({ space: '20vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Text(item + ' index = ' + index) + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase41Page.ets new file mode 100644 index 0000000..abda302 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase41Page.ets @@ -0,0 +1,137 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets index 917df46..abc4944 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextCase4Page.ets @@ -96,11 +96,16 @@ struct TextCase4Page { build() { Row() { - List({ space: '30vp' }) { + List({ space: '20vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Text(item + ' index = ' + index) + Row(){ + Text(item) + Text(item) + Text(item) + Text(item) + }.margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextNavigationPage.ets index 7741dd2..8f4cc10 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/text/TextNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct TextNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 Texts', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Texts', ability: 'TextCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 Texts', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Texts', ability: 'TextCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Texts', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Texts', ability: 'TextCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Texts', ability: 'TextCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 Texts, theme changing on scroll', + ability: 'TextCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 Texts, theme changing on scroll', + ability: 'TextCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 Texts, theme changing on scroll', + ability: 'TextCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 Texts, theme changing on scroll', + ability: 'TextCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 59948e9..02192ab 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -172,6 +172,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "TextCase11Ability", + "srcEntry": "./ets/ability/text/TextCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextCase21Ability", + "srcEntry": "./ets/ability/text/TextCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextCase31Ability", + "srcEntry": "./ets/ability/text/TextCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextCase41Ability", + "srcEntry": "./ets/ability/text/TextCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "TextInputCase1Ability", "srcEntry": "./ets/ability/textInput/TextInputCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 37c4fee..d000c8b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -23,6 +23,10 @@ "pages/tests/text/TextCase2Page", "pages/tests/text/TextCase3Page", "pages/tests/text/TextCase4Page", + "pages/tests/text/TextCase11Page", + "pages/tests/text/TextCase21Page", + "pages/tests/text/TextCase31Page", + "pages/tests/text/TextCase41Page", "pages/tests/text/TextNavigationPage", "pages/tests/textInput/TextInputCase1Page", "pages/tests/textInput/TextInputCase2Page", -- Gitee From dd8efee227a2bf71fdf739f6dc880c4f8cb40430 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Thu, 14 Nov 2024 11:47:36 +0300 Subject: [PATCH 30/37] textclock page modified x3 --- .../textClock/TextClockCase11Ability.ets | 43 ++++++ .../textClock/TextClockCase21Ability.ets | 43 ++++++ .../textClock/TextClockCase31Ability.ets | 43 ++++++ .../textClock/TextClockCase41Ability.ets | 44 ++++++ .../tests/DatePicker/DatePickerCase11Page.ets | 11 +- .../tests/DatePicker/DatePickerCase1Page.ets | 11 +- .../tests/DatePicker/DatePickerCase21Page.ets | 11 +- .../tests/DatePicker/DatePickerCase2Page.ets | 11 +- .../tests/DatePicker/DatePickerCase31Page.ets | 11 +- .../tests/DatePicker/DatePickerCase3Page.ets | 11 +- .../tests/DatePicker/DatePickerCase41Page.ets | 11 +- .../tests/DatePicker/DatePickerCase4Page.ets | 11 +- .../tests/textClock/TextClockCase11Page.ets | 60 ++++++++ .../tests/textClock/TextClockCase1Page.ets | 13 +- .../tests/textClock/TextClockCase21Page.ets | 60 ++++++++ .../tests/textClock/TextClockCase2Page.ets | 13 +- .../tests/textClock/TextClockCase31Page.ets | 139 ++++++++++++++++++ .../tests/textClock/TextClockCase3Page.ets | 13 +- .../tests/textClock/TextClockCase41Page.ets | 139 ++++++++++++++++++ .../tests/textClock/TextClockCase4Page.ets | 13 +- .../textClock/TextClockNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 23 files changed, 695 insertions(+), 84 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase11Ability.ets new file mode 100644 index 0000000..7fd0205 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase21Ability.ets new file mode 100644 index 0000000..5280354 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase31Ability.ets new file mode 100644 index 0000000..96d5acd --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase41Ability.ets new file mode 100644 index 0000000..5a0b191 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textClock/TextClockCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextClockCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textClock/TextClockCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets index 8e05306..e555919 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets @@ -21,14 +21,9 @@ struct DatePickerCase11Page { Scroll() { Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets index cb409af..d586473 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets @@ -21,14 +21,9 @@ struct DatePickerCase1Page { Scroll() { Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets index 0504d94..0e1f15e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets @@ -21,14 +21,9 @@ struct DatePickerCase21Page { Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets index 7ba83e6..a8cd896 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets @@ -21,14 +21,9 @@ struct DatePickerCase2Page { Column({ space: '1vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets index a9b51b8..0b8671d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets @@ -101,14 +101,9 @@ struct DatePickerCase31Page { List({ space: '1vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets index 83ade20..b95cb77 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets @@ -101,14 +101,9 @@ struct DatePickerCase3Page { List({ space: '1vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets index 2956221..63806b6 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets @@ -100,14 +100,9 @@ struct DatePickerCase41Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets index d8459f4..acc5c15 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets @@ -100,14 +100,9 @@ struct DatePickerCase4Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - Row(){ - DatePicker() - .width('45%') - .height(38) - DatePicker() - .width('45%') - .height(38) - }.margin({right:'50vp'}) + DatePicker() + .height(38) + .width('80%') } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase11Page.ets new file mode 100644 index 0000000..acb69b6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase11Page.ets @@ -0,0 +1,60 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets index fe54538..df97389 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase1Page.ets @@ -19,11 +19,16 @@ struct TextClockCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '20vp' }) { ForEach(this.data, (item: string) => { - TextClock() - .width('30%') - .margin({ bottom: 20 }) + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase21Page.ets new file mode 100644 index 0000000..8c6c38d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase21Page.ets @@ -0,0 +1,60 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextClockCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets index 83723c1..7e61f9f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase2Page.ets @@ -18,12 +18,17 @@ struct TextClockCase2Page { build() { Row() { Scroll() { - Column({ space: '10vp' }) { + Column({ space: '20vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - TextClock() - .width('30%') - .margin({ bottom: 20 }) + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase31Page.ets new file mode 100644 index 0000000..5b8e529 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase31Page.ets @@ -0,0 +1,139 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets index dae8f0d..42a14b2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase3Page.ets @@ -97,12 +97,17 @@ struct TextClockCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '10vp' }) { + List({ space: '20vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - TextClock() - .width('30%') - .margin({ bottom: 20 }) + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase41Page.ets new file mode 100644 index 0000000..157c0a0 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase41Page.ets @@ -0,0 +1,139 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextClockCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets index 17bc38f..e203aca 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockCase4Page.ets @@ -96,13 +96,18 @@ struct TextClockCase4Page { build() { Row() { - List({ space: '10vp' }) { + List({ space: '20vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - TextClock() - .width('30%') - .margin({ bottom: 20 }) + Row() { + TextClock() + .width('30%') + TextClock() + .width('30%') + TextClock() + .width('30%') + }.margin({right:'20vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets index 1d8ff83..1cfd5f3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textClock/TextClockNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct TextClockNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 TClocks', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TClocks', ability: 'TextClockCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 TClocks', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TClocks', ability: 'TextClockCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TClocks', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TClocks', ability: 'TextClockCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TClocks', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TClocks', ability: 'TextClockCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TClocks, theme changing on scroll', + ability: 'TextClockCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TClocks, theme changing on scroll', + ability: 'TextClockCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TClocks, theme changing on scroll', + ability: 'TextClockCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TClocks, theme changing on scroll', + ability: 'TextClockCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 02192ab..f91cb7a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -652,6 +652,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "TextClockCase11Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase21Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase31Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextClockCase41Ability", + "srcEntry": "./ets/ability/textClock/TextClockCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "QRCodeCase1Ability", "srcEntry": "./ets/ability/QRCode/QRCodeCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index d000c8b..81e253e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -91,6 +91,10 @@ "pages/tests/textClock/TextClockCase2Page", "pages/tests/textClock/TextClockCase3Page", "pages/tests/textClock/TextClockCase4Page", + "pages/tests/textClock/TextClockCase11Page", + "pages/tests/textClock/TextClockCase21Page", + "pages/tests/textClock/TextClockCase31Page", + "pages/tests/textClock/TextClockCase41Page", "pages/tests/textClock/TextClockNavigationPage", "pages/tests/QRCode/QRCodeCase1Page", "pages/tests/QRCode/QRCodeCase2Page", -- Gitee From 72c82f683249ae358242098edf54757a71edae34 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Thu, 14 Nov 2024 12:17:04 +0300 Subject: [PATCH 31/37] textInput pages modified x4 --- .../textInput/TextInputCase11Ability.ets | 43 ++++++ .../textInput/TextInputCase21Ability.ets | 43 ++++++ .../textInput/TextInputCase31Ability.ets | 43 ++++++ .../textInput/TextInputCase41Ability.ets | 44 ++++++ .../tests/textInput/TextInputCase11Page.ets | 62 ++++++++ .../tests/textInput/TextInputCase1Page.ets | 16 +- .../tests/textInput/TextInputCase21Page.ets | 62 ++++++++ .../tests/textInput/TextInputCase2Page.ets | 16 +- .../tests/textInput/TextInputCase31Page.ets | 141 ++++++++++++++++++ .../tests/textInput/TextInputCase3Page.ets | 16 +- .../tests/textInput/TextInputCase41Page.ets | 141 ++++++++++++++++++ .../tests/textInput/TextInputCase4Page.ets | 16 +- .../textInput/TextInputNavigationPage.ets | 24 ++- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 691 insertions(+), 20 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase11Ability.ets new file mode 100644 index 0000000..633ea87 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextInputCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textInput/TextInputCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase21Ability.ets new file mode 100644 index 0000000..87091dc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextInputCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textInput/TextInputCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase31Ability.ets new file mode 100644 index 0000000..719d306 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextInputCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textInput/TextInputCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase41Ability.ets new file mode 100644 index 0000000..e1d1b5a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textInput/TextInputCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextInputCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textInput/TextInputCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase11Page.ets new file mode 100644 index 0000000..8a1f06c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase11Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextInputCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push(String(i)) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets index ff3a049..8a909b3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase1Page.ets @@ -11,7 +11,7 @@ struct TextInputCase1Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push(String(i)) } } @@ -19,10 +19,18 @@ struct TextInputCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '10vp' }) { + Column() { ForEach(this.data, (item: string) => { - TextInput({ placeholder: item }) - .width('30%') + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase21Page.ets new file mode 100644 index 0000000..b147a3f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase21Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextInputCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push(String(i)) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets index 08732b7..ab32e5e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase2Page.ets @@ -11,18 +11,26 @@ struct TextInputCase2Page { aboutToAppear() { for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) + this.data.push(String(i)) } } build() { Row() { Scroll() { - Column({ space: '10vp' }) { + Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - TextInput({ placeholder: item }) - .width('30%') + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase31Page.ets new file mode 100644 index 0000000..74f547a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase31Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextInputCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData(String(i)) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets index 4d252b6..7ea2c7d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase3Page.ets @@ -90,18 +90,26 @@ struct TextInputCase3Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData(String(i)) } } build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '10vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - TextInput({ placeholder: item + ' index = ' + index }) - .width('30%') + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase41Page.ets new file mode 100644 index 0000000..6e968ae --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase41Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextInputCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData(String(i)) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets index 48b5440..076ce9b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputCase4Page.ets @@ -90,18 +90,26 @@ struct TextInputCase4Page { aboutToAppear() { for (let i = 0; i < 2000; i++) { - this.data.pushData('Item #' + i) + this.data.pushData(String(i)) } } build() { Row() { - List({ space: '10vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - TextInput({ placeholder: item + ' index = ' + index }) - .width('30%') + Row() { + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + TextInput({ placeholder: item }) + .width('22%') + }.margin({right:'30vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputNavigationPage.ets index e0bd997..58f0a0f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textInput/TextInputNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct TextInputNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs', ability: 'TextInputCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 TIs', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs', ability: 'TextInputCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs', ability: 'TextInputCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 TIs', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs', ability: 'TextInputCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 TIs, theme changing on scroll', + ability: 'TextInputCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 TIs, theme changing on scroll', + ability: 'TextInputCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 TIs, theme changing on scroll', + ability: 'TextInputCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 TIs, theme changing on scroll', + ability: 'TextInputCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index f91cb7a..28bac44 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -252,6 +252,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "TextInputCase11Ability", + "srcEntry": "./ets/ability/textInput/TextInputCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextInputCase21Ability", + "srcEntry": "./ets/ability/textInput/TextInputCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextInputCase31Ability", + "srcEntry": "./ets/ability/textInput/TextInputCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextInputCase41Ability", + "srcEntry": "./ets/ability/textInput/TextInputCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "CheckboxCase1Ability", "srcEntry": "./ets/ability/checkbox/CheckboxCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 81e253e..317e272 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -32,6 +32,10 @@ "pages/tests/textInput/TextInputCase2Page", "pages/tests/textInput/TextInputCase3Page", "pages/tests/textInput/TextInputCase4Page", + "pages/tests/textInput/TextInputCase11Page", + "pages/tests/textInput/TextInputCase21Page", + "pages/tests/textInput/TextInputCase31Page", + "pages/tests/textInput/TextInputCase41Page", "pages/tests/textInput/TextInputNavigationPage", "pages/tests/checkbox/CheckboxCase1Page", "pages/tests/checkbox/CheckboxCase2Page", -- Gitee From 6cb58b9bc5cd7a7c9d6faa83dfbb4b0c1f111cc6 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Thu, 14 Nov 2024 12:31:11 +0300 Subject: [PATCH 32/37] textPicker pages modified --- .../textPicker/TextPickerCase11Ability.ets | 43 ++++++ .../textPicker/TextPickerCase21Ability.ets | 43 ++++++ .../textPicker/TextPickerCase31Ability.ets | 43 ++++++ .../textPicker/TextPickerCase41Ability.ets | 44 ++++++ .../tests/textPicker/TextPickerCase11Page.ets | 57 ++++++++ .../tests/textPicker/TextPickerCase1Page.ets | 3 +- .../tests/textPicker/TextPickerCase21Page.ets | 57 ++++++++ .../tests/textPicker/TextPickerCase2Page.ets | 3 +- .../tests/textPicker/TextPickerCase31Page.ets | 136 ++++++++++++++++++ .../tests/textPicker/TextPickerCase3Page.ets | 3 +- .../tests/textPicker/TextPickerCase41Page.ets | 136 ++++++++++++++++++ .../tests/textPicker/TextPickerCase4Page.ets | 3 +- .../textPicker/TextPickerNavigationPage.ets | 16 +++ .../entry/src/main/module.json5 | 40 ++++++ .../resources/base/profile/main_pages.json | 4 + 15 files changed, 623 insertions(+), 8 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase11Ability.ets new file mode 100644 index 0000000..ec05e26 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase21Ability.ets new file mode 100644 index 0000000..bcb64bc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase31Ability.ets new file mode 100644 index 0000000..58c032c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase41Ability.ets new file mode 100644 index 0000000..07eac9b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/textPicker/TextPickerCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TextPickerCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/textPicker/TextPickerCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase11Page.ets new file mode 100644 index 0000000..2fe8e1f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase11Page.ets @@ -0,0 +1,57 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextPickerCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + TextPicker({ range: this.multi}).margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets index 79737be..d6d25d5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase1Page.ets @@ -25,8 +25,7 @@ struct TextPickerCase1Page { Scroll() { Column({ space: '13vp' }) { ForEach(this.data, (item: string) => { - TextPicker({ range: this.multi }) - .width('60%') + TextPicker({ range: this.multi}).margin({right:'50vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase21Page.ets new file mode 100644 index 0000000..81909f7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase21Page.ets @@ -0,0 +1,57 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TextPickerCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '13vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TextPicker({ range: this.multi}).margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets index c8efdd0..94caf3d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase2Page.ets @@ -25,8 +25,7 @@ struct TextPickerCase2Page { Column({ space: '13vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { - TextPicker({ range: this.multi }) - .width('60%') + TextPicker({ range: this.multi}).margin({right:'50vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase31Page.ets new file mode 100644 index 0000000..310e4cc --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase31Page.ets @@ -0,0 +1,136 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextPickerCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TextPicker({ range: this.multi}).margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets index de7e230..82cdc94 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase3Page.ets @@ -104,8 +104,7 @@ struct TextPickerCase3Page { List({ space: '13vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { - TextPicker({ range: this.multi }) - .width('60%') + TextPicker({ range: this.multi}).margin({right:'50vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase41Page.ets new file mode 100644 index 0000000..7a2da26 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase41Page.ets @@ -0,0 +1,136 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TextPickerCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + private ap_fruits: string[] = ['apple1', 'apple2', 'apple3','apple4','apple5'] + private or_fruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4', 'orange5'] + private pe_fruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4', 'peach5'] + private multi: string[][] = [this.ap_fruits, this.or_fruits, this.pe_fruits] + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '13vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TextPicker({ range: this.multi}).margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets index 0946a95..c4bcceb 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerCase4Page.ets @@ -104,8 +104,7 @@ struct TextPickerCase4Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { - TextPicker({ range: this.multi }) - .width('60%') + TextPicker({ range: this.multi}).margin({right:'50vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets index 6e59dfa..16f24c4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/textPicker/TextPickerNavigationPage.ets @@ -26,6 +26,22 @@ struct TextPickerNavigationPage { title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts', ability: 'TextPickerCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 100 Texts, theme changing on scroll', + ability: 'TextPickerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 100 Texts, theme changing on scroll', + ability: 'TextPickerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 Texts, theme changing on scroll', + ability: 'TextPickerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 Texts, theme changing on scroll', + ability: 'TextPickerCase4Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 28bac44..2d3de16 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -1132,6 +1132,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "TextPickerCase11Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase21Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase31Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TextPickerCase41Ability", + "srcEntry": "./ets/ability/textPicker/TextPickerCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "DataPanelCase1Ability", "srcEntry": "./ets/ability/DataPanel/DataPanelCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 317e272..24ac624 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -145,6 +145,10 @@ "pages/tests/textPicker/TextPickerCase2Page", "pages/tests/textPicker/TextPickerCase3Page", "pages/tests/textPicker/TextPickerCase4Page", + "pages/tests/textPicker/TextPickerCase11Page", + "pages/tests/textPicker/TextPickerCase21Page", + "pages/tests/textPicker/TextPickerCase31Page", + "pages/tests/textPicker/TextPickerCase41Page", "pages/tests/textPicker/TextPickerNavigationPage", "pages/tests/DataPanel/DataPanelCase1Page", "pages/tests/DataPanel/DataPanelCase2Page", -- Gitee From 2253c43f5f17929f87e47cc2e5ea8e7263f5cbb1 Mon Sep 17 00:00:00 2001 From: maximsonyagin_4dd0 Date: Thu, 14 Nov 2024 13:00:01 +0300 Subject: [PATCH 33/37] counter pages added --- .../ability/counter/CounterCase11Ability.ets | 43 ++++++ .../ability/counter/CounterCase1Ability.ets | 43 ++++++ .../ability/counter/CounterCase21Ability.ets | 43 ++++++ .../ability/counter/CounterCase2Ability.ets | 43 ++++++ .../ability/counter/CounterCase31Ability.ets | 43 ++++++ .../ability/counter/CounterCase3Ability.ets | 43 ++++++ .../ability/counter/CounterCase41Ability.ets | 44 ++++++ .../ability/counter/CounterCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../pages/tests/counter/CounterCase11Page.ets | 57 ++++++++ .../pages/tests/counter/CounterCase1Page.ets | 55 +++++++ .../pages/tests/counter/CounterCase21Page.ets | 57 ++++++++ .../pages/tests/counter/CounterCase2Page.ets | 55 +++++++ .../pages/tests/counter/CounterCase31Page.ets | 136 ++++++++++++++++++ .../pages/tests/counter/CounterCase3Page.ets | 134 +++++++++++++++++ .../pages/tests/counter/CounterCase41Page.ets | 136 ++++++++++++++++++ .../pages/tests/counter/CounterCase4Page.ets | 134 +++++++++++++++++ .../tests/counter/CounterNavigationPage.ets | 71 +++++++++ .../entry/src/main/module.json5 | 80 +++++++++++ .../resources/base/profile/main_pages.json | 11 +- 20 files changed, 1275 insertions(+), 1 deletion(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase41Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase11Ability.ets new file mode 100644 index 0000000..80087c8 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase1Ability.ets new file mode 100644 index 0000000..8493279 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase21Ability.ets new file mode 100644 index 0000000..647e8c6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase2Ability.ets new file mode 100644 index 0000000..6074d9a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase31Ability.ets new file mode 100644 index 0000000..0d7648c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase3Ability.ets new file mode 100644 index 0000000..46abd1a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase41Ability.ets new file mode 100644 index 0000000..dd74d35 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase4Ability.ets new file mode 100644 index 0000000..2fe965d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/counter/CounterCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class CounterCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/counter/CounterCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 4f51a11..81e2d81 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -80,6 +80,10 @@ struct TestsNavigationPage { { title: 'DatePicker', page: 'pages/tests/DatePicker/DatePickerNavigationPage' + }, + { + title: 'Counter', + page: 'pages/tests/counter/CounterNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase11Page.ets new file mode 100644 index 0000000..7a51279 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase11Page.ets @@ -0,0 +1,57 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CounterCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase1Page.ets new file mode 100644 index 0000000..ba72f56 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase1Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CounterCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '5vp' }) { + ForEach(this.data, (item: string) => { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase21Page.ets new file mode 100644 index 0000000..380f249 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase21Page.ets @@ -0,0 +1,57 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CounterCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase2Page.ets new file mode 100644 index 0000000..29e9a3e --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase2Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct CounterCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '20vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase31Page.ets new file mode 100644 index 0000000..8d22e33 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase31Page.ets @@ -0,0 +1,136 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CounterCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase3Page.ets new file mode 100644 index 0000000..00b00e9 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase3Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CounterCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase41Page.ets new file mode 100644 index 0000000..52690e5 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase41Page.ets @@ -0,0 +1,136 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CounterCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase4Page.ets new file mode 100644 index 0000000..2405bd4 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterCase4Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct CounterCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '20vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row(){ + Counter() + Counter() + Counter() + }.margin({right:'50vp'}) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterNavigationPage.ets new file mode 100644 index 0000000..9c9e5e2 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/counter/CounterNavigationPage.ets @@ -0,0 +1,71 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct CounterNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 300 Counters', + ability: 'CounterCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 300 Counters', + ability: 'CounterCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 6000 Counters', + ability: 'CounterCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 6000 Counters', + ability: 'CounterCase4Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 300 Counters, theme changing on scroll', + ability: 'CounterCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 300 Counters, theme changing on scroll', + ability: 'CounterCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 6000 Counters, theme changing on scroll', + ability: 'CounterCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 6000 Counters, theme changing on scroll', + ability: 'CounterCase41Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 2d3de16..6a287c1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -1491,6 +1491,86 @@ "exported": true, "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase1Ability", + "srcEntry": "./ets/ability/counter/CounterCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase2Ability", + "srcEntry": "./ets/ability/counter/CounterCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase3Ability", + "srcEntry": "./ets/ability/counter/CounterCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase4Ability", + "srcEntry": "./ets/ability/counter/CounterCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase11Ability", + "srcEntry": "./ets/ability/counter/CounterCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase21Ability", + "srcEntry": "./ets/ability/counter/CounterCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase31Ability", + "srcEntry": "./ets/ability/counter/CounterCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "CounterCase41Ability", + "srcEntry": "./ets/ability/counter/CounterCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 24ac624..9e44dc3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -167,6 +167,15 @@ "pages/tests/DatePicker/DatePickerCase21Page", "pages/tests/DatePicker/DatePickerCase31Page", "pages/tests/DatePicker/DatePickerCase41Page", - "pages/tests/DatePicker/DatePickerNavigationPage" + "pages/tests/DatePicker/DatePickerNavigationPage", + "pages/tests/counter/CounterCase1Page", + "pages/tests/counter/CounterCase2Page", + "pages/tests/counter/CounterCase3Page", + "pages/tests/counter/CounterCase4Page", + "pages/tests/counter/CounterCase11Page", + "pages/tests/counter/CounterCase21Page", + "pages/tests/counter/CounterCase31Page", + "pages/tests/counter/CounterCase41Page", + "pages/tests/counter/CounterNavigationPage" ] } \ No newline at end of file -- Gitee From e2faeaeccb4fcf17535a6e8112f63f8e04f0619b Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Fri, 15 Nov 2024 12:00:21 +0300 Subject: [PATCH 34/37] select page elements decreased x2 --- .../main/ets/pages/tests/select/SelectCase11Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase1Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase21Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase2Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase31Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase3Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase41Page.ets | 12 ------------ .../main/ets/pages/tests/select/SelectCase4Page.ets | 12 ------------ 8 files changed, 96 deletions(-) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets index afeb47c..485baad 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets @@ -34,18 +34,6 @@ struct SelectCase11Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets index 7de9793..3393c99 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets @@ -34,18 +34,6 @@ struct SelectCase1Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets index ed90e6f..95e0d8f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets @@ -34,18 +34,6 @@ struct SelectCase21Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) } }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets index 45e886c..20c2451 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets @@ -34,18 +34,6 @@ struct SelectCase2Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) } }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets index 922bd1b..73c3793 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets @@ -113,18 +113,6 @@ struct SelectCase31Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets index 05556fb..69f17e1 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets @@ -113,18 +113,6 @@ struct SelectCase3Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets index 6135e69..f358686 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets @@ -113,18 +113,6 @@ struct SelectCase41Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) } }.width('100%') diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets index 6209b0c..34b1eed 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets @@ -113,18 +113,6 @@ struct SelectCase4Page { {value:'ddd'}]) .selected(2) .value("2") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("3") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("4") }.margin({right:'50vp'}) } }.width('100%') -- Gitee From 36796cf9aef8ef58f53991c72ba6a3058c016b6f Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Fri, 15 Nov 2024 15:02:25 +0300 Subject: [PATCH 35/37] slider page modified --- .../src/main/ets/pages/tests/slider/SliderCase11Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase1Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase21Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase2Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase31Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase3Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase41Page.ets | 8 ++++---- .../src/main/ets/pages/tests/slider/SliderCase4Page.ets | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets index 2ab006c..03c24e8 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase11Page.ets @@ -22,16 +22,16 @@ struct SliderCase11Page { Column() { ForEach(this.data, (item: string) => { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets index 87a45b5..de9304c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase1Page.ets @@ -22,16 +22,16 @@ struct SliderCase1Page { Column() { ForEach(this.data, (item: string) => { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets index 18fcaca..d00678d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase21Page.ets @@ -22,16 +22,16 @@ struct SliderCase21Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets index b2f38e4..4f2e380 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase2Page.ets @@ -22,16 +22,16 @@ struct SliderCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets index b44e82d..92f9bde 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase31Page.ets @@ -101,16 +101,16 @@ struct SliderCase31Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets index 2baeeb1..9fc0edc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase3Page.ets @@ -101,16 +101,16 @@ struct SliderCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets index ad40613..5a2db65 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase41Page.ets @@ -101,16 +101,16 @@ struct SliderCase41Page { ListItem() { WithTheme({ theme: this.customTheme }) { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets index a0f8e42..64668b4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/slider/SliderCase4Page.ets @@ -101,16 +101,16 @@ struct SliderCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { Row(){ - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) - Slider() + Slider({ value: 50 }) .width('22%') .trackThickness(4) }.margin({right:'50vp'}) -- Gitee From 0c501bac32017c416790855a3d4aedbcde4d8145 Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Tue, 19 Nov 2024 13:21:20 +0300 Subject: [PATCH 36/37] AlphabetIndexer pages modified x4 --- .../AlphabetIndexerCase11Ability.ets | 43 ++++++ .../AlphabetIndexerCase21Ability.ets | 43 ++++++ .../AlphabetIndexerCase31Ability.ets | 43 ++++++ .../AlphabetIndexerCase41Ability.ets | 44 ++++++ .../AlphabetIndexerCase11Page.ets | 62 ++++++++ .../AlphabetIndexerCase1Page.ets | 12 +- .../AlphabetIndexerCase21Page.ets | 62 ++++++++ .../AlphabetIndexerCase2Page.ets | 12 +- .../AlphabetIndexerCase31Page.ets | 142 ++++++++++++++++++ .../AlphabetIndexerCase3Page.ets | 12 +- .../AlphabetIndexerCase41Page.ets | 141 +++++++++++++++++ .../AlphabetIndexerCase4Page.ets | 12 +- .../AlphabetIndexerNavigationPage.ets | 24 ++- .../tests/DatePicker/DatePickerCase11Page.ets | 2 +- .../tests/DatePicker/DatePickerCase1Page.ets | 2 +- .../tests/DatePicker/DatePickerCase21Page.ets | 2 +- .../tests/DatePicker/DatePickerCase2Page.ets | 2 +- .../tests/DatePicker/DatePickerCase31Page.ets | 2 +- .../tests/DatePicker/DatePickerCase3Page.ets | 2 +- .../tests/DatePicker/DatePickerCase41Page.ets | 2 +- .../tests/DatePicker/DatePickerCase4Page.ets | 2 +- .../pages/tests/select/SelectCase11Page.ets | 16 +- .../pages/tests/select/SelectCase1Page.ets | 16 +- .../pages/tests/select/SelectCase21Page.ets | 16 +- .../pages/tests/select/SelectCase2Page.ets | 16 +- .../pages/tests/select/SelectCase31Page.ets | 16 +- .../pages/tests/select/SelectCase3Page.ets | 16 +- .../pages/tests/select/SelectCase41Page.ets | 16 +- .../pages/tests/select/SelectCase4Page.ets | 16 +- .../entry/src/main/module.json5 | 40 +++++ .../resources/base/profile/main_pages.json | 4 + 31 files changed, 708 insertions(+), 132 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase11Ability.ets new file mode 100644 index 0000000..658d575 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase21Ability.ets new file mode 100644 index 0000000..a66e012 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase31Ability.ets new file mode 100644 index 0000000..02c56ea --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase41Ability.ets new file mode 100644 index 0000000..3d1747d --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/AlphabetIndexer/AlphabetIndexerCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class AlphabetIndexerCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page.ets new file mode 100644 index 0000000..1a42462 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct AlphabetIndexerCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets index d0b576e..6c21ef4 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase1Page.ets @@ -19,17 +19,17 @@ struct AlphabetIndexerCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '30vp' }) { + Column() { ForEach(this.data, (item: string) => { Row() { - AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) - .itemSize(30) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page.ets new file mode 100644 index 0000000..f6492ed --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page.ets @@ -0,0 +1,62 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct AlphabetIndexerCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column() { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + } + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets index b4eb53e..f625744 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page.ets @@ -18,18 +18,18 @@ struct AlphabetIndexerCase2Page { build() { Row() { Scroll() { - Column({ space: '30vp' }) { + Column() { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row() { - AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) - .itemSize(30) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) } } }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page.ets new file mode 100644 index 0000000..8e6096b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page.ets @@ -0,0 +1,142 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct AlphabetIndexerCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets index f6cceb9..ac8d859 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page.ets @@ -98,18 +98,18 @@ struct AlphabetIndexerCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '30vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row() { - AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) - .itemSize(30) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page.ets new file mode 100644 index 0000000..867e9c2 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct AlphabetIndexerCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Row() { + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) + } + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets index 91f7865..2074f7d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page.ets @@ -96,19 +96,19 @@ struct AlphabetIndexerCase4Page { build() { Row() { - List({ space: '30vp' }) { + List() { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { Row() { - AlphabetIndexer({ arrayValue: ['A', 'B', 'C' ], selected: 0 }) - .itemSize(30) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) - .itemSize(30) + .itemSize(12) + AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 }) + .itemSize(12) } } }.width('100%') diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets index 7a95750..39b01ac 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage.ets @@ -11,21 +11,37 @@ export interface DataClass { struct AlphabetIndexerNavigationPage { data: DataClass[] = [ { - title: 'ForEach (attrs & CustomTheme for all items) List with 100 AlphabetIndexers', + title: 'ForEach (attrs & CustomTheme for all items) List with 400 AlphabetIndexers', ability: 'AlphabetIndexerCase1Ability' }, { - title: 'ForEach (attrs & CustomTheme for every item) List with 100 AlphabetIndexers', + title: 'ForEach (attrs & CustomTheme for every item) List with 400 AlphabetIndexers', ability: 'AlphabetIndexerCase2Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for all items) List with 2000 AlphabetIndexers', + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 AlphabetIndexers', ability: 'AlphabetIndexerCase3Ability' }, { - title: 'LazyForEach (attrs & CustomTheme for every item) List with 2000 AlphabetIndexers', + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 AlphabetIndexers', ability: 'AlphabetIndexerCase4Ability' }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 400 AlphabetIndexers, theme changing on scroll', + ability: 'AlphabetIndexerCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 400 AlphabetIndexers, theme changing on scroll', + ability: 'AlphabetIndexerCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 8000 AlphabetIndexers, theme changing on scroll', + ability: 'AlphabetIndexerCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 8000 AlphabetIndexers, theme changing on scroll', + ability: 'AlphabetIndexerCase41Ability' + }, ] private context = getContext(this) as common.UIAbilityContext diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets index e555919..89604b0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase11Page.ets @@ -19,7 +19,7 @@ struct DatePickerCase11Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '1vp' }) { + Column({ space: '15vp' }) { ForEach(this.data, (item: string) => { DatePicker() .height(38) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets index d586473..8f7a1a7 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase1Page.ets @@ -19,7 +19,7 @@ struct DatePickerCase1Page { WithTheme({ theme: this.customTheme }) { Row() { Scroll() { - Column({ space: '1vp' }) { + Column({ space: '15vp' }) { ForEach(this.data, (item: string) => { DatePicker() .height(38) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets index 0e1f15e..98e7d1a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase21Page.ets @@ -18,7 +18,7 @@ struct DatePickerCase21Page { build() { Row() { Scroll() { - Column({ space: '1vp' }) { + Column({ space: '15vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { DatePicker() diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets index a8cd896..662b6ff 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase2Page.ets @@ -18,7 +18,7 @@ struct DatePickerCase2Page { build() { Row() { Scroll() { - Column({ space: '1vp' }) { + Column({ space: '15vp' }) { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { DatePicker() diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets index 0b8671d..a6eead5 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase31Page.ets @@ -98,7 +98,7 @@ struct DatePickerCase31Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '1vp' }) { + List({ space: '15vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { DatePicker() diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets index b95cb77..c79cd69 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase3Page.ets @@ -98,7 +98,7 @@ struct DatePickerCase3Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - List({ space: '1vp' }) { + List({ space: '15vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { DatePicker() diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets index 63806b6..e6a6c5a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase41Page.ets @@ -96,7 +96,7 @@ struct DatePickerCase41Page { build() { Row() { - List({ space: '1vp' }) { + List({ space: '15vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets index acc5c15..d875b00 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/DatePicker/DatePickerCase4Page.ets @@ -96,7 +96,7 @@ struct DatePickerCase4Page { build() { Row() { - List({ space: '1vp' }) { + List({ space: '15vp' }) { LazyForEach(this.data, (item: string, index: number) => { ListItem() { WithTheme({ theme: this.customTheme }) { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets index 485baad..6300a98 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase11Page.ets @@ -22,19 +22,11 @@ struct SelectCase11Page { Column() { ForEach(this.data, (item: string) => { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets index 3393c99..4deb66a 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase1Page.ets @@ -22,19 +22,11 @@ struct SelectCase1Page { Column() { ForEach(this.data, (item: string) => { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) }, (item: string) => item) } } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets index 95e0d8f..be350d7 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase21Page.ets @@ -22,19 +22,11 @@ struct SelectCase21Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets index 20c2451..99114e0 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase2Page.ets @@ -22,19 +22,11 @@ struct SelectCase2Page { ForEach(this.data, (item: string) => { WithTheme({ theme: this.customTheme }) { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) } }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets index 73c3793..b1f0317 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase31Page.ets @@ -101,19 +101,11 @@ struct SelectCase31Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets index 69f17e1..122062b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase3Page.ets @@ -101,19 +101,11 @@ struct SelectCase3Page { LazyForEach(this.data, (item: string, index: number) => { ListItem() { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) }.width('100%') }, (item: string) => item) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets index f358686..9610a94 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase41Page.ets @@ -101,19 +101,11 @@ struct SelectCase41Page { ListItem() { WithTheme({ theme: this.customTheme }) { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets index 34b1eed..5620c17 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/select/SelectCase4Page.ets @@ -101,19 +101,11 @@ struct SelectCase4Page { ListItem() { WithTheme({ theme: this.customTheme }) { Row(){ - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) - .value("1") - Select([{value:'aaa'}, - {value:'bbb'}, - {value:'ccc'}, - {value:'ddd'}]) - .selected(2) + Select([{value:'1'}, + {value:'2'}]) + .selected(1) .value("2") - }.margin({right:'50vp'}) + }.margin({right:'50vp', bottom:'40vp'}) } }.width('100%') }, (item: string) => item) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 6a287c1..50e08bc 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -1012,6 +1012,46 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "AlphabetIndexerCase11Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase21Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase31Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "AlphabetIndexerCase41Ability", + "srcEntry": "./ets/ability/AlphabetIndexer/AlphabetIndexerCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "SliderCase1Ability", "srcEntry": "./ets/ability/slider/SliderCase1Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 9e44dc3..f2f46fa 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -131,6 +131,10 @@ "pages/tests/AlphabetIndexer/AlphabetIndexerCase2Page", "pages/tests/AlphabetIndexer/AlphabetIndexerCase3Page", "pages/tests/AlphabetIndexer/AlphabetIndexerCase4Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase11Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase21Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase31Page", + "pages/tests/AlphabetIndexer/AlphabetIndexerCase41Page", "pages/tests/AlphabetIndexer/AlphabetIndexerNavigationPage", "pages/tests/slider/SliderCase1Page", "pages/tests/slider/SliderCase2Page", -- Gitee From ca4c1171d4f90119d7fa9d0bf2f2585775907cca Mon Sep 17 00:00:00 2001 From: Maxim Sonyagin Date: Wed, 20 Nov 2024 16:32:52 +0300 Subject: [PATCH 37/37] Timepicker page added --- .../DataPanel/DataPanelCase11Ability.ets | 4 +- .../DataPanel/DataPanelCase21Ability.ets | 4 +- .../DataPanel/DataPanelCase31Ability.ets | 4 +- .../DataPanel/DataPanelCase41Ability.ets | 4 +- .../DatePicker/DatePickerCase11Ability.ets | 4 +- .../DatePicker/DatePickerCase21Ability.ets | 4 +- .../DatePicker/DatePickerCase31Ability.ets | 4 +- .../DatePicker/DatePickerCase41Ability.ets | 4 +- .../TimePicker/TimePickerCase11Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase1Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase21Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase2Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase31Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase3Ability.ets | 43 ++++++ .../TimePicker/TimePickerCase41Ability.ets | 44 ++++++ .../TimePicker/TimePickerCase4Ability.ets | 44 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../tests/TimePicker/TimePickerCase11Page.ets | 55 +++++++ .../tests/TimePicker/TimePickerCase1Page.ets | 53 +++++++ .../tests/TimePicker/TimePickerCase21Page.ets | 55 +++++++ .../tests/TimePicker/TimePickerCase2Page.ets | 53 +++++++ .../tests/TimePicker/TimePickerCase31Page.ets | 135 ++++++++++++++++++ .../tests/TimePicker/TimePickerCase3Page.ets | 133 +++++++++++++++++ .../tests/TimePicker/TimePickerCase41Page.ets | 134 +++++++++++++++++ .../tests/TimePicker/TimePickerCase4Page.ets | 132 +++++++++++++++++ .../TimePicker/TimePickerNavigationPage.ets | 71 +++++++++ .../entry/src/main/module.json5 | 80 +++++++++++ .../resources/base/profile/main_pages.json | 11 +- 28 files changed, 1277 insertions(+), 17 deletions(-) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase11Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase21Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase31Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase41Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase11Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase1Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase21Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase2Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase31Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase41Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerNavigationPage.ets diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets index 310d447..f62bbd2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase11Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DataPanelCase1Ability extends UIAbility { +export default class DataPanelCase11Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DataPanelCase1Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DataPanel/DataPanelCase1Page', (err, data) => { + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase11Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets index e3c8acb..7da0036 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase21Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DataPanelCase2Ability extends UIAbility { +export default class DataPanelCase21Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DataPanelCase2Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DataPanel/DataPanelCase2Page', (err, data) => { + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase21Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets index e77f61b..2e9757b 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase31Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DataPanelCase3Ability extends UIAbility { +export default class DataPanelCase31Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DataPanelCase3Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DataPanel/DataPanelCase3Page', (err, data) => { + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase31Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets index f5ab061..10dd597 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DataPanel/DataPanelCase41Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DataPanelCase4Ability extends UIAbility { +export default class DataPanelCase41Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); @@ -18,7 +18,7 @@ export default class DataPanelCase4Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DataPanel/DataPanelCase4Page', (err, data) => { + windowStage.loadContent('pages/tests/DataPanel/DataPanelCase41Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets index c11a916..de972ec 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase11Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DatePickerCase1Ability extends UIAbility { +export default class DatePickerCase11Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DatePickerCase1Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DatePicker/DatePickerCase1Page', (err, data) => { + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase11Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets index 8a20e1f..fe6bf43 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase21Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DatePickerCase2Ability extends UIAbility { +export default class DatePickerCase21Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DatePickerCase2Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DatePicker/DatePickerCase2Page', (err, data) => { + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase21Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets index 6f2e7fe..51594b2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase31Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DatePickerCase3Ability extends UIAbility { +export default class DatePickerCase31Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -17,7 +17,7 @@ export default class DatePickerCase3Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DatePicker/DatePickerCase3Page', (err, data) => { + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase31Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets index d934eb4..699c38f 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/DatePicker/DatePickerCase41Ability.ets @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -export default class DatePickerCase4Ability extends UIAbility { +export default class DatePickerCase41Ability extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); @@ -18,7 +18,7 @@ export default class DatePickerCase4Ability extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/tests/DatePicker/DatePickerCase4Page', (err, data) => { + windowStage.loadContent('pages/tests/DatePicker/DatePickerCase41Page', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase11Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase11Ability.ets new file mode 100644 index 0000000..d10f726 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase11Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase11Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase11Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase1Ability.ets new file mode 100644 index 0000000..a1e5c86 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase21Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase21Ability.ets new file mode 100644 index 0000000..aefa46f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase21Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase21Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase21Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase2Ability.ets new file mode 100644 index 0000000..f6b3c20 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase31Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase31Ability.ets new file mode 100644 index 0000000..d622acd --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase31Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase31Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase31Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase3Ability.ets new file mode 100644 index 0000000..5011b66 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase41Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase41Ability.ets new file mode 100644 index 0000000..6059a22 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase41Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase41Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase41Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase4Ability.ets new file mode 100644 index 0000000..a8c1073 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/ability/TimePicker/TimePickerCase4Ability.ets @@ -0,0 +1,44 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class TimePickerCase4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/TimePicker/TimePickerCase4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 81e2d81..2d7bf7c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -84,6 +84,10 @@ struct TestsNavigationPage { { title: 'Counter', page: 'pages/tests/counter/CounterNavigationPage' + }, + { + title: 'TimePicker', + page: 'pages/tests/TimePicker/TimePickerNavigationPage' } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase11Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase11Page.ets new file mode 100644 index 0000000..89c7adf --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase11Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TimePickerCase11Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + TimePicker() + .height(38) + .width('80%') + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase1Page.ets new file mode 100644 index 0000000..adacff1 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase1Page.ets @@ -0,0 +1,53 @@ +/* ForEach List with 100 Texts as elements with Single Custom Theme for all elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TimePickerCase1Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + TimePicker() + .height(38) + .width('80%') + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase21Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase21Page.ets new file mode 100644 index 0000000..c01fa81 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase21Page.ets @@ -0,0 +1,55 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TimePickerCase21Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TimePicker() + .height(38) + .width('80%') + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase2Page.ets new file mode 100644 index 0000000..7dcb68c --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase2Page.ets @@ -0,0 +1,53 @@ +/* ForEach List with 100 Texts as elements with Custom Theme for every elements and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' + +@Entry +@Component +struct TimePickerCase2Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + data: string[] = [] + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + Scroll() { + Column({ space: '15vp' }) { + ForEach(this.data, (item: string) => { + WithTheme({ theme: this.customTheme }) { + TimePicker() + .height(38) + .width('80%') + } + }, (item: string) => item) + } + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase31Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase31Page.ets new file mode 100644 index 0000000..c5382c6 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase31Page.ets @@ -0,0 +1,135 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TimePickerCase31Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TimePicker() + .height(38) + .width('80%') + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase3Page.ets new file mode 100644 index 0000000..454c7e2 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase3Page.ets @@ -0,0 +1,133 @@ +/* LazyForEach List with 2000 Texts as elements with Single Custom Theme for all items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TimePickerCase3Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + TimePicker() + .height(38) + .width('80%') + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase41Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase41Page.ets new file mode 100644 index 0000000..cea459a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase41Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TimePickerCase41Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TimePicker() + .height(38) + .width('80%') + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down){ + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase4Page.ets new file mode 100644 index 0000000..dee693b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerCase4Page.ets @@ -0,0 +1,132 @@ +/* LazyForEach List with 2000 Texts as elements with Custom Theme for every items and custom attributes */ +import { CustomTheme } from '@ohos.arkui.theme'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct TimePickerCase4Page { + @State customTheme: CustomTheme = RedTheme + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '15vp' }) { + LazyForEach(this.data, (item: string, index: number) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + TimePicker() + .height(38) + .width('80%') + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + break + case 1: + this.customTheme = GreenTheme + break + case 2: + default: + this.customTheme = BrownTheme + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerNavigationPage.ets new file mode 100644 index 0000000..604f56b --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TimePicker/TimePickerNavigationPage.ets @@ -0,0 +1,71 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct TimePickerNavigationPage { + data: DataClass[] = [ + { + title: 'ForEach (attrs & CustomTheme for all items) List with 200 DatePickers', + ability: 'TimePickerCase1Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 200 DatePickers', + ability: 'TimePickerCase2Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 4000 DatePickers', + ability: 'TimePickerCase3Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 4000 DatePickers', + ability: 'TimePickerCase4Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for all items) List with 200 DatePickers, theme changing on scroll', + ability: 'TimePickerCase11Ability' + }, + { + title: 'ForEach (attrs & CustomTheme for every item) List with 200 DatePickers, theme changing on scroll', + ability: 'TimePickerCase21Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for all items) List with 4000 DatePickers, theme changing on scroll', + ability: 'TimePickerCase31Ability' + }, + { + title: 'LazyForEach (attrs & CustomTheme for every item) List with 4000 DatePickers, theme changing on scroll', + ability: 'TimePickerCase41Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index 50e08bc..0d39093 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -1372,6 +1372,86 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background" }, + { + "name": "TimePickerCase1Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase2Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase2Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase3Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase3Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase4Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase4Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase11Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase11Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase21Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase21Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase31Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase31Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "TimePickerCase41Ability", + "srcEntry": "./ets/ability/TimePicker/TimePickerCase41Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, { "name": "ButtonCase11Ability", "srcEntry": "./ets/ability/button/ButtonCase11Ability.ets", diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index f2f46fa..a4ca668 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -180,6 +180,15 @@ "pages/tests/counter/CounterCase21Page", "pages/tests/counter/CounterCase31Page", "pages/tests/counter/CounterCase41Page", - "pages/tests/counter/CounterNavigationPage" + "pages/tests/counter/CounterNavigationPage", + "pages/tests/TimePicker/TimePickerCase1Page", + "pages/tests/TimePicker/TimePickerCase2Page", + "pages/tests/TimePicker/TimePickerCase3Page", + "pages/tests/TimePicker/TimePickerCase4Page", + "pages/tests/TimePicker/TimePickerCase11Page", + "pages/tests/TimePicker/TimePickerCase21Page", + "pages/tests/TimePicker/TimePickerCase31Page", + "pages/tests/TimePicker/TimePickerCase41Page", + "pages/tests/TimePicker/TimePickerNavigationPage" ] } \ No newline at end of file -- Gitee