diff --git a/OAT.xml b/OAT.xml index 1a64ff47df6dc20c0a39e27cd93becffe682ae20..dce0c1f57d5d1b60b9ad735c423a35cbddb5f724 100644 --- a/OAT.xml +++ b/OAT.xml @@ -142,6 +142,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore index f0b9dc0066df0394eda177867467b1e0bf1539c6..d2ff20141ceed86d87c0ea5d99481973005bab2b 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore @@ -1,3 +1,5 @@ +/node_modules +/oh_modules /local.properties /.idea **/build @@ -6,5 +8,5 @@ /.clangd /.clang-format /.clang-tidy -**/oh_modules -**/oh-package-lock.json5 \ No newline at end of file +**/.test +/.appanalyzer \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 index f17606675dd273842d798f2594ad664b3d388c06..0e3f560dfe0148426ebb728d1acab892a5d03d88 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,12 +15,11 @@ { "app": { - "bundleName": "com.samples.languagebaseclasslibrary", - "vendor": "samples", + "bundleName": "com.arkui.sample", + "vendor": "example", "versionCode": 1000000, "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true + "icon": "$media:layered_image", + "label": "$string:app_name" } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json index 9523fbcc55715a9210d0913d29d4b8e612cfef0e..14afd05c22407a11dd6e53829c1e40a8791e9559 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "app_name", - "value": "LanguageBaseClassLibrary" + "value": "sample0801" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/background.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/background.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/foreground.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/foreground.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/layered_image.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 index d618c219f991269ca4a3a15e7d09d8a894d06b15..18c1cf719834d5d601f0414ef312bb8e9ea99625 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,9 +20,25 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, - "runtimeOS": "OpenHarmony" + "targetSdkVersion": "20", + "arkTSVersion": "1.2", + "compileSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" } ] }, @@ -40,16 +56,16 @@ ] }, { - "name": "menuitems", - "srcPath": "./feature/menuitems" + "name": "common", + "srcPath": "./common", }, { "name": "capabilities", - "srcPath": "./feature/capabilities" + "srcPath": "./feature/capabilities", }, { - "name": "common", - "srcPath": "./common" + "name": "menuitems", + "srcPath": "./feature/menuitems", } ] } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..e2713a2779c5a3e0eb879efe6115455592caeea5 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore @@ -1,3 +1,6 @@ /node_modules +/oh_modules /.preview -/build \ No newline at end of file +/build +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets index eea56ec42d86318775e6182cf6b5e94b7857589b..9b7a2844d6a1b42df6c9fc00b5de15e6144554e4 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets @@ -1,3 +1,4 @@ +'use static' /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +16,10 @@ export { logger } from './src/main/ets/util/Logger'; -export { CustomDataSource } from './src/main/ets/components/CustomDataSource'; +// export { CustomDataSource } from './src/main/ets/components/CustomDataSource'; export { getString, getStringArray } from './src/main/ets/util/ResourceUtil'; export { BaseDataSource } from './src/main/ets/components/BaseDataSource'; -export { EmptyPage } from './src/main/ets/components/EmptyPage'; +export { EmptyPage } from './src/main/ets/components/EmptyPage'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 index 431999870d30f72c7c6e728d63eb40d9b271f976..aefa5f6959f0e65b9347a5182401ee9f4873007a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,5 +16,31 @@ { "apiType": "stageMode", "buildOption": { - } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts index 9c3992ac05f1a4b3c5c93a44388308fd1dc45aa8..8b916a32c526d654b0110abdb28f04e0bc874769 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,6 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').harTasks +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 index 995e5e09e22ed718cd915ea42801ba00217f734e..c1a64fe36152a1c431992f6a4934cc745cd3f181 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,13 +14,11 @@ */ { - "license": "ISC", - "types": "", - "devDependencies": {}, - "name": "@ohos/common", - "description": "a npm package which contains arkUI2.0 page", + "name": "common", + "version": "1.2.0", + "description": "Please describe the basic information.", "main": "Index.ets", - "repository": {}, - "version": "1.0.0", + "author": "", + "license": "Apache-2.0", "dependencies": {} } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets index 75dccab85515b8c962dc10f816a30b60be4c480e..821fe16b0101d1e1663b24fe52d1ddf6948f9dad 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets @@ -23,29 +23,34 @@ import { logger } from '../util/Logger'; const TAG: string = 'BaseDataSource'; -export class BaseDataSource implements IDataSource { +export class BaseDataSource implements IDataSource { + private data: T[] = [] private listeners: DataChangeListener[] = []; public totalCount(): number { return 0; } - public getData(index: number): Object { - return ''; + public setData(data: T[]) { + this.data = data + } + + public getData(index: number): T { + return this.data[index as int] } registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { + if (this.listeners.indexOf(listener) < 0.0) { logger.info(TAG, 'add listener'); this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { + const pos: number = this.listeners.indexOf(listener); + if (pos >= 0.0) { logger.info(TAG, 'remove listener'); - this.listeners.splice(pos, 1); + this.listeners.splice(pos, 1.0); } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets index 81829136d7e6f1bdafb1118eaea334ee6ee019bf..44d79be73f4916c8ae672689fea88dcb9c493dab 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets @@ -1,4 +1,4 @@ -'use static' +// 'use static' /** * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,74 +14,74 @@ * limitations under the License. */ -import { - IDataSource, - DataChangeListener, -} from '@kit.ArkUI'; - -class BasicDataSource implements IDataSource { - private listeners: DataChangeListener[] = []; - - public totalCount(): number { - return 0; - } - - public getData(index: number): Object { - return ''; - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded(); - }) - } - - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdded(index); - }) - } - - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChanged(index); - }) - } -} - -export class CustomDataSource extends BasicDataSource { - public dataArray: string[] = []; - - constructor(ele: string[]) { - super(); - for (let index: int = 0;index < ele.length; index++) { - this.dataArray.push(ele[index]); - } - } - - public totalCount(): number { - return this.dataArray.length; - } - - public getData(index: number): string { - return this.dataArray[index as int]; - } - - public addData(index: number, data: string): void { - this.dataArray.splice(index, 0, data); - this.notifyDataAdd(index); - } -} \ No newline at end of file +// import { +// IDataSource, +// DataChangeListener, +// } from '@kit.ArkUI'; +// +// class BasicDataSource implements IDataSource { +// private listeners: DataChangeListener[] = []; +// +// public totalCount(): number { +// return 0; +// } +// +// public getData(index: number): T { +// // return ''; +// } +// +// registerDataChangeListener(listener: DataChangeListener): void { +// if (this.listeners.indexOf(listener) < 0.0) { +// this.listeners.push(listener); +// } +// } +// +// unregisterDataChangeListener(listener: DataChangeListener): void { +// const pos: number = this.listeners.indexOf(listener); +// if (pos >= 0.0) { +// this.listeners.splice(pos, 1.0); +// } +// } +// +// 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); +// }) +// } +// } +// +// export class CustomDataSource extends BasicDataSource{ +// public dataArray: string[] = []; +// +// constructor(ele: string[]) { +// super(); +// for (let index: number = 0.0;index < ele.length; index++) { +// this.dataArray.push(ele[index as int]); +// } +// } +// +// public totalCount(): number { +// return this.dataArray.length; +// } +// +// public getData(index: number): string { +// return this.dataArray[index as int]; +// } +// +// public addData(index: number, data: string): void { +// this.dataArray.splice(index, 0.0, data); +// this.notifyDataAdd(index); +// } +// } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets index d8ebc3e63c67cd9bb8a332a2ddd1ce13a70f7f0b..ae0b3e2d6f1a884d57292e2b6c01a3c7226067ab 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets @@ -18,13 +18,14 @@ import { Component, PixelMap, Resource, - $r, ResourceStr, Column, Image, Text, FlexAlign, HorizontalAlign, + $r, + Margin, } from '@kit.ArkUI'; @Component @@ -35,13 +36,13 @@ export struct EmptyPage { build() { Column() { Image(this.img) - .width(120) - .aspectRatio(1) + .width(120.0) + .aspectRatio(1.0) Text(this.message) - .fontSize(14) + .fontSize(14.0) .fontColor($r('app.color.text_color_second')) - .margin({ top: 8 }) + .margin({ top: 8.0 } as Margin) } .width('100%') .height('100%') diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/MainPage.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4038459839e24ebe536b8ece3e8e4b483e08a4a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/MainPage.ets @@ -0,0 +1,43 @@ +'use static' +/* +* Copyright (c) 2025 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { + Component, + State, + Row, + Column, + Text, + FontWeight, + $r +} from '@kit.ArkUI'; + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets index c3efefcabb4ca4056053c7df7ef838f1215501d5..173e793db2524e5cf08a3e10b9b22837c340625f 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets @@ -17,9 +17,9 @@ import hilog from '@ohos.hilog'; class Logger { - private domain: number; + private domain: int; private prefix: string; - private format: string = '%{public}s, %{public}s'; + private format: string = '%{public}s'; constructor(prefix: string) { this.prefix = prefix; @@ -27,19 +27,19 @@ class Logger { } debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); + hilog.debug(this.domain, this.prefix, this.format, args.join(' ')); } info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); + hilog.info(this.domain, this.prefix, this.format, args.join(' ')); } warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); + hilog.warn(this.domain, this.prefix, this.format, args.join(' ')); } error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); + hilog.error(this.domain, this.prefix, this.format, args.join(' ')); } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets index 14287c8bf6abea0d6801ec93882d0359fbe29861..7e7ef1a59921877cfe6ce895436974726a3effea 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets @@ -16,18 +16,17 @@ import { Resource, - getUIContext, + UIContext, + Context } from '@kit.ArkUI'; -import common from '@ohos.app.ability.common'; - -export async function getStringArray(resource: Resource): Promise> { - let context = getUIContext().getHostContext() as common.UIAbilityContext; - let menuList: Array = await context.resourceManager.getStringArrayValue(resource); +export function getStringArray(resource: Resource, uIContext: UIContext): Array { + let context = uIContext.getHostContext() as Context; + let menuList: Array = context.resourceManager.getStringArrayValueSync(resource.id); return menuList; } -export function getString(resource: Resource): string { - let context = getUIContext().getHostContext() as common.UIAbilityContext; - return context.resourceManager.getStringSync(resource); -} +export function getString(resource: Resource, uIContext: UIContext): string { + let context = uIContext.getHostContext() as Context; + return context.resourceManager.getStringSync(resource.id); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 index 922bccb772db0e621d51b402ed41626ab05d47d4..ece5960dc388b6f44f9c142a8c2e9d6b545ff893 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,7 @@ "name": "common", "type": "har", "deviceTypes": [ - "default", - "tablet" + "default" ] } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/float.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json index 9bfeb22586ce292fc9a1219b0a65417ef879858a..ff2cd1e73d40485dbd5feb2732025f6fb1dd0d82 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json @@ -2,8 +2,9 @@ "string": [ { "name": "page_show", - "value": "page from npm package" + "value": "page from package" }, + { "name": "tv_no_data", "value": "No data" diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..40120df283016c907e0e7bbc01dc091f99e5e052 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "common_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/LocalUnit.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore index 5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96..e2713a2779c5a3e0eb879efe6115455592caeea5 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore @@ -1,4 +1,6 @@ /node_modules +/oh_modules /.preview /build -/.cxx \ No newline at end of file +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 index ddd6e5f1ac23a18a1d1d0d8d7470c6d4726ef66e..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,9 +14,24 @@ */ { - "apiType": 'stageMode', + "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], "targets": [ { "name": "default" diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts index 27a66d9a3cbadf06e3a3857221a0a1b7c1087e89..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,5 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 index d83add340b607163a1c7ed16d7aa7b98177c934a..2ae709e0fe6a8511863ed4f2eeeb1a6594605c02 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,16 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + { - "license": "ISC", - "devDependencies": {}, "name": "entry", - "description": "example description", - "repository": {}, - "version": "1.0.0", + "version": "1.2.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", "dependencies": { - "@ohos/capabilities": "file:../feature/capabilities", - "@ohos/menuitems": "file:../feature/menuitems", - "@ohos/common": "file:../common" + "common": "file:../common", + "menuitems": "file:../feature/menuitems", + "capabilities": "file:../feature/capabilities" } -} +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets index 9120754461e81263643c5569b98e88757083bff7..ff9f80cc4dadc9972acc20c21ee1b74b82d1f70b 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,5 +1,6 @@ +'use static' /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,12 +14,11 @@ * limitations under the License. */ +import { AppStorage, Context } from '@kit.ArkUI'; +import { AbilityConstant, UIAbility, Want, common } from '@kit.AbilityKit'; import display from '@ohos.display'; -import UIAbility from '@ohos.app.ability.UIAbility'; import window from '@ohos.window'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; -import Want from '@ohos.app.ability.Want'; -import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import { logger } from 'common'; const BREAKPOINT_MD: number = 600; const BREAKPOINT_BIG: number = 840; @@ -28,9 +28,9 @@ const TAG: string = 'EntryAbility'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { logger.info(TAG, 'Ability onCreate'); - AppStorage.setOrCreate('selectedLabel', ''); - AppStorage.setOrCreate('selectedSecondLabel', ''); - AppStorage.setOrCreate('context', this.context); + AppStorage.setOrCreate('selectedLabel', ''); + AppStorage.setOrCreate('selectedSecondLabel', ''); + AppStorage.setOrCreate('context', this.context as common.UIAbilityContext); } updateBreakpoint(windowWidth: number): void { @@ -44,9 +44,9 @@ export default class EntryAbility extends UIAbility { curBp = 'lg'; } logger.info(TAG, 'window width: ' + windowWidth + ', window width vp: ' + windowWidthVp + ', breakpoint: ' + curBp); - AppStorage.SetOrCreate('currentBreakpoint', curBp); - AppStorage.SetOrCreate('windowWidth', windowWidthVp); - AppStorage.SetOrCreate('isSplitMode', curBp === 'sm' ? false : true); + // AppStorage.setOrCreate('currentBreakpoint', curBp); + AppStorage.setOrCreate('windowWidth', windowWidthVp); + AppStorage.setOrCreate('isSplitMode', curBp === 'sm' ? false : true); } onDestroy(): void { @@ -74,7 +74,7 @@ export default class EntryAbility extends UIAbility { }); windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { + if (err && err.code) { logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); return; } @@ -96,4 +96,4 @@ export default class EntryAbility extends UIAbility { // Ability has back to background logger.info(TAG, 'Ability onBackground'); } -} +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets index 0345bffd5e4a35b29d1ec34bb5f07f99e9ddaff9..0469e4cafbd7b4b10cfbc9b5fe4134af5e75ff1f 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets @@ -15,7 +15,6 @@ */ import { - $r, CustomDialog, CustomDialogController, State, @@ -28,62 +27,67 @@ import { Entry, Component, DialogAlignment, - getUIContext, Image, ImageFit, Blank, TextInput, FlexAlign, + Margin, + Padding, + $r, + ClickEvent, + StorageLink } from '@kit.ArkUI'; - -import router from '@ohos.router'; import emitter from '@ohos.events.emitter'; -import { Constant, Information } from '@ohos/capabilities'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { Constant, Information } from 'capabilities'; +import { getString } from 'common'; -const MIN_AGE: int = 1; -const AGE_RANGE: int = 9; -const AGE_DEFAULT: int = 0; +const MIN_AGE = 1; +const AGE_RANGE = 9; +const AGE_DEFAULT = 0; -const arr = Array(AGE_RANGE) +const arr = Array(AGE_RANGE) .fill(0) - .map((_: number, i: number) => `${i + MIN_AGE}${getString($r('app.string.old'))}`); +@Component @CustomDialog -struct AgePickDialog { +export struct AgePickDialog { private controller?: CustomDialogController; - private sure: (age: number) => void = () => { - }; + private sure: (age: number) => void = () => {}; @State select: number = AGE_DEFAULT; build() { Column() { Text($r('app.string.age')) - .margin({ left: 24, top: 14 }) + .margin({ left: 24.0, top: 14.0 } as Margin) .width('100%') .fontColor($r('app.color.text_color_primary')) - .fontSize(20) + .fontSize(20.0) .textAlign(TextAlign.Start) Column() { - TextPicker({ range: arr, selected: this.select }) - .onChange((value: string | string[], index: number | number[]) => { + TextPicker({ range: arr.map( + (_: number, i: number) => `${i + MIN_AGE}${getString($r('app.string.old'), this.getUIContext())}` + ), + selected: this.select + }) + .onChange((value: string | string[], index: number | number[]): void => { if (typeof index === 'number') { - this.select = index; + this.select = index as number; } }) } .width('100%') - .height(238) + .height(238.0) Row() { Text($r('app.string.cancel')) .height('100%') .width('50%') .textAlign(TextAlign.Center) - .fontSize(16) + .fontSize(16.0) .fontColor($r('app.color.text_color_accent')) - .onClick(() => { + .onClick((e: ClickEvent) => { this.controller?.close(); }) Divider() @@ -94,18 +98,18 @@ struct AgePickDialog { .height('100%') .width('50%') .textAlign(TextAlign.Center) - .fontSize(16) + .fontSize(16.0) .fontColor($r('app.color.text_color_accent')) - .onClick(() => { + .onClick((e: ClickEvent) => { this.sure(this.select + MIN_AGE) this.controller?.close(); }) } - .height(40) + .height(40.0) } - .height(328) - .margin({ left: 12, right: 12, bottom: 16 }) - .borderRadius(24) + .height(328.0) + .margin({ left: 12.0, right: 12.0, bottom: 16.0 } as Margin) + .borderRadius(24.0) .backgroundColor($r('app.color.bg_white')) } } @@ -113,7 +117,7 @@ struct AgePickDialog { @Entry @Component export struct AddInformationView { - @State information: Information = new Information('', 0, '', true) + @State information: Information = new Information('', 0.0, '', true) private dialogController: CustomDialogController = new CustomDialogController({ builder: AgePickDialog({ sure: (age: number) => { this.information.age = age; @@ -121,199 +125,196 @@ export struct AddInformationView { customStyle: false, alignment: DialogAlignment.Bottom }) - @State flag: string = ''; + // @State flag: string = ''; + @StorageLink('selectedLabel') flag: string = ''; - aboutToAppear() { - let tem: string = (getUIContext().getRouter.getParams() as Record)['title'] as string; - if (!tem) { - return; - } - this.flag = tem; - } + // aboutToAppear() { + // let tem = this.getUIContext().getRouter().getParams() + // console.log('wzr:' + `${tem}`) + // let temp = JSON.stringify(tem) + // console.log('wzr:' + temp) + // this.getUIContext().getPromptAction().showToast({ message: this.flag, duration: 2000 }) + // let tem: string = this.getUIContext().getRouter().getParams()['title'] + // let tem: Model = (this.getUIContext().getRouter().getParams()) + // let tem: string = (this.getUIContext().getRouter().getParams() as Record)['title'] as string; + // if (!tem) { + // return; + // } + // this.flag = tem; + // } build() { Column() { Row() { Row() { Image($r("app.media.ic_public_back")) - .height(24) - .aspectRatio(1) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .height('100%') - .aspectRatio(1) - .padding({ left: 24 }) - .onClick(() => { - getUIContext().getRouter.back(); + .aspectRatio(1.0) + .padding({ left: 24.0 } as Padding) + .onClick((e: ClickEvent) => { + this.getUIContext().getRouter().back(); }) Text($r('app.string.add_new_contact')) .fontColor($r('app.color.text_color_primary')) - .fontSize(20) - .margin({ left: 24 }) + .fontSize(20.0) + .margin({ left: 24.0 } as Margin) Blank() Row() { Image($r('app.media.ic_public_confirm')) - .height(24) - .aspectRatio(1) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .id('add_confirm') .height('100%') - .aspectRatio(1) - .padding({ right: 24 }) - .onClick(() => { + .aspectRatio(1.0) + .padding({ right: 24.0 } as Padding) + .onClick((e: ClickEvent) => { let eventId = Constant.EMITTER_ID_DEFAULT; - switch (this.flag) { - case getString($r('app.string.deque')): - eventId = Constant.EMITTER_ID_DEQUE; - break; - case getString($r('app.string.linked_list')): - eventId = Constant.EMITTER_ID_LINKED_LIST; - break; - case getString($r('app.string.list')): - eventId = Constant.EMITTER_ID_LIST; - break; - case getString($r('app.string.queue')): - eventId = Constant.EMITTER_ID_QUEUE; - break; - case getString($r('app.string.stack')): - eventId = Constant.EMITTER_ID_STACK; - break; - case getString($r('app.string.vector')): - eventId = Constant.EMITTER_ID_VECTOR; - break; - default: - eventId = Constant.EMITTER_ID_DEFAULT; - break; + const uIContext = this.getUIContext(); + if (this.flag == getString($r('app.string.deque'), uIContext)){ + eventId = Constant.EMITTER_ID_DEQUE; + } + if (this.flag == getString($r('app.string.linked_list'), uIContext)){ + eventId = Constant.EMITTER_ID_LINKED_LIST; + } + if (this.flag == getString($r('app.string.list'), uIContext)){ + eventId = Constant.EMITTER_ID_LIST; + } + if (this.flag == getString($r('app.string.queue'), uIContext)){ + eventId = Constant.EMITTER_ID_QUEUE; + } + if (this.flag == getString($r('app.string.stack'), uIContext)){ + eventId = Constant.EMITTER_ID_STACK; } - let event: emitter.InnerEvent = { eventId: eventId, priority: emitter.EventPriority.HIGH }; - let eventData: emitter.EventData = { data: { 'name': this.information.name, 'age': this.information.age, 'phone': this.information.phone, - 'clickAble': this.information.clickAble - } + 'clickAble': this.information.clickAble as boolean + } as Record }; - emitter.emit(event, eventData); - getUIContext().getRouter.back(); + uIContext.getRouter().back(); }) - } .width('100%') - .height(56) + .height(56.0) Row() { Image($r('app.media.ic_public_user')) - .margin({ left: 19 }) - .width(19) - .aspectRatio(1) + .margin({ left: 19.0 } as Margin) + .width(19.0) + .aspectRatio(1.0) Text($r('app.string.names')) - .margin({ left: 19 }) - .fontSize(16) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { TextInput({ placeholder: $r('app.string.input_name') }) .id('add_name') - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onChange((value: string) => { + .onChange((value: string):void => { this.information.name = value; }) } - .layoutWeight(1) - .margin({ left: 52, right: 16 }) + .layoutWeight(1.0) + .margin({ left: 52.0, right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) Row() { Image($r('app.media.ic_age')) - .margin({ left: 19 }) - .width(19) - .aspectRatio(1) + .margin({ left: 19.0 } as Margin) + .width(19.0) + .aspectRatio(1.0) Text($r('app.string.age')) - .margin({ left: 19 }) - .fontSize(16) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { Image($r('app.media.ic_public_spinner_down')) - .height(24) - .width(12) + .height(24.0) + .width(12.0) } .id('add_age') .justifyContent(FlexAlign.Center) - .width(54) + .width(54.0) .height('100%') - .onClick(() => { + .onClick((e: ClickEvent) => { this.dialogController.open(); }) Column() { TextInput({ - text: this.information.age === 0 ? '' : `${this.information.age}`, + text: this.information.age === 0.0 ? '' : `${this.information.age}`, placeholder: $r('app.string.please_choose') }) - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .focusable(false) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onClick(() => { + .onClick((e: ClickEvent) => { this.dialogController.open(); }) } - .layoutWeight(1) - .margin({ right: 16 }) + .layoutWeight(1.0) + .margin({ right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) Row() { Image($r('app.media.ic_public_phone')) - .margin({ left: 19 }) - .width(19) - .aspectRatio(1) + .margin({ left: 19.0 } as Margin) + .width(19.0) + .aspectRatio(1.0) Text($r('app.string.contact_phone')) - .margin({ left: 19 }) - .fontSize(16) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { TextInput({ placeholder: $r('app.string.input_phone') }) .id('add_phone') - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onChange((value: string) => { + .onChange((value: string):void => { this.information.phone = value; }) } - .layoutWeight(1) - .margin({ left: 52, right: 16 }) + .layoutWeight(1.0) + .margin({ left: 52.0, right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) } .height('100%') .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - .padding({ left: 12, right: 12 }) + .padding({ left: 12.0, right: 12.0 } as Padding) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets index c3f0ae5fa42166c19c15b6d65f48ba17d1cebfd7..27557eb6f9f033165ba11077f001c8debb9de0dc 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets @@ -18,8 +18,6 @@ import { Entry, Component, State, - getUIContext, - $r, Column, Row, Image, @@ -27,29 +25,33 @@ import { Text, Blank, TextInput, + Margin, + Padding, + ClickEvent, + $r, + StorageLink } from '@kit.ArkUI'; - -import router from '@ohos.router'; import emitter from '@ohos.events.emitter'; -import { Constant, KeyValuePair } from '@ohos/capabilities'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { Constant, KeyValuePair } from 'capabilities'; +import { getString } from 'common'; @Entry @Component export struct AddKeyValueView { @State keyValuePair: KeyValuePair = new KeyValuePair('', '') @State title: string = ''; - @State flag: string = ''; + // @State flag: string = ''; + @StorageLink('selectedLabel') flag: string = ''; aboutToAppear() { - let tem: string = (getUIContext().getRouter.getParams() as Record)['title'] as string; - if (!tem) { - return; - } - this.flag = tem; - let matchArr: RegExpMatchArray | null = tem.match(new RegExp('.*(?=\\(|()')); + // let tem: string = (this.getUIContext().getRouter().getParams() as Record)['title'] as string; + // if (!tem) { + // return; + // } + // this.flag = tem; + let matchArr: RegExpMatchArray | null = this.flag.match(new RegExp('.*(?=\\(|()')); if (matchArr !== null) { - this.title = `${getString($r('app.string.add'))}${matchArr[0]}`; + this.title = `${getString($r('app.string.add'), this.getUIContext())}${matchArr[0]}`; } } @@ -58,124 +60,117 @@ export struct AddKeyValueView { Row() { Row() { Image($r("app.media.ic_public_back")) - .height(24) - .aspectRatio(1) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .height('100%') - .aspectRatio(1) - .padding({ left: 24 }) - .onClick(() => { - getUIContext().getRouter.back(); + .aspectRatio(1.0) + .padding({ left: 24.0 } as Padding) + .onClick((e: ClickEvent) => { + this.getUIContext().getRouter().back(); }) Text(this.title) .fontColor($r('app.color.text_color_primary')) - .fontSize(20) - .margin({ left: 24 }) + .fontSize(20.0) + .margin({ left: 24.0 } as Margin) Blank() Row() { Image($r("app.media.ic_public_confirm")) - .height(24) - .aspectRatio(1) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .id('add_confirm') .height('100%') - .aspectRatio(1) - .padding({ right: 24 }) - .onClick(() => { + .aspectRatio(1.0) + .padding({ right: 24.0 } as Padding) + .onClick((e: ClickEvent) => { let eventId = Constant.EMITTER_ID_DEFAULT; - switch (this.flag) { - case getString($r('app.string.hash_map')): - eventId = Constant.EMITTER_ID_HASH_MAP; - break; - case getString($r('app.string.light_weight_map')): - eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_MAP; - break; - case getString($r('app.string.plain_array')): - eventId = Constant.EMITTER_ID_PLAIN_ARRAY; - break; - case getString($r('app.string.tree_map')): - eventId = Constant.EMITTER_ID_TREE_MAP; - break; - default: - eventId = Constant.EMITTER_ID_DEFAULT; - break; + const uIContext = this.getUIContext(); + if (this.flag == getString($r('app.string.hash_map'), uIContext)){ + eventId = Constant.EMITTER_ID_HASH_MAP; + } + if (this.flag == getString($r('app.string.light_weight_map'), uIContext)){ + eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_MAP; + } + if (this.flag == getString($r('app.string.plain_array'), uIContext)){ + eventId = Constant.EMITTER_ID_PLAIN_ARRAY; + } + if (this.flag == getString($r('app.string.tree_map'), uIContext)){ + eventId = Constant.EMITTER_ID_TREE_MAP; } - let event: emitter.InnerEvent = { eventId: eventId, priority: emitter.EventPriority.HIGH }; - let eventData: emitter.EventData = { data: { 'key': this.keyValuePair.key, 'value': this.keyValuePair.value - } + } as Record }; - emitter.emit(event, eventData); - getUIContext().getRouter.back(); + this.getUIContext().getRouter().back(); }) } .width('100%') - .height(56) + .height(56.0) Row() { Text('Key') - .width(44) - .margin({ left: 19 }) - .fontSize(16) + .width(44.0) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { TextInput({ placeholder: $r('app.string.input_key') }) .id('add_key') - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onChange((value: string) => { + .onChange((value: string):void => { this.keyValuePair.key = value; }) } - .layoutWeight(1) - .margin({ left: 52, right: 16 }) + .layoutWeight(1.0) + .margin({ left: 52.0, right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) Row() { Text('Value') - .margin({ left: 19 }) - .fontSize(16) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { TextInput({ placeholder: $r('app.string.input_value') }) .id('add_value') - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onChange((value: string) => { + .onChange((value: string):void => { this.keyValuePair.value = value; }) } - .layoutWeight(1) - .margin({ left: 52, right: 16 }) + .layoutWeight(1.0) + .margin({ left: 52.0, right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) } .height('100%') .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - .padding({ left: 12, right: 12 }) + .padding({ left: 12.0, right: 12.0 } as Padding) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets index 1644470f908d4937200cb8c70c45ff8feea96136..cb8f904fb6854234a2c5e149a46f6d259f93ede3 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets @@ -15,42 +15,44 @@ */ import { - Entry, - Component, - State, - getUIContext, $r, + Blank, + ClickEvent, Column, - Row, + Component, + Entry, Image, ImageFit, + Margin, + Padding, + Row, + State, Text, - Blank, TextInput, + StorageLink } from '@kit.ArkUI'; - -import router from '@ohos.router'; import emitter from '@ohos.events.emitter'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; -import { Constant } from '@ohos/capabilities'; +import { getString } from 'common'; +import { Constant } from 'capabilities'; @Entry @Component export struct AddKeyValueView { @State value: string = '' @State title: string = ''; - @State flag: string = ''; + // @State flag: string = ''; + @StorageLink('selectedLabel') flag: string = ''; aboutToAppear() { - let tem: string = (getUIContext().getRouter.getParams() as Record)['title'] as string; - if (!tem) { - return; - } - this.flag = tem; + // let tem: string = (this.getUIContext().getRouter().getParams() as Record)['title'] as string; + // if (!tem) { + // return; + // } + // this.flag = tem; let regex: RegExp = new RegExp('.*(?=\\(|()'); - let matchArr: RegExpMatchArray | null = tem.match(regex); + let matchArr: RegExpMatchArray | null = this.flag.match(regex); if (matchArr !== null) { - this.title = `${getString($r('app.string.add'))}${matchArr[0]}`; + this.title = `${getString($r('app.string.add'), this.getUIContext())}${matchArr[0]}`; } } @@ -58,94 +60,87 @@ export struct AddKeyValueView { Column() { Row() { Row() { - Image($r("app.media.ic_public_back")) - .height(24) - .aspectRatio(1) + Image($r("app.media.ic_public_add")) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .height('100%') - .aspectRatio(1) - .padding({ left: 24 }) - .onClick(() => { - getUIContext().getRouter.back(); + .aspectRatio(1.0) + .padding({ left: 24.0 } as Padding) + .onClick((event: ClickEvent) => { + this.getUIContext().getRouter().back(); }) Text(this.title) .fontColor($r('app.color.text_color_primary')) - .fontSize(20) - .margin({ left: 24 }) + .fontSize(20.0) + .margin({ left: 24.0 } as Margin) Blank() Row() { - Image($r("app.media.ic_public_confirm")) - .height(24) - .aspectRatio(1) + Image($r("app.media.contact")) + .height(24.0) + .aspectRatio(1.0) .objectFit(ImageFit.Contain) } .id('add_confirm') .height('100%') - .aspectRatio(1) - .padding({ right: 24 }) - .onClick(() => { + .aspectRatio(1.0) + .padding({ right: 24.0 } as Padding) + .onClick((e: ClickEvent) => { let eventId = Constant.EMITTER_ID_DEFAULT; - switch (this.flag) { - case getString($r('app.string.hash_set')): - eventId = Constant.EMITTER_ID_HASH_SET; - break; - case getString($r('app.string.light_weight_set')): - eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_SET; - break; - case getString($r('app.string.tree_set')): - eventId = Constant.EMITTER_ID_TREE_SET; - break; - default: - eventId = Constant.EMITTER_ID_DEFAULT; - break; + const uIContext = this.getUIContext(); + if (this.flag == getString($r('app.string.hash_set'), uIContext)){ + eventId = Constant.EMITTER_ID_HASH_SET; + } + if (this.flag == getString($r('app.string.light_weight_set'), uIContext)){ + eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_SET; + } + if (this.flag == getString($r('app.string.tree_set'), uIContext)){ + eventId = Constant.EMITTER_ID_TREE_SET; } - let event: emitter.InnerEvent = { eventId: eventId, priority: emitter.EventPriority.HIGH }; - let eventData: emitter.EventData = { - data: { 'value': this.value } + data: { 'value': this.value } as Record }; - emitter.emit(event, eventData); - getUIContext().getRouter.back(); + this.getUIContext().getRouter().back(); }) } .width('100%') - .height(56) + .height(56.0) Row() { Text('Value') - .margin({ left: 19 }) - .fontSize(16) + .margin({ left: 19.0 } as Margin) + .fontSize(16.0) .fontColor($r('app.color.text_color_primary')) Column() { TextInput({ placeholder: $r('app.string.input_value') }) .id('add_value') - .height(48) - .fontSize(16) + .height(48.0) + .fontSize(16.0) .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) - .onChange((value: string) => { + .onChange((value: string): void => { this.value = value; }) } - .layoutWeight(1) - .margin({ left: 52, right: 16 }) + .layoutWeight(1.0) + .margin({ left: 52.0, right: 16.0 } as Margin) } - .height(64) + .height(64.0) .width('100%') - .borderRadius(16) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) } .height('100%') .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - .padding({ left: 12, right: 12 }) + .padding({ left: 12.0, right: 12.0 } as Padding) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets index 02fa8f50b162b2b81de8bad7a4d30cf2c3c5c6a8..173500248190af8dd9e589ff64338c623646d90e 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets @@ -14,30 +14,26 @@ * limitations under the License. */ -import { StoragePropRef } from '@kit.ArkUI'; - import { Entry, Component, - State, - getUIContext, $r, Navigation, Divider, NavigationMode, - Stack, + NavPathStack, NavigationTitleMode, Builder, Row, Text, FontWeight, + StoragePropRef, + AppStorage, } from '@kit.ArkUI'; - -import router from '@ohos.router'; import { Capabilities } from './components/Capabilities'; -import { MenuList } from '@ohos/menuitems'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { Util } from 'capabilities'; +import { MenuList } from 'menuitems' +import { getString } from 'common'; const TAG: string = 'Index'; @@ -46,59 +42,85 @@ const TAG: string = 'Index'; struct Index { @StoragePropRef('windowWidth') windowWidth: number = 300; @StoragePropRef('isSplitMode') isSplitMode: boolean = false; - @State title: string = ''; + private title: string = ''; + pageStack: NavPathStack = new NavPathStack() aboutToAppear() { - this.title = getUIContext().getHostContext().resourceManager.getStringSync($r('app.string.lable_name').id.toLong()); + this.title = getString($r('app.string.lable_name'), this.getUIContext()) + AppStorage.setOrCreate('PathStack', this.pageStack); } + // addAction(title: string) { + // logger.info(TAG, `addAction: title = ${title}`) + // const uIContext = this.getUIContext() + // switch (title) { + // case getString($r('app.string.deque'), uIContext): + // case getString($r('app.string.linked_list'), uIContext): + // case getString($r('app.string.list'), uIContext): + // case getString($r('app.string.queue'), uIContext): + // case getString($r('app.string.stack'), uIContext): + // // case getString($r('app.string.vector'), uIContext): + // uIContext.getRouter().pushUrl({ + // url: 'pages/AddInformationView', + // params: { 'title': title } as Record + // }) + // break; + // case getString($r('app.string.plain_array'), uIContext): + // case getString($r('app.string.hash_map'), uIContext): + // case getString($r('app.string.light_weight_map'), uIContext): + // case getString($r('app.string.tree_map'), uIContext): + // uIContext.getRouter().pushUrl({ + // url: 'pages/AddKeyValuePairView', + // params: { 'title': title } as Record + // }) + // break; + // case getString($r('app.string.hash_set'), uIContext): + // case getString($r('app.string.light_weight_set'), uIContext): + // case getString($r('app.string.tree_set'), uIContext): + // uIContext.getRouter().pushUrl({ + // url: 'pages/AddStringView', + // params: { 'title': title } as Record + // }) + // break; + // } + // } + build() { - Navigation() { + Navigation(this.pageStack) { Divider() .strokeWidth('1px') .color($r('sys.color.ohos_id_color_list_separator')) + MenuList({ menuList: $r('app.strarray.language_base_class_library_list'), - addAction: (title: string) => { - logger.info(TAG, `addAction: title = ${title}`) - switch (title) { - case getString($r('app.string.deque')): - case getString($r('app.string.linked_list')): - case getString($r('app.string.list')): - case getString($r('app.string.queue')): - case getString($r('app.string.stack')): - case getString($r('app.string.vector')): - getUIContext().getRouter.pushUrl({ url: 'pages/AddInformationView', params: { 'title': title } }) - break; - case getString($r('app.string.hash_map')): - case getString($r('app.string.light_weight_map')): - case getString($r('app.string.plain_array')): - case getString($r('app.string.tree_map')): - getUIContext().getRouter.pushUrl({ url: 'pages/AddKeyValuePairView', params: { 'title': title } }) - break; - case getString($r('app.string.hash_set')): - case getString($r('app.string.light_weight_set')): - case getString($r('app.string.tree_set')): - getUIContext().getRouter.pushUrl({ url: 'pages/AddStringView', params: { 'title': title } }) - break; - } - } - }) { - Capabilities() - } + // addAction: this.addAction, + // childNavDestination: () => { + // Capabilities() + // } + }) } + .navDestination(this.NavRouter) .title(() => { this.CustomTitle() }) .mode(this.isSplitMode ? NavigationMode.Split : NavigationMode.Stack) .navBarWidth(0.4 * this.windowWidth) .titleMode(NavigationTitleMode.Mini) - .hideToolBar(true) + .hideToolBar(true, false) .width('100%') .height('100%') .backgroundColor($r("sys.color.ohos_id_color_sub_background")) } + @Builder + NavRouter(name: string, param?: Object) { + if (name == 'Capabilities') { + Capabilities() + } else if (name == 'Util') { + Util() + } + } + @Builder CustomTitle() { Row() { diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets index cdef18a4016a8588eda6d269e3a02d312ed89744..4480195870140ca3792a857570b8f2a137cbcd4f 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets @@ -15,19 +15,31 @@ */ import { + $r, + Row, + Text, + Image, + ImageFit, + Visibility, + FontWeight, + FlexAlign, Component, StorageLink, Column, Divider, - $r, + Padding, + NavDestination, + UIContext, + Builder, + ClickEvent } from '@kit.ArkUI'; - -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { MenuList } from 'menuitems' +import { logger, getString } from 'common'; import { ArrayListView, ConvertXml, Url, - Util, + // Util, ProcessMessage, TaskPool, DequeView, @@ -42,79 +54,166 @@ import { StackView, TreeMapView, TreeSetView, - VectorView -} from '@ohos/capabilities'; + // VectorView +} from 'capabilities'; + +const TAG: string = 'Capabilities'; @Component export struct Capabilities { @StorageLink('selectedLabel') selectedLabel: string = ''; + private type: string = ''; + + @Builder + Capabilities() { + // 此处根据选中的菜单,显示对应的页面内容 + const uIContext = this.getUIContext() + if (this.selectedLabel === getString($r('app.string.xml'), uIContext)) { + ConvertXml() + } + if (this.selectedLabel === getString($r('app.string.process'), uIContext)) { + ProcessMessage() + } + if (this.selectedLabel === getString($r('app.string.url'), uIContext)) { + Url() + } + if (this.selectedLabel === getString($r('app.string.array_list'), uIContext)) { + ArrayListView() + } + if (this.selectedLabel === getString($r('app.string.task_pool'), uIContext)) { + TaskPool() + } + if (this.selectedLabel === getString($r('app.string.deque'), uIContext)) { + DequeView() + this.type = 'Information' + } + if (this.selectedLabel === getString($r('app.string.hash_map'), uIContext)) { + HashMapView() + this.type = 'KeyValuePair' + } + if (this.selectedLabel === getString($r('app.string.hash_set'), uIContext)) { + HashSetView() + this.type = 'String' + } + if (this.selectedLabel === getString($r('app.string.light_weight_map'), uIContext)) { + LightWeightMapView() + this.type = 'KeyValuePair' + } + if (this.selectedLabel === getString($r('app.string.light_weight_set'), uIContext)) { + LightWeightSetView() + this.type = 'String' + } + if (this.selectedLabel === getString($r('app.string.linked_list'), uIContext)) { + LinkedListView() + this.type = 'Information' + } + if (this.selectedLabel === getString($r('app.string.list'), uIContext)) { + ListView() + this.type = 'Information' + } + if (this.selectedLabel === getString($r('app.string.plain_array'), uIContext)) { + PlainArrayView() + this.type = 'KeyValuePair' + } + if (this.selectedLabel === getString($r('app.string.queue'), uIContext)) { + QueueView() + this.type = 'Information' + } + if (this.selectedLabel === getString($r('app.string.stack'), uIContext)) { + StackView() + this.type = 'Information' + } + if (this.selectedLabel === getString($r('app.string.tree_map'), uIContext)) { + TreeMapView() + this.type = 'KeyValuePair' + } + if (this.selectedLabel === getString($r('app.string.tree_set'), uIContext)) { + TreeSetView() + this.type = 'String' + } + // if (this.selectedLabel === getString($r('app.string.vector'), uIContext)) { + // VectorView() + // } + } build() { - Column() { + NavDestination() { Divider() .strokeWidth('1px') .color($r('sys.color.ohos_id_color_list_separator')) + + if (this.selectedLabel === getString($r('app.string.util'), this.getUIContext())) { + MenuList({ + menuList: $r('app.strarray.util_menu'), + isSecond: true + }) + } Column() { - // 此处根据选中的菜单,显示对应的页面内容 - if (this.selectedLabel === getString($r('app.string.xml'))) { - ConvertXml() - } - if (this.selectedLabel === getString($r('app.string.util'))) { - Util() - } - if (this.selectedLabel === getString($r('app.string.process'))) { - ProcessMessage() - } - if (this.selectedLabel === getString($r('app.string.url'))) { - Url() - } - if (this.selectedLabel === getString($r('app.string.array_list'))) { - ArrayListView() - } - if (this.selectedLabel === getString($r('app.string.task_pool'))) { - TaskPool() - } - if (this.selectedLabel === getString($r('app.string.deque'))) { - DequeView() - } - if (this.selectedLabel === getString($r('app.string.hash_map'))) { - HashMapView() - } - if (this.selectedLabel === getString($r('app.string.hash_set'))) { - HashSetView() - } - if (this.selectedLabel === getString($r('app.string.light_weight_map'))) { - LightWeightMapView() - } - if (this.selectedLabel === getString($r('app.string.light_weight_set'))) { - LightWeightSetView() - } - if (this.selectedLabel === getString($r('app.string.linked_list'))) { - LinkedListView() - } - if (this.selectedLabel === getString($r('app.string.list'))) { - ListView() - } - if (this.selectedLabel === getString($r('app.string.plain_array'))) { - PlainArrayView() - } - if (this.selectedLabel === getString($r('app.string.queue'))) { - QueueView() - } - if (this.selectedLabel === getString($r('app.string.stack'))) { - StackView() - } - if (this.selectedLabel === getString($r('app.string.tree_map'))) { - TreeMapView() - } - if (this.selectedLabel === getString($r('app.string.tree_set'))) { - TreeSetView() - } - if (this.selectedLabel === getString($r('app.string.vector'))) { - VectorView() - } + this.Capabilities() } - .padding({ left: 12, right: 12 }) + .height('100%') + .padding({ left: 12.0, right: 12.0 }as Padding) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + .title(() => { + this.CustomTitle(this.selectedLabel) + }, {backgroundColor: $r("sys.color.ohos_id_color_sub_background")}) + .width('100%') + .height('100%') + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + } + + @Builder + CustomTitle(title: string) { + Row() { + Text(title) + .fontColor($r('app.color.black')) + .fontSize(16.0) + .fontWeight(FontWeight.Bold) + + Row() { + Image($r('app.media.ic_public_add')) + .height(24.0) + .aspectRatio(1.0) + .objectFit(ImageFit.Contain) + } + .id('add') + .height('100%') + .aspectRatio(1.0) + .visibility(this.type !== '' ? Visibility.Visible : Visibility.None) + .onClick((e: ClickEvent) => { + if (this.type !== '') { + logger.info(TAG, 'addAction') + this.addAction(title, this.type) + } + }) + } + .width('85%') + .height(56.0) + .justifyContent(FlexAlign.SpaceBetween) + } + + addAction(title: string, type: string): void { + logger.info(TAG, `addAction: title = ${title}`) + const uIContext = this.getUIContext() + switch (type) { + case 'Information': + uIContext.getRouter().pushUrl({ + url: 'pages/AddInformationView', + }) + break; + case 'KeyValuePair': + uIContext.getRouter().pushUrl({ + url: 'pages/AddKeyValuePairView', + // params: { 'title': title } as Record + }) + break; + case 'String': + uIContext.getRouter().pushUrl({ + url: 'pages/AddStringView', + // params: { 'title': title } as Record + }) + break; } } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 index 7d12c705277fc6c991239661dc30f9695f6c2d66..a352ef2b5a71ed69856f79a632c3cc57fffb1302 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,8 +20,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "default", - "tablet" + "default" ], "deliveryWithInstall": true, "installationFree": false, @@ -29,20 +28,20 @@ "abilities": [ { "name": "EntryAbility", - "srcEntrance": "./ets/entryability/EntryAbility.ets", + "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:lable_name", - "startWindowIcon": "$media:icon", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", - "visible": true, + "exported": true, "skills": [ { "entities": [ "entity.system.home" ], "actions": [ - "action.system.home" + "ohos.want.action.home" ] } ] diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/float.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json index 6f294c6c424ba0e2b8491fe60cd1439003530752..d1388be24c7320f617bf5e6f9d0fcb457d390e61 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json @@ -3,7 +3,6 @@ { "name": "language_base_class_library_list", "value": [ - { "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" }, @@ -57,9 +56,6 @@ }, { "value": "TreeSet (Nonlinear Container TreeSet)" - }, - { - "value": "Vector (Linear Container Vector)" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json index 3bcb2fe11547eed4598db7116fa8254f51ff01cb..765600ffc073882cbe7334226908121f202845e3 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json @@ -8,6 +8,10 @@ "name": "EntryAbility_desc", "value": "description" }, + { + "name": "EntryAbility_label", + "value": "label" + }, { "name": "lable_name", "value": "LanguageBaseClassLibrary" diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/background.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/background.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/foreground.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/foreground.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/layered_image.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/startIcon.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/startIcon.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json index 3de427eaa714dc55d3030120bc850c2b4a63b310..1898d94f58d6128ab712be2c68acc7c98e9ab9ce 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json @@ -1,8 +1,5 @@ { "src": [ - "pages/Index", - "pages/AddInformationView", - "pages/AddKeyValuePairView", - "pages/AddStringView" + "pages/Index" ] -} \ No newline at end of file +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/dark/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json index 6f294c6c424ba0e2b8491fe60cd1439003530752..9b5196bffef186b25bdf00f53fe4d6cd0f1b9d96 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json @@ -57,9 +57,6 @@ }, { "value": "TreeSet (Nonlinear Container TreeSet)" - }, - { - "value": "Vector (Linear Container Vector)" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json index c0e7094d86a455daaaee82a2cf42564c640c62fa..9a1a9227a38015b4702f7f0e2b2024ed00961ec1 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json @@ -3,7 +3,6 @@ { "name": "language_base_class_library_list", "value": [ - { "value": "Xml & ConvertXml (XML解析,生成与转换)" }, @@ -57,9 +56,6 @@ }, { "value": "TreeSet (非线性容器TreeSet)" - }, - { - "value": "Vector (线性容器Vector)" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets index 240281c6eed4878238dde5054ef16eae5fb05101..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,874 +13,38 @@ * limitations under the License. */ -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import { describe, it, expect } from '@ohos/hypium'; -import { Driver, ON, MatchPattern } from '@ohos.UiTest'; -import { logger } from '../util/Logger'; -import Want from '@ohos.app.ability.Want'; - -const TAG: string = 'Sample_LanguageBaseClassLibraryTest'; -const BUNDLE = 'LanguageBaseClassLibrary'; -const delegator = AbilityDelegatorRegistry.getAbilityDelegator() -const driver: Driver = Driver.create(); - -// 资源本地化 -async function getResourceString(resource: Resource): Promise { - let manage = delegator.getAppContext().resourceManager - let text = await manage.getStringValue(resource) - return text -} - -async function addContact(driver: Driver, name: string, phone: string) { - // 进入新增联系人 - await driver.assertComponentExist(ON.id('add')); - let addBtn = await driver.findComponent(ON.id('add')); - await addBtn.click(); - await driver.delayMs(200); - // 点击姓名输入框 - await driver.assertComponentExist(ON.id('add_name')); - let addNameTextInput = await driver.findComponent(ON.id('add_name')); - await addNameTextInput.inputText(name); - await driver.delayMs(200); - // 点击年龄输入框 - await driver.assertComponentExist(ON.id('add_age')); - let addAgeComponent = await driver.findComponent(ON.id('add_age')); - await addAgeComponent.click(); - await driver.delayMs(200); - // 点击确定按钮 - await driver.assertComponentExist(ON.id('add_sure')); - let addSureBtn = await driver.findComponent(ON.id('add_sure')); - await addSureBtn.click(); - await driver.delayMs(200); - // 点击电话输入框 - await driver.assertComponentExist(ON.id('add_phone')); - let addPhoneTextInput = await driver.findComponent(ON.id('add_phone')); - await addPhoneTextInput.inputText(phone); - await driver.delayMs(200); - // 点击完成按钮 - await driver.assertComponentExist(ON.id('add_confirm')); - let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); - await addConfirmBtn.click(); - await driver.delayMs(200); -} - -async function deleteItem(driver: Driver, id: string) { - await driver.assertComponentExist(ON.id(id)); - let deleteBtn = await driver.findComponent(ON.id(id)); - await deleteBtn.click(); - await driver.delayMs(200); -} - -async function addKeyValue(driver: Driver, key: string, value: string) { - // 进入新增Key/Value - await driver.assertComponentExist(ON.id('add')); - let addBtn = await driver.findComponent(ON.id('add')); - await addBtn.click(); - await driver.delayMs(200); - // 点击Key输入框 - await driver.assertComponentExist(ON.id('add_key')); - let addKeyTextInput = await driver.findComponent(ON.id('add_key')); - await addKeyTextInput.inputText(key); - await driver.delayMs(200); - // 点击Value输入框 - await driver.assertComponentExist(ON.id('add_value')); - let addValueTextInput = await driver.findComponent(ON.id('add_value')); - await addValueTextInput.inputText(value); - await driver.delayMs(200); - // 点击完成按钮 - await driver.assertComponentExist(ON.id('add_confirm')); - let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); - await addConfirmBtn.click(); - await driver.delayMs(200); -} - -async function addValue(driver: Driver, value: string) { - // 进入新增Value - await driver.assertComponentExist(ON.id('add')); - let addBtn = await driver.findComponent(ON.id('add')); - await addBtn.click(); - await driver.delayMs(200); - // 点击Value输入框 - await driver.assertComponentExist(ON.id('add_value')); - let addValueTextInput = await driver.findComponent(ON.id('add_value')); - await addValueTextInput.inputText(value); - await driver.delayMs(200); - // 点击完成按钮 - await driver.assertComponentExist(ON.id('add_confirm')); - let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); - await addConfirmBtn.click(); - await driver.delayMs(200); -} +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function abilityTest() { describe('ActsAbilityTest', () => { - // 打开应用 - it(BUNDLE + 'StartAbility_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}StartAbility_001 begin`); - let want: Want = { - bundleName: 'com.samples.languagebaseclasslibrary', - abilityName: 'EntryAbility' - }; - delegator.startAbility(want, (err) => { - logger.info(TAG, `${BUNDLE}_startAbility end err ${JSON.stringify(err)}`); - }) - await driver.delayMs(1000); - logger.info(TAG, `${BUNDLE}StartAbility_001 end`); - done(); - }) - - // 进入xml解析、生成与转换页面 - it(BUNDLE + 'Xml_ConvertXml_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}Xml_ConvertXml_001 begin`); - await driver.delayMs(200); - // find component on text 'Xml' - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.xml')))); - let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.xml')))); - await button.click(); - await driver.delayMs(200); - // 点击Xml生成 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.serializer')), MatchPattern.CONTAINS)); - let serializer = await driver.findComponent(ON.text(await getResourceString($r('app.string.serializer')), MatchPattern.CONTAINS)); - await serializer.click(); - await driver.delayMs(1000); - logger.info(TAG, BUNDLE + 'ClickXmlFunction_001 clickParserXml'); - // 点击Xml解析 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.parser')), MatchPattern.CONTAINS)); - let parser = await driver.findComponent(ON.text(await getResourceString($r('app.string.parser')), MatchPattern.CONTAINS)); - await parser.click(); - await driver.delayMs(1000); - logger.info(TAG, BUNDLE + 'ClickXmlFunction_001 clickConvertXml'); - // 点击Xml转换 - let convert = await driver.findComponent(ON.text(await getResourceString($r('app.string.convert')), MatchPattern.CONTAINS)); - await convert.click(); - await driver.delayMs(1000); - // 校验是否进入对应页面 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.xml')))); - await driver.delayMs(200); - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE}Xml_ConvertXml_001 end`); - }) - - // 进入Util界面 - it(BUNDLE + 'util_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}util_001 begin`); - await driver.delayMs(200); - // check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.util')))); - let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.util')))); - await button.click(); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}util_001 end`); - }) - - // StringCode(字符串编码) - it(BUNDLE + 'StringCodeFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} StringCodeFunction_001 begin`); - await driver.delayMs(200); - // 进入字符串编解码界面 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.string_code')))); - let strBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.string_code')))); - await strBtn.click(); - await driver.delayMs(200); - // 点击特定格式输出 - await driver.assertComponentExist(ON.id('specFormatOutput')); - let specOutputBtn = await driver.findComponent(ON.id('specFormatOutput')); - await specOutputBtn.click(); - await driver.delayMs(200); - // 点击文本编码器 - await driver.assertComponentExist(ON.id('textEncoder')); - let textEncoderBtn = await driver.findComponent(ON.id('textEncoder')); - await textEncoderBtn.click(); - await driver.delayMs(200); - // 判断读取信息是否正确 - await driver.assertComponentExist(ON.id('read')); - let readInfo = await driver.findComponent(ON.id('read')); - let readValue = await readInfo.getText(); - logger.info(TAG, `${BUNDLE}clickTextEncoderFunction_001 readValue:${readValue}`); - expect(readValue).assertEqual('23'); - // 判断写入信息是否正确 - await driver.assertComponentExist(ON.id('write')); - let writeInfo = await driver.findComponent(ON.id('write')); - let writeValue = await writeInfo.getText(); - logger.info(TAG, `${BUNDLE}clickTextEncoderFunction_001 writeValue:${writeValue}`); - expect(writeValue).assertEqual('39'); - // 点击文本译码器 - await driver.assertComponentExist(ON.id('textDecoder')); - let textDecoderBtn = await driver.findComponent(ON.id('textDecoder')); - await textDecoderBtn.click(); - await driver.delayMs(200); - // 获取译码文本,判断是否是原字符串 - await driver.assertComponentExist(ON.id('decRes')); - let decRes = await driver.findComponent(ON.id('decRes')); - let decodeValue = await decRes.getText(); - expect(decodeValue).assertContain('OpenHarmony 3.0'); - // 返回首页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} StringCodeFunction_001 end`); - }) - - // RationalNumber(有理数) - it(BUNDLE + 'RationalNumber_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}RationalNumber_001 begin`); - await driver.delayMs(200); - // 进入有理数界面 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number')))); - let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.rational_number')))); - await button.click(); - await driver.delayMs(200); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.compare')))); - let compare = await driver.findComponent(ON.text(await getResourceString($r('app.string.compare')))); - await compare.click(); - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.less_than')))); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get')))); - let getValue = await driver.findComponent(ON.text(await getResourceString($r('app.string.get')))); - await getValue.click(); - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_value')), MatchPattern.CONTAINS)); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.getDenominator')))); - let operation0 = await driver.findComponent(ON.text(await getResourceString($r('app.string.getDenominator')))); - await operation0.click(); - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.numerator')), MatchPattern.CONTAINS)); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isZero')))); - let operation1 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isZero')))); - await operation1.click(); - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number_is')), MatchPattern.CONTAINS)); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isNaN')))); - let operation2 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isNaN')))); - await operation2.click(); - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number_is_not_nan')), MatchPattern.CONTAINS)); - - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isFinite')))); - let operation3 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isFinite')))); - await operation3.click(); - await driver.assertComponentExist(ON.text('Finite', MatchPattern.CONTAINS)); - - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE}RationalNumber_001 end`); - }) - - // 进入到LRUCache (缓冲区) - it(BUNDLE + 'UtilLruBuffer_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}UtilLruBuffer_001 begin`); - await driver.delayMs(200); - // find component on text 'LRUCache' - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.lru_cache')))); - let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.lru_cache')))); - await button.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击初始化缓冲区 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.initialize_buffer')))); - let initializeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.initialize_buffer')))); - await initializeBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击获取缓冲区容量 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_buffer_capacity')))); - let getBufferBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_buffer_capacity')))); - await getBufferBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击更新缓冲区容量 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.update_buffer_capacity')))); - let updateBufferBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.update_buffer_capacity')))); - await updateBufferBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击获取缓冲区字符串 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_buffer_string')))); - let getBufferCharacterBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_buffer_string')))); - await getBufferCharacterBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击添加键值对 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.add_key_value')))); - let addBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.add_key_value')))); - await addBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击获取键对应的值 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_value_with_key')))); - let getBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_value_with_key')))); - await getBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 关闭弹窗 - let getDialogBtn = await driver.findComponent(ON.type('Dialog')); - await getDialogBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击获取所有键值对 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_all_key_values')))); - let getAllBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_all_key_values')))); - await getAllBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击删除指定键及关联值 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.delete_key_and_value')))); - let deleteBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.delete_key_and_value')))); - await deleteBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 关闭弹窗 - let deleteDialogBtn = await driver.findComponent(ON.type('Dialog')); - await deleteDialogBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击清除所有键值对 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.clear_all_key_values')))); - let eliminateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.clear_all_key_values')))); - await eliminateBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); - // 点击查看操作记录 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.view_operation_record')))); - let operatingBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.view_operation_record')))); - await operatingBtn.click(); - await driver.delayMs(200); - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE}UtilLruBuffer_001 end`); - }) - - // Base64Helper (Base64编解码) - it(BUNDLE + 'UtilBase64Codec_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}UtilBase64Codec_001 begin`); - await driver.delayMs(200); - // 进入Base64编解码 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.base64')))); - let typeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.base64')))); - await typeBtn.click(); - await driver.delayMs(200); - // 点击编码 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.encode')))); - let codeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.encode')))); - await codeBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'UtilBase64Codec_001 clickCheckPresetValue'); - // 点击解码 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.decode')))); - let decodeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.decode')))); - await decodeBtn.click(); - await driver.delayMs(1000); - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE}UtilBase64Codec_001 begin`); - }) - - // TypeCheck (类型检查) - it(BUNDLE + 'TypeCheck_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}TypeCheck_001 begin`); - await driver.delayMs(200); - // 进入类型检查 - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.type_check')))); - let typeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.type_check')))); - await typeBtn.click(); - await driver.delayMs(1000); - // 点击显示预置值 - await driver.assertComponentExist(ON.id('displayPresetValue')); - let displayPresetValueBtn = await driver.findComponent(ON.id('displayPresetValue')); - await displayPresetValueBtn.click(); - await driver.delayMs(200); - logger.info(TAG, BUNDLE + 'TypeCheck_001 clickCheckPresetValue'); - // 点击校验预置值 - await driver.assertComponentExist(ON.id('checkPresetValue')); - let checkPresetValueBtn = await driver.findComponent(ON.id('checkPresetValue')); - await checkPresetValueBtn.click(); - await driver.delayMs(200); - await driver.pressBack(); - await driver.pressBack(); - await driver.delayMs(1000); - done(); - - logger.info(TAG, `${BUNDLE}TypeCheck_001 begin`) - }) - - // 进入Url字符串解析页面 - it(BUNDLE + 'Url_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}Url_001 begin`); - await driver.delayMs(500); - // find component on text 'Xml' - await driver.assertComponentExist(ON.text('Url (Url字符串解析)')); - let button = await driver.findComponent(ON.text('Url (Url字符串解析)')); - await button.click(); - await driver.delayMs(1000); - // check text - await driver.assertComponentExist(ON.text('Url (Url字符串解析)')); - await driver.delayMs(1000); - done() - logger.info(TAG, `${BUNDLE}Url_001 end`); - }) - - // Url字符串解析 - it(BUNDLE + 'ClickUrlStringBtnFunction_001', 0, async (done: Function) => { - logger.info(TAG, BUNDLE + 'ClickUrlStringBtnFunction_001 begin') - await driver.delayMs(1000) - // 点击插入键值对到查询字符串 - await driver.assertComponentExist(ON.id('item0')) - let insertKeyValuePairs = await driver.findComponent(ON.id('item0')) - await insertKeyValuePairs.click() - await driver.delayMs(500) - // 是否成功插入 - await driver.assertComponentExist(ON.id('output')) - let outputInsert = await driver.findComponent(ON.id('output')) - let insertValue = await outputInsert.getText() - await driver.delayMs(1000); - expect(insertValue).assertContain('node=nodeValue1') - // 点击删除键值对 - await driver.assertComponentExist(ON.id('item1')) - let deleteKeyValuePairs = await driver.findComponent(ON.id('item1')) - await deleteKeyValuePairs.click() - await driver.delayMs(500) - // 是否成功删除 - await driver.assertComponentExist(ON.id('output')) - let outputDelete = await driver.findComponent(ON.id('output')) - let deleteValue = await outputDelete.getText() - await driver.delayMs(1000); - expect(deleteValue).assertEqual('https://gitee.com/openharmony/'); - // 点击获取指定名称对应的第一个值 - await driver.assertComponentExist(ON.id('item0')) - let insertKeyValue = await driver.findComponent(ON.id('item0')) - await insertKeyValue.click() - await driver.delayMs(500) - await driver.assertComponentExist(ON.id('item2')) - let getFirstValue = await driver.findComponent(ON.id('item2')) - await getFirstValue.click() - await driver.delayMs(500) - // 是否成功获取 - await driver.assertComponentExist(ON.id('output')) - let outputGet = await driver.findComponent(ON.id('output')) - let getValue = await outputGet.getText() - await driver.delayMs(1000); - expect(getValue).assertContain('nodeValue1') - // 点击设置键的新值 - await driver.assertComponentExist(ON.id('item3')) - let setNewValue = await driver.findComponent(ON.id('item3')) - await setNewValue.click() - await driver.delayMs(500) - // 是否成功设置新值 - await driver.assertComponentExist(ON.id('output')) - let outputSet = await driver.findComponent(ON.id('output')) - let setValue = await outputSet.getText() - await driver.delayMs(1000); - expect(setValue).assertContain('newValue') - // 返回首页 - await driver.pressBack(); - done(); - logger.info(TAG, BUNDLE + 'ClickUrlStringBtnFunction_001 end') - }) - - // 进入TaskPool页面 - it(BUNDLE + 'TaskPool_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}TaskPool_001 begin`); - await driver.delayMs(200); - // 滚动到TaskPool - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - // find component on text 'TaskPool' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.task_pool')))); - await button.click(); - await driver.delayMs(200); - // 点击Execute task - await driver.assertComponentExist(ON.id('execute_task')); - let executeTask = await driver.findComponent(ON.id('execute_task')); - await executeTask.click(); - await driver.delayMs(1000); - logger.info(TAG, BUNDLE + 'ClickTaskPoolFunction_001 clickExecuteTask'); - // 点击Cancel task - await driver.assertComponentExist(ON.id('cancel_task')); - let parser = await driver.findComponent(ON.id('cancel_task')); - await parser.click(); - await driver.delayMs(1000); - logger.info(TAG, BUNDLE + 'ClickTaskPoolFunction_001 clickCancelTask'); - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE}TaskPool_001 end`); - }) - - // 进入Deque界面 - it(BUNDLE + 'deque_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}deque_001 begin`); - await driver.delayMs(200); - // 滚动到Deque - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'Deque' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.deque')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.deque')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}deque_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'DequeAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} DequeAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // 删除三条数据 - await deleteItem(driver, 'delete2'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} DequeAddFunction_001 end`); - }) - - // 进入HashMap界面 - it(BUNDLE + 'hash_map_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}hash_map_001 begin`); - await driver.delayMs(200); - // 滚动到HashMap - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'HashMap' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.hash_map')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.hash_map')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}hash_map_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'HashMapAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} HashMapAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addKeyValue(driver, '1', '1'); - await addKeyValue(driver, '2', '2'); - await addKeyValue(driver, '3', '3'); - // 删除三条数据 - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} HashMapAddFunction_001 end`); - }) - - // 进入HashSet界面 - it(BUNDLE + 'hash_set_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}hash_set_001 begin`); - await driver.delayMs(200); - // 滚动到HashSet - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'HashSet' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.hash_set')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.hash_set')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}hash_set_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'HashSetAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} HashSetAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addValue(driver, '1'); - await addValue(driver, '2'); - await addValue(driver, '3'); - // 删除三条数据 - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} HashSetAddFunction_001 end`); - }) - - // 进入LightWeightMap界面 - it(BUNDLE + 'light_weight_map_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}light_weight_map_001 begin`); - await driver.delayMs(200); - // 滚动到LightWeightMap - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'LightWeightMap' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.light_weight_map')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.light_weight_map')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}light_weight_map_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'LightWeightMapAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} LightWeightMapAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addKeyValue(driver, '1', '1'); - await addKeyValue(driver, '2', '2'); - await addKeyValue(driver, '3', '3'); - // 删除三条数据 - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} LightWeightMapAddFunction_001 end`); - }) - - // 进入LightWeightSet界面 - it(BUNDLE + 'light_weight_set_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}light_weight_set_001 begin`); - await driver.delayMs(200); - // 滚动到LightWeightSet - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'LightWeightSet' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.light_weight_set')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.light_weight_set')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}light_weight_set_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'LightWeightSetAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} LightWeightSetAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addValue(driver, '1'); - await addValue(driver, '2'); - await addValue(driver, '3'); - // 删除三条数据 - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} LightWeightSetAddFunction_001 end`); - }) - - // 进入LinkedList界面 - it(BUNDLE + 'linked_list_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE}linked_list_001 begin`); - await driver.delayMs(200); - // 滚动到LinkedList - await driver.assertComponentExist(ON.id('menu_list')); - let menuList = await driver.findComponent(ON.id('menu_list')); - //find component on text 'LinkedList' - let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.linked_list')))); - await button.click(); - await driver.delayMs(200); - //check text - await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.linked_list')))); - await driver.delayMs(200); - done(); - logger.info(TAG, `${BUNDLE}linked_list_001 end`); - }) - - // 新增数据 - it(BUNDLE + 'LinkedListAddFunction_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} LinkedListAddFunction_001 begin`); - await driver.delayMs(200); - // 添加三条数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // 删除三条数据 - await deleteItem(driver, 'delete2'); - await deleteItem(driver, 'delete0'); - await deleteItem(driver, 'delete0'); - // 返回上一页 - await driver.pressBack(); - done(); - logger.info(TAG, `${BUNDLE} LinkedListAddFunction_001 end`); - }) - - // 进入List页面 - it(BUNDLE + 'list_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} list_001 begin`); - await driver.delayMs(200); - //find component on text 'list' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.list')))); - await button.click() - await driver.delayMs(200); - // list添加数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // list删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} list_001 end`); - }) - - // 进入plain_array页面 - it(BUNDLE + 'plain_array_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} plain_array_001 begin`); - await driver.delayMs(200); - //find component on text 'plain_array' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.plain_array')))); - await button.click() - await driver.delayMs(200); - // PlainArray添加数据 - await addKeyValue(driver, '1', '1'); - await addKeyValue(driver, '2', '2'); - await addKeyValue(driver, '3', '3'); - // PlainArray删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} plain_array_001 end`); - }) - - // 进入queue页面 - it(BUNDLE + 'queue_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} queue_001 begin`); - await driver.delayMs(200); - //find component on text 'queue' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.queue')))); - await button.click() - await driver.delayMs(200); - // queue添加数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // queue删除数据 - await deleteItem(driver, 'delete0') - await deleteItem(driver, 'delete0') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} queue_001 end`); - }) - - // 进入stack页面 - it(BUNDLE + 'stack_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} stack_001 begin`); - await driver.delayMs(200); - // find component on text 'stack' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.stack')))); - await button.click() - await driver.delayMs(200); - // stack添加数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // stack删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} stack_001 end`); - }) - - // 进入tree_map页面 - it(BUNDLE + 'tree_map_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} tree_map_001 begin`); - await driver.delayMs(200); - //find component on text 'tree_map' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.tree_map')))); - await button.click() - await driver.delayMs(200); - // tree_map添加数据 - await addKeyValue(driver, '1', '1'); - await addKeyValue(driver, '2', '2'); - await addKeyValue(driver, '3', '3'); - // tree_map删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} tree_map_001 end`); - }) - - // 进入tree_set页面 - it(BUNDLE + 'tree_set_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} tree_set_001 begin`); - await driver.delayMs(200); - //find component on text 'tree_set' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.tree_set')))); - await button.click() - await driver.delayMs(200); - // tree_set添加数据 - await addValue(driver, '1'); - await addValue(driver, '2'); - await addValue(driver, '3'); - // tree_set删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} tree_set_001 end`); - }) - - // 进入vector页面 - it(BUNDLE + 'vector_001', 0, async (done: Function) => { - logger.info(TAG, `${BUNDLE} vector_001 begin`); - await driver.delayMs(200); - //find component on text 'vector' - let scrollBar = await driver.findComponent(ON.id('menu_list')); - let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.vector')))); - await button.click() - await driver.delayMs(200); - // vector添加数据 - await addContact(driver, '1', '1'); - await addContact(driver, '2', '2'); - await addContact(driver, '3', '3'); - // vector删除数据 - await deleteItem(driver, 'delete2') - await deleteItem(driver, 'delete1') - await deleteItem(driver, 'delete0') - await driver.pressBack(); - await driver.delayMs(3000); - done(); - logger.info(TAG, `${BUNDLE} vector_001 end`); + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); }) }) } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets index 657d194164f932396390ddb56c59cbd65c7d1259..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 index 22e2c611f379dbb0fddf452b259ef27c508d058b..02e02d6ac81afbc4dbd70353118a431e3dcbad98 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,36 +17,10 @@ "module": { "name": "entry_test", "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", "deviceTypes": [ - "default", - "tablet" + "default" ], "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] + "installationFree": false } -} +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore index 5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96..e2713a2779c5a3e0eb879efe6115455592caeea5 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore @@ -1,4 +1,6 @@ /node_modules +/oh_modules /.preview /build -/.cxx \ No newline at end of file +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 index 12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1..aefa5f6959f0e65b9347a5182401ee9f4873007a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,9 +17,30 @@ "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], "targets": [ { "name": "default" + }, + { + "name": "ohosTest" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/consumer-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts index 6522df25794b80abde0b0aa8654f3970c4a35cfa..8b916a32c526d654b0110abdb28f04e0bc874769 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,5 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file + +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets index 31eb8377d10574cbe72798997e653fefee8fbc49..63846dc138d0ede7dd9ac5833ef2f5ce47bb8683 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets @@ -1,3 +1,4 @@ +'use static' /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,10 +50,10 @@ export { TreeMapView } from './src/main/ets/capabilities/TreeMapView'; export { TreeSetView } from './src/main/ets/capabilities/TreeSetView'; -export { VectorView } from './src/main/ets/capabilities/VectorView'; +// export { VectorView } from './src/main/ets/capabilities/VectorView'; export { KeyValuePair } from './src/main/ets/model/KeyValuePair'; export { Information } from './src/main/ets/model/Information'; -export { Constant as Constant } from './src/main/ets/Constant'; +export { Constant } from './src/main/ets/Constant'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package-lock.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c985535d554316175fbffac99e78b93ff06c66b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package-lock.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "common@../../common": "common@../../common", + "menuitems@../menuitems": "menuitems@../menuitems" + }, + "packages": { + "common@../../common": { + "name": "common", + "version": "1.2.0", + "resolved": "", + "registryType": "local" + }, + "menuitems@../menuitems": { + "name": "menuitems", + "version": "1.2.0", + "resolved": "", + "registryType": "local", + "dependencies": { + "common": "file:../../common" + } + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 index 9fc812a73e677983097f75112620bb697d3f8015..87ca6b4133b9e29811f7cf44d7c192d79bcc28de 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,15 +14,14 @@ */ { - "license": "ISC", - "types": "", - "devDependencies": {}, "name": "capabilities", - "description": "a npm package which contains arkUI2.0 page", - "main": "index.ets", - "version": "1.0.0", + "version": "1.2.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", "dependencies": { - "@ohos/menuitems": "file:../menuitems", - "@ohos/common": "file:../../common" + "menuitems": "file:../menuitems", + "common": "file:../../common", } -} +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ets new file mode 100644 index 0000000000000000000000000000000000000000..680439ddda6020e4d6a7aada49fbdb8f25b32684 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use static' +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +export class Constant { + public static readonly EMITTER_ID_DEFAULT = 0x10000; + public static readonly EMITTER_ID_DEQUE = 0x10001; + public static readonly EMITTER_ID_HASH_MAP = 0x10002; + public static readonly EMITTER_ID_HASH_SET = 0x10003; + public static readonly EMITTER_ID_LIGHT_WEIGHT_MAP = 0x10004; + public static readonly EMITTER_ID_LIGHT_WEIGHT_SET = 0x10005; + public static readonly EMITTER_ID_LINKED_LIST = 0x10006; + public static readonly EMITTER_ID_LIST = 0x10007; + public static readonly EMITTER_ID_PLAIN_ARRAY = 0x10008; + public static readonly EMITTER_ID_QUEUE = 0x10009; + public static readonly EMITTER_ID_STACK = 0x10010; + public static readonly EMITTER_ID_TREE_MAP = 0x10011; + public static readonly EMITTER_ID_TREE_SET = 0x10012; + public static readonly EMITTER_ID_VECTOR = 0x10013; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets index 28f77f54f899ffc31133fbb4e2e5ed8342a4f44e..c1ea66435bc9783bcc8082cd5d2c6cf5b43fc453 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets @@ -15,7 +15,7 @@ */ import { - Preview, + // Preview, Component, State, CustomDialogController, @@ -25,27 +25,30 @@ import { Blank, Button, Image, - $r, ImageFit, Alignment, ButtonType, List, ForEach, ListItem, + $r, + Padding, + Margin, + ClickEvent, + ButtonOptions } from '@kit.ArkUI'; - import ArrayList from '@ohos.util.ArrayList'; import { AddDialog } from '../components/arraylistcomponents/AddDialog'; import { ArrayListItem } from '../components/arraylistcomponents/ArrayListItem'; import { Information } from '../model/Information'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { logger } from 'common'; const TAG: string = 'ArrayListView'; -@Preview +// @Preview @Component export struct ArrayListView { - @State dataSource: Information[] = []; + @State dataSource: Array = new Array(); private informations: ArrayList = new ArrayList(); private dialogController: CustomDialogController = new CustomDialogController({ builder: AddDialog({ @@ -63,40 +66,41 @@ export struct ArrayListView { Column() { Row() { Blank() - Button() { + + Button({} as ButtonOptions) { Image($r('app.media.ic_add')) - .height(35) + .height(35.0) .width('100%') .objectFit(ImageFit.Contain) .align(Alignment.End) } .key('addBtn') - .width(35) + .width(35.0) .type(ButtonType.Normal) .backgroundColor($r("app.color.button_bg")) .align(Alignment.End) - .onClick(() => { + .onClick((event: ClickEvent) => { this.dialogController.open(); logger.info(TAG, `enter the AddDialog`); }) } .width('100%') - List({ space: 12 }) { + List({ space: 12.0 }) { ForEach(this.dataSource, (item: Information, index: number) => { ListItem() { ArrayListItem({ information: item, index: index, handleOnClick: this.handleOnClick }) } }, (item: Information, index: number) => JSON.stringify(item) + index) } - .margin({ top: 10 }) + .margin({ top: 10.0 } as Margin) } .width('100%') .height('100%') } - handleOnClick = (index: int) => { - this.informations.removeByIndex(index); + handleOnClick(index: number) { + this.informations.removeByIndex(index as int); this.dataSource = this.informations.convertToArray(); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets index f55ad65199a48f215ff99a64e595bd138988f966..2756acff8a6123b35679025800f0cbc07f658dd9 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets @@ -21,9 +21,10 @@ import { Column, Text, Color, - $r, BarState, Alignment, + Margin, + $r, } from '@kit.ArkUI'; import { ColumnOperation } from '../components/ColumnOperation'; @@ -46,21 +47,21 @@ export struct ConvertXml { Text(this.output) .width('90%') .height('60%') - .fontSize(15) - .padding(10) - .margin({ left: 10, right: 10, top: 20, bottom: 10 }) - .border({ width: 2, radius: 5, color: Color.Gray }) + .fontSize(15.0) + .padding(10.0) + .margin({ left: 10.0, right: 10.0, top: 20.0, bottom: 10.0 } as Margin) + .border({ width: 2.0, radius: 5.0, color: Color.Gray }) ColumnOperation({ operationRes: $r('app.strarray.convert_xml_operations'), doOperation: this.doOperation }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) } - doOperation = (index: number) => { - switch (index) { + doOperation (index: number) { + switch (index as int) { case 0: this.output = serializerNode(); break; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets index 7f51bcbc09dd582d5abedb77fec847dd03b3621a..961bf87e3efc026cd2b518c044dc531cccd3971e 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets @@ -21,12 +21,17 @@ import { List, LazyForEach, ListItem, + Padding, + Margin, $r, + + Text } from '@kit.ArkUI'; +import { Callback } from '@kit.BasicServicesKit'; import emitter from "@ohos.events.emitter"; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { Information } from '../model/Information' import { InformationItemView } from '../components/InformationItemView'; import { DequeDataSource } from '../components/dequecomponents/DequeDataSource'; @@ -36,25 +41,39 @@ const TAG = 'DequeView'; @Component export struct DequeView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; private dataSource: DequeDataSource = new DequeDataSource(); aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_DEQUE }, (eventData) => { - let item = eventData.data as Information; - this.dataSource.insertFront(item); + emitter.on({ eventId: Constant.EMITTER_ID_DEQUE } as emitter.InnerEvent, (eventData: emitter.EventData) => { + // this.getUIContext().getPromptAction().showToast({ message: `${eventData.data}`, duration: 2000 }) + // console.info('1111111111'+JSON.stringify((eventData.data as Record)['name'])) + + let item = eventData.data as Record; + console.info('wzr'+JSON.stringify(item)) + const data: Information = new Information( + item['name'] as string, + item['age'] as number, + item['phone'] as string, + item['clickAble'] as boolean + ); + console.info('wzr'+JSON.stringify(data)) + this.dataSource.insertFront(data); + console.info('wzr'+`${this.dataSource.totalCount()}`) this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_DEQUE.toLong()); + emitter.off(Constant.EMITTER_ID_DEQUE); } build() { Column() { - if (this.totalCount != 0) { + if (this.totalCount != 0.0) { List() { + Text("11111") + LazyForEach(this.dataSource, (item: Information, index: number) => { ListItem() { InformationItemView({ @@ -62,24 +81,24 @@ export struct DequeView { information: item, deleteAction: () => { logger.info(TAG, `deleteAction: ${JSON.stringify(item)}`); - if (index === 0) { + if (index === 0.0) { this.dataSource.deleteFront(); this.totalCount = this.dataSource.totalCount(); - } else if (index === this.totalCount - 1) { + } else if (index === this.totalCount - 1.0) { this.dataSource.deleteEnd(); this.totalCount = this.dataSource.totalCount(); } } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: Information, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 } as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets index 70d6f32e96b921b73403aef64a142f302cb3cb01..c044743f046f1adea2712e40c383e9e5a91879da 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets @@ -21,13 +21,14 @@ import { List, LazyForEach, ListItem, - $r, + Padding, + $r } from '@kit.ArkUI'; import HashMap from '@ohos.util.HashMap'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { KeyValueItemView } from '../components/KeyValueItemView'; import { KeyValuePair } from '../model/KeyValuePair'; import { HashMapDataSource } from '../components/hashmapcomponents/HashMapDataSource'; @@ -37,13 +38,13 @@ const TAG = 'HashMapView'; @Component export struct HashMapView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; private hashMap: HashMap = new HashMap(); private dataSource: HashMapDataSource = new HashMapDataSource(); aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_HASH_MAP }, (eventData) => { - let item: KeyValuePair = eventData.data as KeyValuePair; + emitter.on({ eventId: Constant.EMITTER_ID_HASH_MAP } as emitter.InnerEvent, (eventData: emitter.EventData) => { + let item = (eventData.data as Record)['value'] as KeyValuePair; this.dataSource.addData(item); this.totalCount = this.dataSource.totalCount(); this.hashMap.set(item.key, item.value); @@ -51,13 +52,13 @@ export struct HashMapView { } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_HASH_MAP.toLong()); + emitter.off(Constant.EMITTER_ID_HASH_MAP); } build() { Column() { - if (this.totalCount != 0) { - List({ space: 12 }) { + if (this.totalCount != 0.0) { + List({ space: 12.0 }) { LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { ListItem() { KeyValueItemView({ @@ -71,13 +72,13 @@ export struct HashMapView { } }) } - .height(72) + .height(72.0) .width('100%') }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 } as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets index 970905a228513b4a45be2a10a55630cd94e62905..c4da39976b89dd8d364f73d8e13a54113fb36b18 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets @@ -21,13 +21,14 @@ import { List, LazyForEach, ListItem, - $r, + Padding, + $r } from '@kit.ArkUI'; import HashSet from '@ohos.util.HashSet'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { ValueItemView } from '../components/ValueItemView'; import { HashSetDataSource } from '../components/hashsetcomponents/HashSetDataSource'; import { Constant } from '../Constant'; @@ -36,16 +37,16 @@ const TAG = 'HashSetView' @Component export struct HashSetView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; private hashSet: HashSet = new HashSet(); private dataSource: HashSetDataSource = new HashSetDataSource(); aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_HASH_SET }, (eventData: emitter.EventData) => { + emitter.on({ eventId: Constant.EMITTER_ID_HASH_SET } as emitter.InnerEvent, (eventData: emitter.EventData) => { if (eventData.data === undefined) { return; } - let item: string = eventData.data.value; + let item = (eventData.data as Record)['value'] as string; this.dataSource.addData(item); this.totalCount = this.dataSource.totalCount(); this.hashSet.add(item); @@ -53,13 +54,13 @@ export struct HashSetView { } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_HASH_SET.toLong()); + emitter.off(Constant.EMITTER_ID_HASH_SET); } build() { Column() { - if (this.totalCount != 0) { - List({ space: 12 }) { + if (this.totalCount != 0.0) { + List({ space: 12.0 }) { LazyForEach(this.dataSource, (item: string, index: number) => { ListItem() { ValueItemView({ @@ -73,13 +74,13 @@ export struct HashSetView { } }) } - .height(72) + .height(72.0) .width('100%') }, (item: string, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 } as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets index 403792fb538621f8bfc9bc239a98a715804e742e..ec56b1fdf2b054e02f18e06d673e2ee5489cb2d6 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets @@ -21,13 +21,14 @@ import { List, LazyForEach, ListItem, + Padding, $r, } from '@kit.ArkUI'; import LightWeightMap from '@ohos.util.LightWeightMap'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { KeyValueItemView } from '../components/KeyValueItemView'; import { KeyValuePair } from '../model/KeyValuePair'; import { LightWeightMapDataSource } from '../components/lightweightmapcomponents/LightWeightMapDataSource'; @@ -37,13 +38,13 @@ const TAG = 'LightWeightMapView'; @Component export struct LightWeightMapView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; private lightWeightMap: LightWeightMap = new LightWeightMap(); private dataSource: LightWeightMapDataSource = new LightWeightMapDataSource(); aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_MAP }, (eventData) => { - let item: KeyValuePair = eventData.data as KeyValuePair; + emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_MAP } as emitter.InnerEvent, (eventData: emitter.EventData) => { + let item = (eventData.data as Record)['value'] as KeyValuePair; this.dataSource.addData(item); this.totalCount = this.dataSource.totalCount(); this.lightWeightMap.set(item.key, item.value); @@ -51,13 +52,13 @@ export struct LightWeightMapView { } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_MAP.toLong()); + emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_MAP); } build() { Column() { - if (this.totalCount != 0) { - List({ space: 12 }) { + if (this.totalCount != 0.0) { + List({ space: 12.0 }) { LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { ListItem() { KeyValueItemView({ @@ -71,13 +72,13 @@ export struct LightWeightMapView { } }) } - .height(72) + .height(72.0) .width('100%') }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 } as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets index fbff5515fe72afcdded332eff77262c63ac32ef3..f30b5b47965bd9440131d95521bebb4296f4c294 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets @@ -21,13 +21,14 @@ import { List, LazyForEach, ListItem, - $r, + Padding, + $r } from '@kit.ArkUI'; import LightWeightSet from '@ohos.util.LightWeightSet'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { ValueItemView } from '../components/ValueItemView'; import { LightWeightSetDataSource } from '../components/lightweightsetcomponents/LightWeightSetDataSource'; import { Constant } from '../Constant'; @@ -36,16 +37,16 @@ const TAG = 'LightWeightSetView'; @Component export struct LightWeightSetView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; @State lightWeightSet: LightWeightSet = new LightWeightSet(); private dataSource: LightWeightSetDataSource = new LightWeightSetDataSource(); aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_SET }, (eventData: emitter.EventData) => { + emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_SET } as emitter.InnerEvent, (eventData: emitter.EventData) => { if (eventData.data === undefined) { return; } - let item: string = eventData.data.value; + let item = (eventData.data as Record)['value'] as string; this.dataSource.addData(item); this.lightWeightSet.add(item); this.totalCount = this.dataSource.totalCount(); @@ -53,13 +54,13 @@ export struct LightWeightSetView { } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_SET.toLong()); + emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_SET); } build() { Column() { - if (this.totalCount != 0) { - List({ space: 12 }) { + if (this.totalCount != 0.0) { + List({ space: 12.0 }) { LazyForEach(this.dataSource, (item: string, index: number) => { ListItem() { ValueItemView({ @@ -73,13 +74,13 @@ export struct LightWeightSetView { } }) } - .height(72) + .height(72.0) .width('100%') }, (item: string, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 } as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets index d59efddcfb3821b91299d11d376bb2c9c4f09836..fa96a5f0188085d40d9e4603d7101e748fa5acdd 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets @@ -22,11 +22,14 @@ import { LazyForEach, ListItem, $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { EmptyPage } from 'common'; +import { logger } from 'common'; import { Information } from '../model/Information' import { InformationItemView } from '../components/InformationItemView'; import { LinkedListDataSource } from '../components/linkedlistcomponents/LinkedListDataSource' @@ -36,53 +39,54 @@ const TAG = 'LinkedListView' @Component export struct LinkedListView { - @State totalCount: number = 0; + @State totalCount: number = 0.0; private dataSource: LinkedListDataSource = new LinkedListDataSource(); + aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_LINKED_LIST }, (eventData) => { - let item = eventData.data as Information; + emitter.on({ eventId: Constant.EMITTER_ID_LINKED_LIST } as emitter.InnerEvent, (eventData: emitter.EventData) => { + let item = (eventData.data as Record)['value'] as Information; this.dataSource.addData(item); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_LINKED_LIST.toLong()); + emitter.off(Constant.EMITTER_ID_LINKED_LIST); } build() { Column() { - if (this.totalCount != 0) { + if (this.totalCount != 0.0) { List() { - LazyForEach(this.dataSource, (item: Information, index: number) => { + LazyForEach(this.dataSource, (item: Information, index: number):void => { + ListItem() { InformationItemView({ index: index, information: item, deleteAction: () => { logger.info(TAG, `deleteAction: ${JSON.stringify(item)}`); + if (index === 0) { this.dataSource.deleteFirst(); - this.totalCount = this.dataSource.totalCount(); } else if (index === this.totalCount - 1) { this.dataSource.deleteLast(); - this.totalCount = this.dataSource.totalCount(); } else { - this.dataSource.deleteData(index); - this.totalCount = this.dataSource.totalCount(); + this.dataSource.deleteData(index.toInt()); } + this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: Information, index: number) => JSON.stringify(item) + index) } .width('100%') .height('100%') - .padding({ top: 8, left: 12, right: 12 }) + .padding({ top: 8.0, left: 12.0, right: 12.0 }as Padding) } else { EmptyPage() } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets index fbe04c67a7d4507c90b23981746bb60547b8df0a..f6b7a4371b34b0bbc2f8c82a9dce2bf14731c976 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets @@ -23,16 +23,19 @@ import { LazyForEach, ListItem, $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { Information } from '../model/Information'; import { ListDateSource } from '../components/listcomponents/ListDataSource'; import { InformationItemView } from '../components/InformationItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH: int = 0; +const MIN_LENGTH: number = 0.0; @Entry @Component @@ -41,14 +44,14 @@ export struct ListView { @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_LIST }, (eventData) => { - this.dataSource.addData(eventData.data as Information); + emitter.on({ eventId: Constant.EMITTER_ID_LIST } as emitter.InnerEvent, (eventData: emitter.EventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as Information); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_LIST.toLong()); + emitter.off(Constant.EMITTER_ID_LIST); } build() { @@ -58,17 +61,17 @@ export struct ListView { LazyForEach(this.dataSource, (item: Information, index: number) => { ListItem() { InformationItemView({ index: index, information: item, deleteAction: () => { - this.dataSource.deleteData(index); + this.dataSource.deleteData(index.toInt()); this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: Information, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets index 76a093001297449b3154089e5085ccbfee02ccb8..4ed6e037881a8e9885d8112c0c20565c0eb9a5da 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets @@ -17,23 +17,26 @@ import { Component, State, - getUIContext, - $r, Column, List, LazyForEach, ListItem, + $r, + Padding, + Margin, + ClickEvent, + Observed, } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; import promptAction from '@ohos.promptAction'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { KeyValuePair } from '../model/KeyValuePair'; import { PlainArrayDataSource } from '../components/plainarraycomponents/PlainArrayDataSource'; import { KeyValueItemView } from '../components/KeyValueItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH: int = 0; +const MIN_LENGTH: number = 0.0; const isNaturalNumber = (str: string): boolean => { let regExp: RegExp = new RegExp('^\\d+$'); return regExp.test(str); @@ -41,23 +44,23 @@ const isNaturalNumber = (str: string): boolean => { @Component export struct PlainArrayView { - private dataSource: PlainArrayDataSource = new PlainArrayDataSource(); + @Observed dataSource: PlainArrayDataSource = new PlainArrayDataSource(); @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_PLAIN_ARRAY }, (eventData) => { - let data = eventData.data as KeyValuePair; + emitter.on({ eventId: Constant.EMITTER_ID_PLAIN_ARRAY } as emitter.InnerEvent, (eventData: emitter.EventData) => { + let data = (eventData.data as Record)['value'] as KeyValuePair; if (isNaturalNumber(data.key)) { - this.dataSource.addData(eventData.data as KeyValuePair); + this.dataSource.addData(data); this.totalCount = this.dataSource.totalCount(); } else { - getUIContext().getPromptAction.showToast({ message: $r('app.string.key_limit') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.key_limit') }); } }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_PLAIN_ARRAY.toLong()); + emitter.off(Constant.EMITTER_ID_PLAIN_ARRAY); } build() { @@ -67,17 +70,17 @@ export struct PlainArrayView { LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { ListItem() { KeyValueItemView({ index: index, keyValuePair: item, deleteAction: () => { - this.dataSource.deleteData(index); + this.dataSource.deleteData(index as int); this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets index ed53ea527740909c9e35eb88228d0ec539e337ad..b58486ec96a572e8d85f9f652f6e341bcc15bddf 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets @@ -21,21 +21,23 @@ import { Column, Text, TextAlign, - $r, BarState, Alignment, + $r, + Padding, + Margin, + StdProcess } from '@kit.ArkUI'; -import process from '@ohos.process'; -import { ColumnOperation } from '../components/ColumnOperation'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +// import { ColumnOperation } from '../components/ColumnOperation'; +import { getString } from 'common'; +import { logger } from 'common'; -let child: process.ChildProcess | undefined = undefined; +let child: StdProcess.ChildProcess | undefined = undefined; const TAG: string = 'Process'; @Component -export struct Process { +export struct ProcessView { @State result: string = ''; build() { @@ -43,63 +45,64 @@ export struct Process { Column() { Text(this.result) .width('100%') - .height(100) + .height(100.0) .backgroundColor('#DFDFDF') - .fontSize(20) - .margin({ top: 20 }) + .fontSize(20.0) + .margin({ top: 20.0 } as Margin) .textAlign(TextAlign.Start) - .padding(10) - ColumnOperation({ operationRes: $r('app.strarray.process_operations'), doOperation: this.doOperation }) + .padding(10.0) + // ColumnOperation({ operationRes: $r('app.strarray.process_operations'), doOperation: this.doOperation }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) } - doOperation = (index: number) => { - let proManager = new process.ProcessManager(); - switch (index) { + doOperation (index: number) { + let proManager = new StdProcess.ProcessManager(); + const uIContext = this.getUIContext(); + switch (index as int) { case 0: - this.result = process.uptime().toString() + 's'; + this.result = StdProcess.uptime().toString() + 's'; logger.info(TAG, 'uptime=' + this.result); break; case 1: logger.info(TAG, 'process cwd'); - this.result = process.cwd().toString(); + this.result = StdProcess.cwd().toString(); break; case 2: logger.info(TAG, 'process change dir'); - process.chdir('/system'); - this.result = process.cwd().toString(); + StdProcess.chdir('/system'); + this.result = StdProcess.cwd().toString(); break; case 3: - child = process.runCmd('sleep 2;ls'); + child = StdProcess.runCmd('sleep 2;ls'); this.result = child == null ? 'failed' : 'succeed'; logger.info(TAG, 'runCmd=' + this.result); - let childResult = child.wait(); - childResult.then(val => { + let childResult = child?.wait(); + childResult?.then(val => { this.result = 'child process run finish' + JSON.stringify(val); logger.info(TAG, 'runCmd result =' + val); }) break; case 4: if (child != null) { - this.result = getString($r('app.string.close_success')); - child.close(); + this.result = getString($r('app.string.close_success'), uIContext); + child?.close(); } else { - this.result = getString($r('app.string.child_null')); + this.result = getString($r('app.string.child_null'), uIContext); } logger.info(TAG, this.result); break; case 5: - let pres = process.pid; + let pres = StdProcess.pid(); let result = proManager.kill(28, pres); if (result === true) { - this.result = getString($r('app.string.success')); + this.result = getString($r('app.string.success'), uIContext); } else { - this.result = getString($r('app.string.failed')); + this.result = getString($r('app.string.failed'), uIContext); } break; case 6: diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets index deedf2c0bbf57bc45ae005e06b09db0a473be9d2..81587e3f4905bbd82bc523ff26422bf27f8dacb6 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets @@ -19,43 +19,45 @@ import { Column, Button, Text, - $r, Color, ButtonType, AppStorage, FlexAlign, HorizontalAlign, + $r, + ButtonOptions } from '@kit.ArkUI'; +import { common, Want } from '@kit.AbilityKit'; import { BusinessError } from '@ohos.base'; -import Want from '@ohos.app.ability.Want'; -import common from '@ohos.app.ability.common'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { logger } from 'common'; @Component export struct ProcessMessage { build() { Column() { - Button() { + Button({} as ButtonOptions) { Text($r('app.string.process')) - .fontSize(16) + .fontSize(16.0) .fontColor(Color.White) } .width('100%') - .height(50) + .height(50.0) .type(ButtonType.Capsule) .onClick(() => { - let context: common.UIAbilityContext | undefined = AppStorage.get('context'); + let context: common.UIAbilityContext | undefined = AppStorage.get('context'); let want: Want = { bundleName: "com.samples.process_message", abilityName: "EntryAbility", }; - context && context.startAbility(want, (err: BusinessError) => { - if (err.code) { - logger.error('StartAbility', `Failed to startAbility. Code: ${err.code}, message: ${err.message}`); - } - }); + if(context){ + context.startAbility(want, (err: BusinessError | null, data: undefined) => { + if (err && err.code) { + logger.error('StartAbility', `Failed to startAbility. Code: ${err.code}, message: ${err.message}`); + } + }); + } }) } .width('100%') diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets index ad8322ad858ddfd5cea5f10edf2ec9a96e6a88bc..0a7a200660a534cccc60d67f05e8e3a4b0359974 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets @@ -21,17 +21,18 @@ import { List, LazyForEach, ListItem, - $r, + Margin, + $r } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { Information } from '../model/Information'; import { QueueDataSource } from '../components/queuecomponents/QueueDataSource'; import { InformationItemView } from '../components/InformationItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH = 0; +const MIN_LENGTH: number = 0.0; @Component export struct QueueView { @@ -39,14 +40,14 @@ export struct QueueView { @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_QUEUE }, (eventData) => { - this.dataSource.addData(eventData.data as Information); + emitter.on({ eventId: Constant.EMITTER_ID_QUEUE } as emitter.InnerEvent, (eventData: emitter.EventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as Information); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_QUEUE.toLong()); + emitter.off(Constant.EMITTER_ID_QUEUE); } build() { @@ -60,13 +61,13 @@ export struct QueueView { this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: Information, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets index 1607c4b1bbf584b1eb0da14d03b55b499fc1e555..ef08c23de50977955229b785a272e84fe2360151 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets @@ -21,17 +21,18 @@ import { List, LazyForEach, ListItem, - $r, + Margin, + $r } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { Information } from '../model/Information'; import { StackDataSource } from '../components/stackcomponents/StackDataSource'; import { InformationItemView } from '../components/InformationItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH = 0; +const MIN_LENGTH: number = 0.0; @Component export struct StackView { @@ -39,14 +40,14 @@ export struct StackView { @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_STACK }, (eventData) => { - this.dataSource.addData(eventData.data as Information); + emitter.on({ eventId: Constant.EMITTER_ID_STACK } as emitter.InnerEvent, (eventData: emitter.EventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as Information); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_STACK.toLong()); + emitter.off(Constant.EMITTER_ID_STACK); } build() { @@ -64,13 +65,13 @@ export struct StackView { } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: Information, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets index 3ea228e3e8386731df8d59e9a20962c17f45c5c0..c8537e7290bde4dae05593025d369026a496d2c1 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets @@ -19,27 +19,29 @@ import { State, Column, Row, + RowOptions, Text, - $r, Blank, Button, ButtonType, FlexAlign, + $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; - -import router from '@ohos.router' +"use concurrent" function functionForTasks(numberOfExecutions: number) { - return numberOfExecutions + 1 } @Component export struct TaskPool { - @State numberOfExecutions: number = 0; - private isExecute = true; - private clickAble = true; + @State numberOfExecutions: number = 0.0; + private isExecute: boolean = true; + private clickAble: boolean = true; @State task: taskpool.Task | null = null; @State msg: string = 'task ready'; @@ -47,7 +49,7 @@ export struct TaskPool { Column() { Row() { Text($r('app.string.click_exec_add_one')) - .margin({ top: 22 }) + .margin({ top: 22.0 } as Margin) } .width('90%') @@ -68,37 +70,37 @@ export struct TaskPool { } .width('100%') } - .height(160) - .margin({ top: 12 }) - .padding(16) - .borderRadius(16) + .height(160.0) + .margin({ top: 12.0 } as Margin) + .padding(16.0) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) Blank() - .layoutWeight(1) + .layoutWeight(1.0) - Row({ space: 20 }) { + Row({ space: 20.0 } as RowOptions) { Button('Execute task') .id('execute_task') .type(ButtonType.Capsule) .width('45%') .fontColor($r('app.color.text_color_accent')) .backgroundColor($r('app.color.bg_btn_grey')) - .onClick(async () => { + .onClick((event: ClickEvent): void => { if (!this.clickAble) { return; } - for (let i: int = 0; i > -1; i++) { + for (let i: number = 0.0; i > -1.0; i++) { this.task = new taskpool.Task(functionForTasks, i); if (!this.isExecute) { this.isExecute = true; - taskpool.cancel(this.task); + taskpool.cancel(this.task as taskpool.Task); } else { this.clickAble = false; this.msg = 'task is running'; - await taskpool.execute(this.task) - .then((res: Object) => { - this.numberOfExecutions = Number(JSON.parse(JSON.stringify(res))); + await taskpool.execute(this.task as taskpool.Task) + .then((res) => { + this.numberOfExecutions = JSON.parse(JSON.stringify(res), DoubleType.VAL) as number }); } } @@ -110,7 +112,7 @@ export struct TaskPool { .width('45%') .fontColor($r('app.color.text_color_red')) .backgroundColor($r('app.color.bg_btn_grey')) - .onClick(() => { + .onClick((event: ClickEvent) => { if (!this.clickAble) { this.msg = 'task cancel'; this.clickAble = true; @@ -119,7 +121,7 @@ export struct TaskPool { }) } .width('100%') - .margin({ top: 12, bottom: 16 }) + .margin({ top: 12.0, bottom: 16.0 } as Margin) .justifyContent(FlexAlign.Center) } .width('100%') diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets index 845e68d8f7f8eeeb18a65513159935a213ff1e83..2dc9426be17c9b021c2034647c7dc7f06b4f5da1 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets @@ -22,16 +22,19 @@ import { LazyForEach, ListItem, $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { KeyValuePair } from '../model/KeyValuePair'; import { TreeMapDataSource } from '../components/treemapcomponents/TreeMapDataSource'; import { KeyValueItemView } from '../components/KeyValueItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH = 0; +const MIN_LENGTH: number = 0.0; @Component export struct TreeMapView { @@ -39,14 +42,14 @@ export struct TreeMapView { @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_TREE_MAP }, (eventData) => { - this.dataSource.addData(eventData.data as KeyValuePair); + emitter.on({ eventId: Constant.EMITTER_ID_TREE_MAP } as emitter.InnerEvent, (eventData: emitter.EventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as KeyValuePair); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_TREE_MAP.toLong()); + emitter.off(Constant.EMITTER_ID_TREE_MAP); } build() { @@ -60,13 +63,13 @@ export struct TreeMapView { this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets index 60132460d278c0dea1a3f2c5d28634056565e8f9..051cd31048d412342d9f830c66476e6bf297f51b 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets @@ -22,16 +22,19 @@ import { LazyForEach, ListItem, $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { EmptyPage } from 'common'; import { TreeSetDataSource } from '../components/treesetcomponents/TreeSetDataSource'; import { ValueItemView } from '../components/ValueItemView'; import { Constant } from '../Constant'; -const MIN_LENGTH = 0; +const MIN_LENGTH: number = 0.0; @Component export struct TreeSetView { @@ -39,14 +42,14 @@ export struct TreeSetView { @State totalCount: number = MIN_LENGTH; aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_TREE_SET }, (eventData) => { - this.dataSource.addData((eventData.data as Record)['value'] as string); + emitter.on({ eventId: Constant.EMITTER_ID_TREE_SET } as emitter.InnerEvent, (eventData: emitter.EventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as string); this.totalCount = this.dataSource.totalCount(); }); } aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_TREE_SET.toLong()); + emitter.off(Constant.EMITTER_ID_TREE_SET); } build() { @@ -60,13 +63,13 @@ export struct TreeSetView { this.totalCount = this.dataSource.totalCount(); } }) } - .height(72) + .height(72.0) .width('100%') - .margin({ bottom: 20 }) + .margin({ bottom: 20.0 } as Margin) }, (item: string, index: number) => JSON.stringify(item) + index) } .width('100%') - .layoutWeight(1) + .layoutWeight(1.0) } else { EmptyPage() diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets index 835a59f948be289cdf492bb84593d99795a5d7ea..c18c9ff46446e50633ddb6136970ae5b8f30bfc3 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets @@ -15,7 +15,7 @@ */ import { - Preview, + // Preview, Component, State, Scroll, @@ -23,17 +23,20 @@ import { Text, Color, FontWeight, - $r, BarState, Alignment, + $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; -import { ColumnOperation } from '../components/ColumnOperation'; +// import { ColumnOperation } from '../components/ColumnOperation'; import { changeValue, deleteNode, getFirstNode, insertNode } from '../util/UrlUtil'; const URL_NET: string = 'https://gitee.com/openharmony/'; -@Preview +// @Preview @Component export struct Url { @State output: string = URL_NET; @@ -45,25 +48,25 @@ export struct Url { .id('output') .width('95%') .height('30%') - .fontSize(15) - .padding(10) - .margin({ left: 10, right: 10, top: 10 }) - .border({ width: 2, radius: 5, color: Color.Gray }) + .fontSize(15.0) + .padding(10.0) + .margin({ left: 10.0, right: 10.0, top: 10.0 } as Margin) + .border({ width: 2.0, radius: 5.0, color: Color.Gray }) Text(URL_NET) - .fontSize(15) - .margin({ top: 15 }) + .fontSize(15.0) + .margin({ top: 15.0 } as Margin) .fontWeight(FontWeight.Bold) - ColumnOperation({ operationRes: $r('app.strarray.url_operations'), doOperation: this.doOperation }) + // ColumnOperation({ operationRes: $r('app.strarray.url_operations'), doOperation: this.doOperation }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) } - doOperation = (index: number) => { - switch (index) { + doOperation (index: number) { + switch (index as int) { case 0: this.output = insertNode(); break; @@ -71,7 +74,7 @@ export struct Url { this.output = deleteNode(); break; case 2: - this.output = getFirstNode(); + this.output = getFirstNode(this.getUIContext()); break; case 3: this.output = changeValue(); diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets index 8f911a6bf4c03b356a13248d6f293422944da2c5..281f5d737324f9cc4333c4985b6b84c64a475015 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets @@ -18,19 +18,25 @@ import { Component, StorageLink, Builder, - $r, Column, Divider, + $r, + Padding, + Margin, + ClickEvent, + NavDestination, + Row, + Text, + FlexAlign, + FontWeight } from '@kit.ArkUI'; - -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; -import { LRUCache } from '../components/utilcomponents/LRUCache'; -import { Base64Helper } from '../components/utilcomponents/Base64Helper'; -import { MenuList } from '@ohos/menuitems'; +import { getString } from 'common'; +import { LRUCache } from '../components/utilcomponents/LRUCache.ets'; +import { Base64Helper } from '../components/utilcomponents/Base64Helper.ets'; import { RationalNumber } from '../components/utilcomponents/RationalNumber'; -import { ScopeHelper } from '../components/utilcomponents/ScopeHelper'; -import { StringCode } from '../components/utilcomponents/StringCode'; -import { TypeCheck } from '../components/utilcomponents/TypeCheck'; +import { ScopeHelper } from '../components/utilcomponents/ScopeHelper.ets'; +import { StringCode } from '../components/utilcomponents/StringCode.ets'; +import { TypeCheck } from '../components/utilcomponents/TypeCheck.ets'; @Component export struct Util { @@ -38,37 +44,59 @@ export struct Util { @Builder UtilCapabilities() { - if (this.selectedSecondLabel === getString($r('app.string.lru_cache'))) { + const uIContext = this.getUIContext() + if (this.selectedSecondLabel === getString($r('app.string.lru_cache'), uIContext)) { LRUCache() } - if (this.selectedSecondLabel === getString($r('app.string.base64'))) { + if (this.selectedSecondLabel === getString($r('app.string.base64'), uIContext)) { Base64Helper() } - if (this.selectedSecondLabel === getString($r('app.string.string_code'))) { + if (this.selectedSecondLabel === getString($r('app.string.string_code'), uIContext)) { StringCode() } - if (this.selectedSecondLabel === getString($r('app.string.rational_number'))) { + if (this.selectedSecondLabel === getString($r('app.string.rational_number'), uIContext)) { RationalNumber() } - if (this.selectedSecondLabel === getString($r('app.string.type_check'))) { + if (this.selectedSecondLabel === getString($r('app.string.type_check'), uIContext)) { TypeCheck() } - if (this.selectedSecondLabel === getString($r('app.string.scope_helper'))) { + if (this.selectedSecondLabel === getString($r('app.string.scope_helper'), uIContext)) { ScopeHelper() } } build() { - Column() { - MenuList({ menuList: $r('app.strarray.util_menu') }) { - Column() { - Divider() - .strokeWidth('1px') - .color($r('sys.color.ohos_id_color_list_separator')) - this.UtilCapabilities() - } + NavDestination() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + + Column() { + this.UtilCapabilities() } + .height('100%') + .padding({ left: 12.0, right: 12.0 }as Padding) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + .title(() => { + this.CustomTitle(this.selectedSecondLabel) + }, {backgroundColor: $r("sys.color.ohos_id_color_sub_background")}) + .width('100%') + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + + @Builder + CustomTitle(title: string) { + Row() { + Text(title) + .fontColor($r('app.color.black')) + .fontSize(16.0) + .fontWeight(FontWeight.Bold) } - .margin({ left: -12, right: -12 }) + .width('85%') + .height(56.0) + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets index 768ca925c231a4d73750922e8d1521e38e40dd98..0a2af74c5f193084429a6a63c9f6fb1a8a45e688 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets @@ -1,3 +1,4 @@ +// 'use static' 'use static' /* * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. @@ -13,65 +14,68 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { - Component, - State, - Column, - List, - LazyForEach, - ListItem, - $r, -} from '@kit.ArkUI'; - -import emitter from '@ohos.events.emitter'; -import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; -import { Information } from '../model/Information'; -import { VectorDataSource } from '../components/vectorcomponents/VectorDataSource'; -import { InformationItemView } from '../components/InformationItemView'; -import { Constant } from '../Constant'; - -const MIN_LENGTH = 0; - -@Component -export struct VectorView { - private dataSource: VectorDataSource = new VectorDataSource(); - @State totalCount: number = MIN_LENGTH; - - aboutToAppear() { - emitter.on({ eventId: Constant.EMITTER_ID_VECTOR }, (eventData) => { - this.dataSource.addData(eventData.data as Information); - this.totalCount = this.dataSource.totalCount(); - }); - } - - aboutToDisappear() { - emitter.off(Constant.EMITTER_ID_VECTOR.toLong()); - } - - build() { - Column() { - if (this.totalCount > MIN_LENGTH) { - List() { - LazyForEach(this.dataSource, (item: Information, index: number) => { - ListItem() { - InformationItemView({ index: index, information: item, deleteAction: () => { - this.dataSource.deleteData(index); - this.totalCount = this.dataSource.totalCount(); - } }) - } - .height(72) - .width('100%') - .margin({ bottom: 20 }) - }, (item: Information, index: number) => JSON.stringify(item) + index) - } - .width('100%') - .layoutWeight(1) - - } else { - EmptyPage() - } - } - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - } -} \ No newline at end of file +// +// import { +// Component, +// State, +// Column, +// List, +// LazyForEach, +// ListItem, +// $r, +// Padding, +// Margin, +// ClickEvent, +// } from '@kit.ArkUI'; +// +// import emitter from '@ohos.events.emitter'; +// import { EmptyPage } from 'common'; +// import { Information } from '../model/Information'; +// import { VectorDataSource } from '../components/vectorcomponents/VectorDataSource'; +// import { InformationItemView } from '../components/InformationItemView'; +// import { Constant } from '../Constant'; +// +// const MIN_LENGTH: number = 0.0; +// +// @Component +// export struct VectorView { +// private dataSource: VectorDataSource = new VectorDataSource(); +// @State totalCount: number = MIN_LENGTH; +// +// aboutToAppear() { +// emitter.on({ eventId: Constant.EMITTER_ID_VECTOR } as emitter.InnerEvent, (eventData: emitter.EventData) => { +// this.dataSource.addData((eventData.data as Record)['value'] as Information); +// this.totalCount = this.dataSource.totalCount(); +// }); +// } +// +// aboutToDisappear() { +// emitter.off(Constant.EMITTER_ID_VECTOR); +// } +// +// build() { +// Column() { +// if (this.totalCount > MIN_LENGTH) { +// List() { +// LazyForEach(this.dataSource, (item: Information, index: number) => { +// ListItem() { +// InformationItemView({ index: index, information: item, deleteAction: () => { +// this.dataSource.deleteData(index as int); +// this.totalCount = this.dataSource.totalCount(); +// } }) +// } +// .height(72.0) +// .width('100%') +// .margin({ bottom: 20.0 } as Margin) +// }, (item: Information, index: number) => JSON.stringify(item) + index) +// } +// .width('100%') +// .layoutWeight(1.0) +// +// } else { +// EmptyPage() +// } +// } +// .backgroundColor($r('sys.color.ohos_id_color_sub_background')) +// } +// } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets index a4cf463564ccbf207e05de5597ab46009e7c6c17..514f6920dc6b85657853d416feadc9df358778a1 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets @@ -26,32 +26,37 @@ import { Color, ButtonType, FlexAlign, + Padding, + Margin, + ClickEvent, + UIContext, + ButtonOptions } from '@kit.ArkUI'; -import { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getStringArray } from 'common'; @Component export struct ColumnOperation { private operationRes: Resource | undefined = undefined; - @State operationSource: string[] = []; - private doOperation: (index: number) => void = () => { + @State operationSource: string[] = ['']; + private doOperation: (index: number) => void = (index: number) => { }; build() { Column() { ForEach(this.operationSource, (item: string, index: number) => { Row() { - Button() { + Button({} as ButtonOptions) { Text(item) - .fontSize(16) + .fontSize(16.0) .fontColor(Color.White) } .id(`item${index}`) .width('100%') - .height(50) + .height(50.0) .type(ButtonType.Capsule) - .margin({ right: 15, top: 15 }) - .onClick(() => { + .margin({ right: 15.0, top: 15.0 } as Margin) + .onClick((e: ClickEvent) => { this.doOperation(index); }) } @@ -60,12 +65,12 @@ export struct ColumnOperation { }, (index: string) => index) } .width('100%') - .padding({ bottom: 15 }) + .padding({ bottom: 15.0 } as Padding) } - async aboutToAppear() { + aboutToAppear() { if (this.operationRes) { - let menuList = await getStringArray(this.operationRes); + let menuList = getStringArray(this.operationRes as Resource, this.getUIContext()); this.operationSource = menuList; } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets index 00d39b0d3ca1cd576e52a6866eed4421d51fc1ea..10ca4e4d69841e901b99140badba3b7c02689efa 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets @@ -16,26 +16,37 @@ import { Component, + State, Row, Image, - $r, FlexAlign, VerticalAlign, + $r, + Margin, + ClickEvent, + Link } from '@kit.ArkUI'; @Component export struct DeleteView { private enable: boolean = false; + private id: string = ''; + private enabled: boolean = true; + private onClick?: (event?: ClickEvent) => void; build() { Row() { Image($r('app.media.ic_delete_plane')) - .width(24) - .aspectRatio(1) + .width(24.0) + .aspectRatio(1.0) } - .width(40) - .aspectRatio(1) - .borderRadius(20) + .id(this.id) + .enabled(this.enabled) + .onClick(this.onClick) + .margin({ left: 12.0 } as Margin) + .width(40.0) + .aspectRatio(1.0) + .borderRadius(20.0) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) .backgroundColor($r('app.color.bg_btn_red')) diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets index 8f87229aad8390e5776997ed3760432abb4b1b70..acd911cabaed70c189c6e8a55da8b5232c43cbb7 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets @@ -29,34 +29,38 @@ import { Color, ButtonType, FlexAlign, + Padding, + Margin, + ClickEvent, + ButtonOptions } from '@kit.ArkUI'; -import { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getStringArray } from 'common'; @Component export struct GridOperation { private operationRes: Resource | undefined = undefined; - @State operationSource: string[] = []; + @State operationSource: string[] = ['']; private doOperation: (index: number) => void = () => {}; build() { Column() { - GridRow({ columns: 12, gutter: { x: 2, y: 5 }, + GridRow({ columns: 12.0, gutter: { x: 2.0, y: 5.0 }, direction: GridRowDirection.Row }) { ForEach(this.operationSource, (item: string, index: number) => { - GridCol({ span: { xs: 6, sm: 6, md: 4, lg: 4 } }) { + GridCol({ span: { xs: 6.0, sm: 6.0, md: 4.0, lg: 4.0 } }) { Row() { - Button() { + Button({} as ButtonOptions) { Text(item) - .fontSize(16) + .fontSize(16.0) .fontColor(Color.White) } - .width(160) - .height(50) + .width(160.0) + .height(50.0) .type(ButtonType.Capsule) - .margin({ right: 10, top: 10 }) - .onClick(() => { + .margin({ right: 10.0, top: 10.0 } as Margin) + .onClick((e:ClickEvent) => { this.doOperation(index); }) } @@ -66,12 +70,12 @@ export struct GridOperation { } } .width('100%') - .padding({ bottom: 15 }) + .padding({ bottom: 15.0 } as Padding) } - async aboutToAppear() { + aboutToAppear() { if (this.operationRes) { - let menuList = await getStringArray(this.operationRes); + let menuList = getStringArray(this.operationRes as Resource, this.getUIContext()); this.operationSource = menuList; } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets index 9141789f67ac0dffc0862b331f181a2bc77112b8..bebedcc132060353fda6b66f060846a3e73ecdc2 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets @@ -21,20 +21,21 @@ import { Row, Column, Text, - $r, Blank, + $r, + Padding, + Margin, } from '@kit.ArkUI'; import { Information } from '../model/Information'; import { DeleteView } from './DeleteView'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; @Component export struct InformationItemView { @ObjectLink information: Information; - private deleteAction: (event?: ClickEvent) => void = () => { - }; - private index: number = 0; + private deleteAction: (event?: ClickEvent) => void = () => {}; + private index: number = 0.0; build() { Row() { @@ -42,32 +43,34 @@ export struct InformationItemView { Column() { Text(this.information.name) .fontColor($r('app.color.text_color_primary')) - .fontSize(16) + .fontSize(16.0) Text(this.information.phone) .fontColor($r('app.color.text_color_second')) - .fontSize(14) - .margin({ top: 5 }) + .fontSize(14.0) + .margin({ top: 5.0 } as Margin) } Blank() - Text(`${this.information.age}${getString($r('app.string.old'))}`) + Text(`${this.information.age}${getString($r('app.string.old'), this.getUIContext())}`) .fontColor($r('app.color.text_color_second')) - .fontSize(12) + .fontSize(12.0) } - .height(72) - .layoutWeight(1) - .padding({ left: 16, right: 15 }) - .margin({ right: 12 }) + .height(72.0) + .layoutWeight(1.0) + .padding({ left: 16.0, right: 15.0 } as Padding) + .margin({ right: 12.0 } as Margin) .backgroundColor($r('app.color.bg_white')) - .borderRadius(16) + .borderRadius(16.0) - DeleteView({ enable: this.information.clickAble }) - .id(`delete${this.index}`) - .enabled(this.information.clickAble) - .onClick(this.deleteAction) + DeleteView({ + enable: this.information.clickAble, + id: `delete${this.index}`, + enabled: this.information.clickAble, + onClick: this.deleteAction + }) } - .padding({ left: 12 }) + .padding({ left: 12.0 } as Padding) .width('100%') - .margin({ top: 12, right: 12 }) + .margin({ top: 12.0, right: 12.0 } as Margin) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets index 2975a77941294c22e63cea0940cc89fc2e9a65d3..1d3956dd9e907284d68eeec2e1a687ab83256b2d 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets @@ -22,9 +22,12 @@ import { Row, Column, Text, - $r, HorizontalAlign, VerticalAlign, + Margin, + Padding, + $r, + Link } from '@kit.ArkUI'; import { KeyValuePair } from '../model/KeyValuePair'; @@ -32,37 +35,42 @@ import { DeleteView } from './DeleteView'; @Component export struct KeyValueItemView { - @ObjectLink keyValuePair: KeyValuePair; + @ObjectLink keyValuePair: KeyValuePair = new KeyValuePair('', ''); @State deleteEnabled: boolean = true; - private deleteAction: (event?: ClickEvent) => void = () => { - }; - private index: number = 0; + private deleteAction: (event?: ClickEvent) => void = () => {}; + private index: number = 0.0; build() { Row() { Column() { Text(`Key: ${this.keyValuePair.key}`) .fontColor($r('app.color.text_color_primary')) - .fontSize(16) + .fontSize(16.0) Text(`Value: ${this.keyValuePair.value}`) .fontColor($r('app.color.text_color_second')) - .fontSize(14) + .fontSize(14.0) } .height('100%') - .layoutWeight(1) - .padding({ left: 16, right: 16, top: 12, bottom: 12 }) - .borderRadius(16) + .layoutWeight(1.0) + .padding({ + left: 16.0, + right: 16.0, + top: 12.0, + bottom: 12.0 + } as Padding) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) .alignItems(HorizontalAlign.Start) - DeleteView({ enable: this.deleteEnabled }) - .id(`delete${this.index}`) - .margin({ left: 12 }) - .enabled(this.deleteEnabled) - .onClick(this.deleteAction) + DeleteView({ + enable: this.deleteEnabled, + id: `delete${this.index}`, + enabled: this.deleteEnabled, + onClick: this.deleteAction + }) } .width('100%') - .height(64) + .height(64.0) .alignItems(VerticalAlign.Center) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets index 44ee81af7c6a1752e575bc12f61325be9640c116..e9935d1cb80a6bf14025011fd209672edbaa4bf2 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets @@ -21,10 +21,12 @@ import { Row, Column, Text, - $r, FlexAlign, HorizontalAlign, VerticalAlign, + Margin, + Padding, + $r } from '@kit.ArkUI'; import { DeleteView } from './DeleteView'; @@ -34,31 +36,32 @@ export struct ValueItemView { @State deleteEnabled: boolean = true; private value: string = ''; private deleteAction: (event?: ClickEvent) => void = () => {}; - private index: number = 0; + private index: number = 0.0; build() { Row() { Column() { Text(`Value: ${this.value}`) .fontColor($r('app.color.text_color_primary')) - .fontSize(16) + .fontSize(16.0) } .height('100%') - .layoutWeight(1) - .padding({ left: 16, right: 16, top: 12, bottom: 12 }) - .borderRadius(16) + .layoutWeight(1.0) + .padding({ left: 16.0, right: 16.0, top: 12.0, bottom: 12.0 } as Padding) + .borderRadius(16.0) .backgroundColor($r('app.color.bg_white')) .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Start) - DeleteView({ enable: this.deleteEnabled }) - .id(`delete${this.index}`) - .margin({ left: 12 }) - .enabled(this.deleteEnabled) - .onClick(this.deleteAction) + DeleteView({ + enable: this.deleteEnabled, + id: `delete${this.index}`, + enabled: this.deleteEnabled, + onClick: this.deleteAction + }) } .width('100%') - .height(64) + .height(64.0) .alignItems(VerticalAlign.Center) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets index c6ceca067c13ff0cce4036e36ffa18e391e11a40..b59125360ca4f34075677ffbe82bef4ab59db48a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets @@ -20,7 +20,6 @@ import { CustomDialogController, Column, Text, - $r, Color, FontWeight, Row, @@ -28,17 +27,23 @@ import { InputType, Button, Divider, + $r, + Padding, + Margin, + ClickEvent, + ButtonOptions } from '@kit.ArkUI'; -import prompt from '@ohos.promptAction'; +import promptAction from '@ohos.promptAction'; import { Information } from '../../model/Information'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { logger } from 'common'; const TAG: string = 'AddDialog'; @CustomDialog export struct AddDialog { - @State writeInformation: Information = new Information('', Number.NaN, '') + // @State + writeInformation: Information = new Information('', Number.NaN, '') private saveData: (information: Information) => void = () => { }; private controller?: CustomDialogController; @@ -46,128 +51,129 @@ export struct AddDialog { build() { Column() { Text($r('app.string.contact_information')) - .fontSize(24) + .fontSize(24.0) .fontColor(Color.Black) .fontWeight(FontWeight.Bold) - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) Row() { Text($r('app.string.contact_name')) - .width(65) - .fontSize(20) + .width(65.0) + .fontSize(20.0) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) - .margin({ left: 10 }) + .margin({ left: 10.0 } as Margin) TextInput({ placeholder: $r('app.string.input_name'), text: this.writeInformation.name }) .key('inputPhone') - .layoutWeight(1) + .layoutWeight(1.0) .type(InputType.Normal) .placeholderColor(Color.Gray) - .fontSize(19) - .maxLength(11) - .margin({ right: 10 }) - .onChange((value: string) => { + .fontSize(19.0) + .maxLength(11.0) + .margin({ right: 10.0 } as Margin) + .onChange((value: string):void => { this.writeInformation.name = value; logger.info(TAG, ` this.writeInformation.name = ${value}`); }) } - .margin({ top: 12 }) + .margin({ top: 12.0 }as Margin) Row() { Text($r('app.string.contact_age')) - .width(65) - .fontSize(20) + .width(65.0) + .fontSize(20.0) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) - .margin({ left: 10 }) + .margin({ left: 10.0 } as Margin) TextInput({ placeholder: $r('app.string.input_age') }) .key('inputPhone') - .layoutWeight(1) + .layoutWeight(1.0) .type(InputType.Number) .placeholderColor(Color.Gray) - .fontSize(19) - .maxLength(11) - .margin({ right: 10 }) - .onChange((value: string) => { + .fontSize(19.0) + .maxLength(11.0) + .margin({ right: 10.0 } as Margin) + .onChange((value: string):void => { this.writeInformation.age = Number(value); }) } - .margin({ top: 12 }) + .margin({ top: 12.0 }as Margin) Row() { Text($r('app.string.contact_phone')) - .width(65) - .fontSize(20) + .width(65.0) + .fontSize(20.0) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) - .margin({ left: 10 }) + .margin({ left: 10.0 } as Margin) TextInput({ placeholder: $r('app.string.input_phone'), text: this.writeInformation.phone }) .key('inputPhone') - .layoutWeight(1) + .layoutWeight(1.0) .type(InputType.Number) .placeholderColor(Color.Gray) - .fontSize(19) - .maxLength(11) - .margin({ right: 10 }) - .onChange((value: string) => { + .fontSize(19.0) + .maxLength(11.0) + .margin({ right: 10.0 } as Margin) + .onChange((value: string) :void=> { this.writeInformation.phone = value; }) } - .margin({ top: 12 }) + .margin({ top: 12.0 }as Margin) Row() { - Button() { + Button({} as ButtonOptions) { Text($r("app.string.button_confirm")) .key('confirm') .fontColor(Color.Blue) - .fontSize(17) + .fontSize(17.0) } - .layoutWeight(7) + .layoutWeight(7.0) .backgroundColor(Color.White) - .margin(5) - .onClick(() => { + .margin(5.0) + .onClick((e: ClickEvent):void => { this.addInformation(); }) Divider() - .height(30) + .height(30.0) .vertical(true) - .strokeWidth(2) + .strokeWidth(2.0) .color('#999999') - Button() { + Button({} as ButtonOptions) { Text($r('app.string.button_cancel')) .fontColor(Color.Red) - .fontSize(17) + .fontSize(17.0) } - .margin(5) - .layoutWeight(7) + .margin(5.0) + .layoutWeight(7.0) .backgroundColor(Color.White) - .onClick(() => { + .onClick((e: ClickEvent) => { this.controller?.close(); }) } - .margin({ top: 12 }) + .margin({ top: 12.0 } as Margin) } - .padding(12) + .padding(12.0 ) } addInformation() { if (this.writeInformation.name === '') { - prompt.showToast({ message: $r('app.string.name_null') }); + //todo + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.name_null') }); return; } - if (this.writeInformation.age < 1 || Number.isNaN(this.writeInformation.age)) { - prompt.showToast({ message: $r('app.string.age_null') }); + if (this.writeInformation.age < 1.0 || Number.isNaN(this.writeInformation.age)) { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.age_null') }); return; } if (this.writeInformation.phone === '') { - prompt.showToast({ message: $r('app.string.phone_null') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.phone_null') }); return; } - if (this.writeInformation.name !== '' && this.writeInformation.phone !== '' && this.writeInformation.age > 0) { + if (this.writeInformation.name !== '' && this.writeInformation.phone !== '' && this.writeInformation.age > 0.0) { this.saveData(this.writeInformation); } this.controller?.close(); diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets index e87846ca1a281c05a852d7a34527bd8ac6bb3565..0954eb0efbd04a72733f39d17d392b221d6763f2 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets @@ -19,7 +19,6 @@ import { ObjectLink, Row, Image, - $r, ImageFit, Column, Text, @@ -30,6 +29,11 @@ import { TextAlign, ButtonType, Alignment, + $r, + Padding, + Margin, + ClickEvent, + ButtonOptions } from '@kit.ArkUI'; import { Information } from '../../model/Information'; @@ -37,7 +41,7 @@ import { Information } from '../../model/Information'; @Component export struct ArrayListItem { @ObjectLink information: Information; - private index: number = 0; + private index: number = 0.0; private handleOnClick: (index: number) => void = () => {}; build() { @@ -48,61 +52,61 @@ export struct ArrayListItem { Column() { Row() { Text($r("app.string.contact_name")) - .fontSize(24) + .fontSize(24.0) .fontColor(Color.Black) Text(this.information.name) .fontColor(Color.Black) - .fontSize(24) + .fontSize(24.0) } .width('100%') - .margin({ top: 5 }) + .margin({ top: 5.0 } as Margin) Row() { Text($r("app.string.contact_age")) .fontColor(Color.Black) - .fontSize(24) + .fontSize(24.0) Text(this.information.age.toString()) .fontColor(Color.Black) - .fontSize(24) + .fontSize(24.0) } .width('100%') - .margin({ top: 5 }) + .margin({ top: 5.0 } as Margin) Row() { Text($r("app.string.contact_phone")) .fontColor(Color.Black) - .fontSize(24) + .fontSize(24.0) Text(this.information.phone) .fontColor(Color.Black) - .fontSize(24) + .fontSize(24.0) } .width('100%') - .margin({ top: 5 }) + .margin({ top: 5.0 } as Margin) } .width('55%') - .margin({ left: 10 }) + .margin({ left: 10.0 } as Margin) .justifyContent(FlexAlign.Start) Blank() - Button() { + Button({} as ButtonOptions) { Text($r('app.string.button_delete')) .key('delContact') .fontColor(Color.Red) - .fontSize(19) - .width(100) + .fontSize(19.0) + .width(100.0) .textAlign(TextAlign.Center) } .type(ButtonType.Capsule) .backgroundColor($r("app.color.button_bg")) - .height(40) - .onClick(() => { + .height(40.0) + .onClick((event:ClickEvent) => { this.handleOnClick(this.index); }) } .width('100%') - .padding(10) + .padding(10.0) .align(Alignment.Center) - .borderRadius(20) + .borderRadius(20.0) .backgroundColor(Color.White) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets index 32d435b15e96459a4cc8b66f7790c4408bbd400f..000db2928b34480768716d21242d0065dc0138c0 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets @@ -1,4 +1,4 @@ -'use static' +// 'use static' /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,62 +14,62 @@ * limitations under the License. */ -import { DataChangeListener } from '@kit.ArkUI'; - -import ArrayList from '@ohos.util.ArrayList'; -import { Information } from '../../model/Information'; - -export class MyDataSource { - public dataArray: ArrayList = new ArrayList(); - private listeners: DataChangeListener[] = []; - - constructor(ele: ArrayList) { - for (let index: int = 0;index < ele.length; index++) { - this.dataArray.add(ele[index]); - } - } - - public totalCount(): number { - return this.dataArray.length; - } - - public getData(index: number): Information { - return this.dataArray[index]; - } - - public addData(index: int, data: Information): void { - this.dataArray.removeByIndex(index); - this.notifyDataAdd(index); - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener); - } - } - - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1); - } - } - - 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); - }) - } -} \ No newline at end of file +// import { DataChangeListener } from '@kit.ArkUI'; +// +// import ArrayList from '@ohos.util.ArrayList'; +// import { Information } from '../../model/Information'; +// +// export class MyDataSource { +// public dataArray: ArrayList = new ArrayList(); +// private listeners: DataChangeListener[] = []; +// +// constructor(ele: ArrayList) { +// for (let index: int = 0;index < ele.length; index++) { +// this.dataArray.add(ele[index]); +// } +// } +// +// public totalCount(): int { +// return this.dataArray.length; +// } +// +// public getData(index: int): Information { +// return this.dataArray[index]; +// } +// +// public addData(index: int, data: Information): void { +// this.dataArray.removeByIndex(index); +// this.notifyDataAdd(index); +// } +// +// registerDataChangeListener(listener: DataChangeListener): void { +// if (this.listeners.indexOf(listener) < 0.0) { +// this.listeners.push(listener); +// } +// } +// +// unregisterDataChangeListener(listener: DataChangeListener): void { +// const pos: number = this.listeners.indexOf(listener); +// if (pos >= 0.0) { +// this.listeners.splice(pos, 1.0); +// } +// } +// +// notifyDataReload(): void { +// this.listeners.forEach(listener => { +// listener.onDataReloaded(); +// }) +// } +// +// notifyDataAdd(index: int): void { +// this.listeners.forEach(listener => { +// listener.onDataAdd(index); +// }) +// } +// +// notifyDataChange(index: int): void { +// this.listeners.forEach(listener => { +// listener.onDataChange(index); +// }) +// } +// } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets index 6fffeb812dd8ed646dce076edf0791821e3ba82c..aae1a760f4624bc8cc25c29d8b242e569995c35c 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets @@ -15,10 +15,10 @@ */ import Deque from '@ohos.util.Deque'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { Information } from '../../model/Information'; -export class DequeDataSource extends BaseDataSource { +export class DequeDataSource extends BaseDataSource { private deque = new Deque(); public totalCount(): number { @@ -26,21 +26,22 @@ export class DequeDataSource extends BaseDataSource { } public getData(index: number): Information { - return this.deque[index] + return this.deque[index as int] } public insertFront(information: Information): void { this.deque.insertFront(information); this.deque.forEach((value, index) => { - value.clickAble = index === 0 || index === this.deque.length - 1; + value.clickAble = index === 0.0 || index === this.deque.length - 1.0; }); this.notifyDataReload(); + console.info('wzrinsert') } public insertEnd(information: Information): void { this.deque.insertEnd(information); this.deque.forEach((value, index) => { - value.clickAble = index === 0 || index === this.deque.length - 1; + value.clickAble = index === 0.0 || index === this.deque.length - 1.0; }); this.notifyDataReload(); } @@ -48,7 +49,7 @@ export class DequeDataSource extends BaseDataSource { public deleteFront(): void { this.deque.popFirst(); this.deque.forEach((value, index) => { - value.clickAble = index === 0 || index === this.deque.length - 1; + value.clickAble = index === 0.0 || index === this.deque.length - 1.0; }); this.notifyDataReload(); } @@ -56,7 +57,7 @@ export class DequeDataSource extends BaseDataSource { public deleteEnd(): void { this.deque.popLast(); this.deque.forEach((value, index) => { - value.clickAble = index === 0 || index === this.deque.length - 1; + value.clickAble = index === 0.0 || index === this.deque.length - 1.0; }); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets index dff2f813cb3025960251c9f7b5552c9930f26604..ade9af47142d8d47c40e47d2df50e4bc2ad715a2 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets @@ -14,10 +14,10 @@ * limitations under the License. */ -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { KeyValuePair } from '../../model/KeyValuePair'; -export class HashMapDataSource extends BaseDataSource { +export class HashMapDataSource extends BaseDataSource { public dataArr: KeyValuePair[] = []; public totalCount(): number { @@ -30,13 +30,13 @@ export class HashMapDataSource extends BaseDataSource { public addData(item: KeyValuePair): void { this.dataArr.push(item); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(item: KeyValuePair, index: number): void { this.notifyDataDelete(index); - this.dataArr.splice(index, 1); + this.dataArr.splice(index, 1.0); this.notifyDataReload(); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets index c8e01af50f9cef3d18a10072621e68ceb13cc4d9..3d276bd0d9907d38a4540bfba9d4ef065e120557 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets @@ -14,9 +14,9 @@ * limitations under the License. */ -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; -export class HashSetDataSource extends BaseDataSource { +export class HashSetDataSource extends BaseDataSource { public dataArr: string[] = []; public totalCount(): number { @@ -29,12 +29,12 @@ export class HashSetDataSource extends BaseDataSource { public addData(item: string): void { this.dataArr.push(item); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(item: string, index: number): void { - this.dataArr.splice(index, 1); + this.dataArr.splice(index, 1.0); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets index 6b4127afd9d2cc91cad196a74e93320486f832ab..c59515710dcf87c29d29803fb54fe0f3a51187fe 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets @@ -14,10 +14,10 @@ * limitations under the License. */ -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { KeyValuePair } from '../../model/KeyValuePair'; -export class LightWeightMapDataSource extends BaseDataSource { +export class LightWeightMapDataSource extends BaseDataSource { public dataArr: KeyValuePair[] = []; public totalCount(): number { @@ -30,12 +30,12 @@ export class LightWeightMapDataSource extends BaseDataSource { public addData(item: KeyValuePair): void { this.dataArr.push(item); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(item: KeyValuePair, index: number): void { - this.dataArr.splice(index, 1); + this.dataArr.splice(index, 1.0); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets index 55ba0c4dd59ad88cc06ad153d72f74995082dce8..dbec6bbd286e8889cce4224b5c9d8170635c8ece 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets @@ -14,9 +14,9 @@ * limitations under the License. */ -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; -export class LightWeightSetDataSource extends BaseDataSource { +export class LightWeightSetDataSource extends BaseDataSource { public dataArr: string[] = [] public totalCount(): number { @@ -29,12 +29,12 @@ export class LightWeightSetDataSource extends BaseDataSource { public addData(item: string): void { this.dataArr.push(item); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(item: string, index: number): void { - this.dataArr.splice(index, 1); + this.dataArr.splice(index, 1.0); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets index 39975d97275bd450bfc555568f24bcc9591f2bef..126b003554078b9461665c8ece3be458ee1075f6 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets @@ -15,40 +15,40 @@ */ import LinkedList from '@ohos.util.LinkedList'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { Information } from '../../model/Information'; -export class LinkedListDataSource extends BaseDataSource { - private linkedList: LinkedList = new LinkedList(); +export class LinkedListDataSource extends BaseDataSource { + private linkedList = new LinkedList(); public totalCount(): number { return this.linkedList.length; } public getData(index: number): Information { - return this.linkedList[index]; + return this.linkedList.get(index as int) as Information;; } public addData(item: Information): void { this.linkedList.add(item); - this.notifyDataAdd(this.linkedList.length - 1); + this.notifyDataAdd(this.linkedList.length - 1.0); this.notifyDataReload(); } public deleteFirst(): void { this.linkedList.removeFirst(); - this.notifyDataDelete(0); + this.notifyDataDelete(0.0); this.notifyDataReload(); } public deleteLast(): void { this.linkedList.removeLast(); - this.notifyDataDelete(this.linkedList.length - 1); + this.notifyDataDelete(this.linkedList.length - 1.0); this.notifyDataReload(); } public deleteData(index: number): void { - this.linkedList.removeByIndex(index.toInt()); + this.linkedList.removeByIndex(index as int); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets index ef94b4604364e50e84d7ae4a01fbc56f4892f646..259f14f0256208a6f05b7d46785f3753c3110e76 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets @@ -15,28 +15,28 @@ */ import ListUtil from '@ohos.util.List'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { Information } from '../../model/Information'; -export class ListDateSource extends BaseDataSource { +export class ListDateSource extends BaseDataSource { private dataArr: ListUtil = new ListUtil(); public totalCount(): number { return this.dataArr.length; } - public getData(index: int): Information { - return this.dataArr.get(index); + public getData(index: number): Information { + return this.dataArr.get(index as int) as Information; } public addData(information: Information): void { this.dataArr.add(information); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } - public deleteData(index: number): void { - this.dataArr.removeByIndex(index.toInt()); + public deleteData(index: int): void { + this.dataArr.removeByIndex(index); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets index 5d9cb7b0e5fde1130e204f653799bfab79b03c4e..9f3efb56c861163d1c50a0714cbfd2928f66b125 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets @@ -16,38 +16,41 @@ import PlainArray from '@ohos.util.PlainArray'; import ArrayList from '@ohos.util.ArrayList'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { KeyValuePair } from '../../model/KeyValuePair'; -export class PlainArrayDataSource extends BaseDataSource { +export class PlainArrayDataSource extends BaseDataSource { private dataArr: PlainArray = new PlainArray(); - private arr: ArrayList = new ArrayList(); + private arr: ArrayList = new ArrayList(); public totalCount(): number { return this.arr.length; } public getData(index: number): KeyValuePair { - let key: number = this.arr[index]; - let value: string = this.dataArr.get(key.toInt()); - this.dataArr.get(this.arr[index].toInt()); - let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value); + let key: int = this.arr[index as int]; + let value: string = this.dataArr.get(key) as string + this.dataArr.get(key); + if (value === undefined) { + value = ""; + } + let keyValuePair: KeyValuePair = new KeyValuePair(`${key}`, value); return keyValuePair; } public addData(keyValuePair: KeyValuePair): void { - let key: number = Number(keyValuePair.key); - if (!this.dataArr.has(key.toInt())) { + let key: int = Number(keyValuePair.key) as int + if (!this.dataArr.has(key)) { this.arr.add(key) } this.dataArr.add(key, keyValuePair.value); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } - public deleteData(index: number): void { - this.dataArr.removeAt(index.toInt()); - this.arr.removeByIndex(index.toInt()); + public deleteData(index: int): void { + this.dataArr.removeAt(index); + this.arr.removeByIndex(index); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets index ac86edd5df2c3cda1467bea5e4a5ba8634187ac1..00df2207271f2a607fb6c153e98e70ec806f651c 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets @@ -15,35 +15,49 @@ */ import Queue from '@ohos.util.Queue'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { Information } from '../../model/Information'; -export class QueueDataSource extends BaseDataSource { - private dataArr: Queue = new Queue(); +export class QueueDataSource extends BaseDataSource { + private dataArr = new Queue(); public totalCount(): number { return this.dataArr.length; } public getData(index: number): Information { - return this.dataArr[index]; + let result: Information | undefined; + let currentIndex: number = 0; + for (const item of this.dataArr) { + if (currentIndex === index) { + result = item; + break; + } + currentIndex++; + } + + if (!result) { + throw new Error(`Index ${index} out of bounds`); + } + + return result; } public addData(information: Information): void { this.dataArr.add(information); this.dataArr.forEach((value, index) => { - value.clickAble = index === 0; + value.clickAble = index === 0.0; }); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(): void { this.dataArr.pop(); this.dataArr.forEach((value, index) => { - value.clickAble = index === 0; + value.clickAble = index === 0.0; }); - this.notifyDataDelete(0); + this.notifyDataDelete(0.0); this.notifyDataReload(); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets index 2775e129dacadb567f3ac059fc42d88f5cba2ba9..2292b656e5624d917d9762185058b90be0d5b0df 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets @@ -15,10 +15,10 @@ */ import Stack from '@ohos.util.Stack'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { Information } from '../../model/Information'; -export class StackDataSource extends BaseDataSource { +export class StackDataSource extends BaseDataSource { private dataArr: Stack = new Stack(); public totalCount(): number { @@ -26,24 +26,38 @@ export class StackDataSource extends BaseDataSource { } public getData(index: number): Information { - return this.dataArr[index]; + let result: Information | undefined; + let currentIndex: number = 0; + for (const item of this.dataArr) { + if (currentIndex === index) { + result = item; + break; + } + currentIndex++; + } + + if (!result) { + throw new Error(`Index ${index} out of bounds`); + } + + return result; } public addData(information: Information): void { this.dataArr.push(information); this.dataArr.forEach((value, index) => { - value.clickAble = index === this.dataArr.length - 1; + value.clickAble = index === this.dataArr.length - 1.0; }); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(): void { this.dataArr.pop(); this.dataArr.forEach((value, index) => { - value.clickAble = index === this.dataArr.length - 1; + value.clickAble = index === this.dataArr.length - 1.0; }); - this.notifyDataDelete(this.dataArr.length - 1); + this.notifyDataDelete(this.dataArr.length - 1.0); this.notifyDataReload(); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets index 9c8ba6de492d5300044880d4f620bc2b7c8231da..5efe7c4646ac65989bf206c6f53a57c7979ea5e1 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets @@ -16,11 +16,11 @@ import TreeMap from '@ohos.util.TreeMap'; import ArrayList from '@ohos.util.ArrayList'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; import { KeyValuePair } from '../../model/KeyValuePair'; -export class TreeMapDataSource extends BaseDataSource { - private dataArr: TreeMap = new TreeMap(); +export class TreeMapDataSource extends BaseDataSource { + private dataArr = new TreeMap(); private arr: ArrayList = new ArrayList(); public totalCount(): number { @@ -28,10 +28,13 @@ export class TreeMapDataSource extends BaseDataSource { } public getData(index: number): KeyValuePair { - let key: string = this.arr[index]; - let value: string = this.dataArr.get(key); - this.dataArr.get(this.arr[index]); - let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value); + let key: string = this.arr[index as int]; + let value: string |undefined= this.dataArr.get(key) as string; + this.dataArr.get(key); + let keyValuePair: KeyValuePair = new KeyValuePair(`${key}`, value); + if (value === undefined) { + value = ""; + } return keyValuePair; } @@ -40,13 +43,13 @@ export class TreeMapDataSource extends BaseDataSource { this.arr.add(keyValuePair.key) } this.dataArr.set(keyValuePair.key, keyValuePair.value); - this.notifyDataChange(this.dataArr.length - 1); + this.notifyDataChange(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(key: string): void { this.dataArr.remove(key); - let index = this.arr.getIndexOf(key); + let index: number = this.arr.getIndexOf(key); this.arr.remove(key); this.notifyDataDelete(index); this.notifyDataReload(); diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets index c208a11b4804a0aa15feb26538c1c871902cbc09..97da9621b6d96fe36b34fb57553831aff9c0d077 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets @@ -16,9 +16,9 @@ import TreeSet from '@ohos.util.TreeSet'; import ArrayList from '@ohos.util.ArrayList'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { BaseDataSource } from 'common'; -export class TreeSetDataSource extends BaseDataSource { +export class TreeSetDataSource extends BaseDataSource { private dataArr: TreeSet = new TreeSet(); private arr: ArrayList = new ArrayList(); @@ -27,19 +27,19 @@ export class TreeSetDataSource extends BaseDataSource { } public getData(index: number): string { - return this.arr[index]; + return this.arr[index as int]; } public addData(value: string): void { this.dataArr.add(value); this.arr.add(value); - this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataAdd(this.dataArr.length - 1.0); this.notifyDataReload(); } public deleteData(value: string, index: number): void { this.dataArr.remove(value); - this.arr.removeByIndex(index.toInt()); + this.arr.removeByIndex(index as int); this.notifyDataDelete(index); this.notifyDataReload(); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets index 86303643a5bbb3d07aebb809ba8e9abc95bf61fa..a78acec1bd47d05b286f26e3cbff8b17fad21c7c 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets @@ -21,7 +21,6 @@ import { Column, Row, Text, - $r, FontWeight, TextAlign, Color, @@ -29,6 +28,12 @@ import { ButtonType, BarState, Alignment, + $r, + Padding, + Margin, + ClickEvent, + ColumnOptions, + ButtonOptions, } from '@kit.ArkUI'; import util from '@ohos.util'; @@ -41,15 +46,15 @@ export struct Base64Helper { build() { Scroll() { - Column({ space: 12 }) { + Column({ space: 12.0 } as ColumnOptions) { Row() { Text($r('app.string.change_str')) - .fontSize(20) + .fontSize(20.0) .fontWeight(FontWeight.Bold) .textAlign(TextAlign.End) Text(this.input) - .fontSize(20) + .fontSize(20.0) .fontWeight(FontWeight.Bold) .textAlign(TextAlign.Start) } @@ -59,48 +64,48 @@ export struct Base64Helper { Text(this.resultEncode) .width('100%') .height('10%') - .padding({ left: 10 }) - .fontSize(20) + .padding({ left: 10.0 }as Padding) + .fontSize(20.0) .fontWeight(FontWeight.Bold) - .border({ width: 2, radius: 10, color: Color.Black }) + .border({ width: 2.0, radius: 10.0, color: Color.Black }) - Button() { + Button({} as ButtonOptions) { Text($r("app.string.encode")) - .fontSize(25) + .fontSize(25.0) .fontColor(Color.White) } .key('encodeBtn') .width('100%') - .height(50) + .height(50.0) .type(ButtonType.Capsule) - .onClick(() => { + .onClick((e:ClickEvent) => { this.encode(); }) Text(this.resultDecode) .width('100%') .height('10%') - .fontSize(20) - .padding({ left: 10 }) + .fontSize(20.0) + .padding({ left: 10.0 } as Padding) .fontWeight(FontWeight.Bold) - .border({ width: 2, radius: 10, color: Color.Black }) - .margin({ top: 50 }) + .border({ width: 2.0, radius: 10.0, color: Color.Black }) + .margin({ top: 50.0 } as Margin) - Button() { + Button({} as ButtonOptions) { Text($r("app.string.decode")) - .fontSize(25) + .fontSize(25.0) .fontColor(Color.White) } .key('decodeBtn') .width('100%') - .height(50) + .height(50.0) .type(ButtonType.Capsule) - .onClick(() => { + .onClick((e:ClickEvent) => { this.decode(); }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) @@ -108,7 +113,7 @@ export struct Base64Helper { encode() { let strToAscii: number[] = []; - for (let i: int = 0;i < this.input.length; i++) { + for (let i: number = 0.0;i < this.input.length; i++) { strToAscii.push(this.input.charCodeAt(i)); } let that = new util.Base64Helper(); @@ -123,8 +128,8 @@ export struct Base64Helper { } let decodeNum = that.decodeSync(this.resultEncode); this.resultDecode = ''; - for (let i: int = 0; i < decodeNum.length; i++) { - this.resultDecode += String.fromCharCode(decodeNum[i]); + for (let i: number = 0.0; i < decodeNum.length; i++) { + this.resultDecode += String.fromCharCode(decodeNum[i as int]); } } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets index c61fb472ac0358f6ce0014ab820a8531bc1699d1..4020ed5fda405397882c930bef44767a73147bba 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets @@ -22,9 +22,12 @@ import { Text, Color, BarState, - $r, Alignment, CustomDialogController, + $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; import { ActionSheetDialog } from './lrucache/ActionSheetDialog'; @@ -44,7 +47,7 @@ import { @Component export struct LRUCache { @State resultText: string = ''; - @State actionSheets: Array = []; + @State actionSheets: Array = ['']; private isGet: boolean = true; build() { @@ -53,25 +56,25 @@ export struct LRUCache { Scroll() { Text(this.resultText) .width('100%') - .fontSize(16) + .fontSize(16.0) } .width('90%') - .height(240) - .margin({ top: 10 }) - .border({ width: 1, color: Color.Gray, radius: 15 }) + .height(240.0) + .margin({ top: 10.0 } as Margin) + .border({ width: 1.0, color: Color.Gray, radius: 15.0 }) .scrollBar(BarState.Off) - .padding(15) + .padding(15.0) GridOperation({ operationRes: $r('app.strarray.lru_cache_operations'), doOperation: this.doOperation }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) } - action = (key: string) => { + action (key: string) { if (this.isGet) { if (lruBuffer.contains(key)) { let value: string = lruBuffer.get(key) as string; @@ -92,14 +95,15 @@ export struct LRUCache { }), autoCancel: true }); - doOperation = (index: number) => { - if (index !== 0 && lruBuffer === null) { + doOperation (index: number) { + if (index !== 0.0 && lruBuffer === null) { this.resultText = 'Click the first button and then operate'; return; } - switch (index) { + const uIContext = this.getUIContext() + switch (index as int) { case 0: - this.resultText = initLRUCache(); + this.resultText = initLRUCache(uIContext); break; case 1: this.resultText = getCapacity(); @@ -111,7 +115,7 @@ export struct LRUCache { this.resultText = getCacheString(); break; case 4: - this.resultText = putKeyValue(); + this.resultText = putKeyValue(uIContext); break; case 5: this.isGet = true; @@ -127,7 +131,7 @@ export struct LRUCache { this.actionDialogController.open(); break; case 8: - this.resultText = clear(); + this.resultText = clear(uIContext); break; case 9: this.resultText = operationLog(); diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets index 92d773828dc7c9cdc1a1825e00bd2d59a3d72a91..34af7e4ac86392a8c3b42a7d87a827c03ff11e75 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets @@ -18,13 +18,13 @@ import { TextAttribute, BorderStyle, TextAlign, - Preview, + // Preview, Component, State, Scroll, Column, + ColumnOptions, Text, - $r, BarState, Alignment, Builder, @@ -32,49 +32,54 @@ import { FontWeight, VerticalAlign, FlexAlign, + $r, + Padding, + Margin, + ClickEvent, + UIContext } from '@kit.ArkUI'; -import { compareTo, getDenominator, getValueOf, isFinite, isNaN, isZero } from '../../util/RationalNumberUtil'; +import { compareTo, getDenominator, getValueOf, isFinite1, isNaN1, isZero } from '../../util/RationalNumberUtil'; import { GridOperation } from '../GridOperation'; -const NUMERATOR1: number = 1; -const DENOMINATOR1: number = 2; -const NUMERATOR2: number = 3; -const DENOMINATOR2: number = 4; +const NUMERATOR1: number = 1.0; +const DENOMINATOR1: number = 2.0; +const NUMERATOR2: number = 3.0; +const DENOMINATOR2: number = 4.0; -function textStyle(this: TextAttribute): this { - this.border({ width: 1, color: '#000000', radius: 10, style: BorderStyle.Solid }); - this.fontSize(24); - this.textAlign(TextAlign.Center); - return this; +function textStyle(this_TextAttribute: TextAttribute): TextAttribute { + this_TextAttribute.border({ width: 1.0, color: '#000000', radius: 10.0, style: BorderStyle.Solid }); + this_TextAttribute.fontSize(24.0); + this_TextAttribute.textAlign(TextAlign.Center); + return this_TextAttribute; } -@Preview +// @Preview @Component export struct RationalNumber { @State resultText: string = ''; build() { Scroll() { - Column({ space: 12 }) { + Column({ space: 12.0 } as ColumnOptions) { Text($r('app.string.first_rational_number')) .width('100%') - .fontSize(24) + .fontSize(24.0) .textAlign(TextAlign.Start) this.Texts(NUMERATOR1, DENOMINATOR1) Text($r('app.string.second_rational_number')) .width('100%') - .fontSize(24) + .fontSize(24.0) .textAlign(TextAlign.Start) this.Texts(NUMERATOR2, DENOMINATOR2) Text(this.resultText) - .textStyle() + // .textStyle() .width('100%') - .height(100) + .height(100.0) GridOperation({ operationRes: $r('app.strarray.rational_number_operations'), doOperation: this.doOperation }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) @@ -84,44 +89,45 @@ export struct RationalNumber { Texts(numerator: number, denominator: number) { Row() { Text($r('app.string.numerator')) - .fontSize(24) + .fontSize(24.0) .fontWeight(FontWeight.Bold) Text(`${numerator}`) - .textStyle() - .margin({ left: 5 }) - .layoutWeight(1) + // .textStyle() + .margin({ left: 5.0 } as Margin) + .layoutWeight(1.0) Text($r('app.string.denominator')) - .fontSize(24) + .fontSize(24.0) .fontWeight(FontWeight.Bold) Text(`${denominator}`) - .textStyle() - .margin({ left: 5 }) - .layoutWeight(1) + // .textStyle() + .margin({ left: 5.0 } as Margin) + .layoutWeight(1.0) } .width('100%') .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.SpaceAround) } - doOperation = (index: number) => { - switch (index) { + doOperation (index: number) { + const uIContext = this.getUIContext() + switch (index as int) { case 0: - this.resultText = compareTo(); + this.resultText = compareTo(uIContext); break; case 1: - this.resultText = getValueOf(); + this.resultText = getValueOf(uIContext); break; case 2: - this.resultText = getDenominator(); + this.resultText = getDenominator(uIContext); break; case 3: - this.resultText = isZero(); + this.resultText = isZero(uIContext); break; case 4: - this.resultText = isNaN(); + this.resultText = isNaN1(uIContext); break; case 5: - this.resultText = isFinite(); + this.resultText = isFinite1(uIContext); break; default: break; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets index 44c726dedab01f9eb8b8ad86093de89ff3c30f5c..5a481671323ebc98384fe466c55aa02bf1f18e77 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets @@ -15,16 +15,16 @@ */ import { - Preview, + // Preview, Component, State, Scroll, Column, Text, - $r, Color, TextAlign, Row, + RowOptions, TextInput, InputType, FontStyle, @@ -35,8 +35,10 @@ import { BarState, Alignment, ResourceStr, - getUIContext, - AlertDialog, + ColumnOptions, + $r, + AlertDialogParamWithConfirm, + ButtonOptions } from '@kit.ArkUI'; import util from '@ohos.util'; @@ -44,69 +46,69 @@ import { ScopeNumber } from '../../model/ScopeNumber'; import { TempView } from './scopehelper/TempView'; import { SleepView } from './scopehelper/SleepView'; -const AGE_MIN: int = 16; -const AGE_MAX: int = 62; +const AGE_MIN: number = 16.0; +const AGE_MAX: number = 62.0; -@Preview +// @Preview @Component export struct ScopeHelper { - @State age: number = 0; - @State tempMorning: number = 0; - @State tempNoon: number = 1; - @State tempNight: number = 2; - @State shortTime: number = 0; - @State longTime: number = 0; + @State age: number = 0.0; + @State tempMorning: number = 0.0; + @State tempNoon: number = 1.0; + @State tempNight: number = 2.0; + @State shortTime: number = 0.0; + @State longTime: number = 0.0; build() { Scroll() { - Column({ space: 12 }) { + Column({ space: 12.0 } as ColumnOptions) { Text($r('app.string.judge_age')) - .fontSize(20) + .fontSize(20.0) .fontColor(Color.White) .backgroundColor(Color.Gray) .textAlign(TextAlign.Start) - Row({ space: 5 }) { + Row({ space: 5.0 } as RowOptions) { TextInput({ placeholder: $r('app.string.age_placeholder') }) .key('inputAge') .height('100%') - .layoutWeight(6) + .layoutWeight(6.0) .type(InputType.Number) - .fontSize(24) + .fontSize(24.0) .fontStyle(FontStyle.Italic) - .maxLength(20) + .maxLength(20.0) .fontWeight(FontWeight.Bold) - .placeholderFont({ size: 24, weight: FontWeight.Normal }) + .placeholderFont({ size: 24.0, weight: FontWeight.Normal }) .enterKeyType(EnterKeyType.Go) .onChange((value: string) => { this.age = Number(value); }) - Button() { + Button({} as ButtonOptions) { Text($r('app.string.age_analyse')) .fontColor(Color.White) - .fontSize(16) + .fontSize(16.0) } .key('ageAnalysis') - .layoutWeight(4) - .height(40) + .layoutWeight(4.0) + .height(40.0) .type(ButtonType.Capsule) .onClick(() => { this.ageRange(); }) } - .height(50) + .height(50.0) TempView() SleepView() } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) } dialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) { - getUIContext().showAlertDialog( + this.getUIContext().showAlertDialog( { title: title, message: message, @@ -115,14 +117,14 @@ export struct ScopeHelper { action: () => { } }, - } + } as AlertDialogParamWithConfirm ); } ageRange() { let tempLower = new ScopeNumber(AGE_MIN); let tempUpper = new ScopeNumber(AGE_MAX); - let range = new util.Scope(tempLower, tempUpper); + let range = new util.ScopeHelper(tempLower, tempUpper); let ageTemp = new ScopeNumber(this.age); if (range.contains(ageTemp)) { this.dialog($r('app.string.age'), $r('app.string.age_message_confirm'), $r('app.string.determine')); diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets index 28e8a950afded431ae12f7d3362359090ed7c67d..c8ce475c33c94dc740ea71dd148df776b9b0ce4d 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets @@ -15,14 +15,13 @@ */ import { - Preview, + // Preview, Component, State, Scroll, Column, Row, Text, - $r, TextAlign, Button, FontWeight, @@ -30,13 +29,19 @@ import { Divider, BarState, Alignment, + $r, + Padding, + Margin, + ClickEvent, + ColumnOptions, + ButtonOptions } from '@kit.ArkUI'; import util from '@ohos.util'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; import { SpecInput } from './stringcode/SpecInput'; -@Preview +// @Preview @Component export struct StringCode { @State specStrInput_f: string = ''; @@ -47,17 +52,17 @@ export struct StringCode { @State resdec: string = ''; @State read: string = ''; @State write: string = ''; - private resArray: Uint8Array | undefined = undefined; + private resArray: Uint8Array = new Uint8Array(0); build() { Scroll() { - Column({ space: 12 }) { + Column({ space: 12.0 } as ColumnOptions) { Row() { Text($r('app.string.SpecString')) - .fontSize(15) + .fontSize(15.0) .textAlign(TextAlign.Start) Text($r('app.string.SpecString_info')) - .fontSize(15) + .fontSize(15.0) .textAlign(TextAlign.Start) } @@ -65,16 +70,16 @@ export struct StringCode { SpecInput({ result_str: $r('app.string.result_i'), specStrInput: this.specStrInput_i }) SpecInput({ result_str: $r('app.string.result_d'), specStrInput: this.specStrInput_d }) SpecInput({ result_str: $r('app.string.result_s'), specStrInput: this.specStrInput_s }) - Button() { + Button({} as ButtonOptions) { Text($r('app.string.SpecFormOutput')) - .fontSize(15) + .fontSize(15.0) .fontWeight(FontWeight.Bold) .fontColor(Color.White) } .id('specFormatOutput') .width('100%') - .height(40) - .onClick(() => { + .height(40.0) + .onClick((e:ClickEvent):void => { this.specStrInput_f = util.format("%f", "OpenHarmony 3.0") this.specStrInput_i = util.format("%i", "OpenHarmony 3.0") this.specStrInput_d = util.format("%d", "OpenHarmony 3.0") @@ -82,110 +87,110 @@ export struct StringCode { }) Divider() - .strokeWidth(4) + .strokeWidth(4.0) .color($r('sys.color.ohos_id_color_floating_button_shadow_end')) Row() { Text($r('app.string.SpecString')) - .fontSize(15) + .fontSize(15.0) .textAlign(TextAlign.Start) Text($r('app.string.StringCodec_info')) - .fontSize(15) - .margin({ left: 5 }) + .fontSize(15.0) + .margin({ left: 5.0 }as Margin) .textAlign(TextAlign.Start) } Row() { Text($r('app.string.result')) .width('20%') - .height(30) - .fontSize(15) + .height(30.0) + .fontSize(15.0) .textAlign(TextAlign.Start) Text(this.resen) - .height(60) - .fontSize(15) - .layoutWeight(1) - .maxLines(2) + .height(60.0) + .fontSize(15.0) + .layoutWeight(1.0) + .maxLines(2.0) .textAlign(TextAlign.Start) - .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + .border({ width: 2.0, radius: 5.0, color: $r('app.color.text_color') }) } - .margin({ top: 20 }) + .margin({ top: 20.0 } as Margin) .width('100%') Row() { Text($r('app.string.read')) .width('20%') - .fontSize(15) + .fontSize(15.0) .textAlign(TextAlign.Start) Text(this.read) .id('read') .width('30%') - .fontSize(15) - .height(30) + .fontSize(15.0) + .height(30.0) .textAlign(TextAlign.Start) - .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + .border({ width: 2.0, radius: 5.0, color: $r('app.color.text_color') }) Text($r('app.string.write')) .width('20%') - .fontSize(15) + .fontSize(15.0) .textAlign(TextAlign.Center) Text(this.write) .id('write') .width('30%') - .fontSize(15) - .height(30) + .fontSize(15.0) + .height(30.0) .textAlign(TextAlign.Start) - .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + .border({ width: 2.0, radius: 5.0, color: $r('app.color.text_color') }) } .width('100%') - Button() { + Button({} as ButtonOptions) { Text($r('app.string.Text_encoder')) .fontColor(Color.White) - .fontSize(15) + .fontSize(15.0) .fontWeight(FontWeight.Bold) } .id('textEncoder') .width('100%') - .height(40) - .onClick(() => { + .height(40.0) + .onClick((event: ClickEvent):void => { this.textEncode(); }) Row() { Text($r('app.string.result')) .width('20%') - .height(30) - .fontSize(15) + .height(30.0) + .fontSize(15.0) .textAlign(TextAlign.Start) .fontColor(Color.Black) Text(this.resdec) .id('decRes') .width('80%') - .height(60) - .fontSize(15) + .height(60.0) + .fontSize(15.0) .textAlign(TextAlign.Start) - .maxLines(2) - .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + .maxLines(2.0) + .border({ width: 2.0, radius: 5.0, color: $r('app.color.text_color') }) } - .margin({ top: 20 }) - .width(300) + .margin({ top: 20.0 } as Margin) + .width(300.0) - Button() { + Button({} as ButtonOptions) { Text($r('app.string.Text_decoder')) .fontColor(Color.White) - .fontSize(15) + .fontSize(15.0) .fontWeight(FontWeight.Bold) } .id('textDecoder') .width('100%') - .height(40) - .margin({ bottom: 50 }) - .onClick(() => { + .height(40.0) + .margin({ bottom: 50.0 }as Margin) + .onClick((event: ClickEvent):void => { this.textDecode(); }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) @@ -193,13 +198,14 @@ export struct StringCode { textEncode() { let textEncoder = new util.TextEncoder(); - let buffer = new ArrayBuffer(100); + let buffer = new ArrayBuffer(100.0); this.resArray = new Uint8Array(buffer); - this.resArray = textEncoder.encodeInto(getString($r('app.string.message'))); - let resArratNum = textEncoder.encodeIntoUint8Array(getString($r('app.string.message')), this.resArray); + this.resArray = textEncoder.encodeInto(getString($r('app.string.message'), this.getUIContext())); + let resArratNum = textEncoder.encodeIntoUint8Array(getString($r('app.string.message'), this.getUIContext()), + this.resArray); this.resen = this.resArray.toString(); - this.read = JSON.stringify(resArratNum.read); - this.write = JSON.stringify(resArratNum.written); + this.read = JSON.stringify(resArratNum?.read??0); + this.write = JSON.stringify(resArratNum?.written??0); } textDecode() { @@ -207,7 +213,6 @@ export struct StringCode { if (this.resArray === undefined) { return; } - this.resdec = textDecoder.decodeWithStream(this.resArray, { stream: false }); + this.resdec = textDecoder.decodeToString(this.resArray, { stream: false }); } -} - +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets index 90fe30553d9f54a32801280964b0724aab774c1c..6f61ff7ffdc38935026c1db2fb37e268f9dbb7ec 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets @@ -15,7 +15,7 @@ */ import { - Preview, + // Preview, Component, State, Scroll, @@ -24,42 +24,43 @@ import { Color, BarState, Alignment, + Padding, + Margin, } from '@kit.ArkUI'; import { ShowKey } from './typecheck/ShowKey'; import { CheckType } from './typecheck/CheckType'; - let int8Array: Int8Array = new Int8Array(new ArrayBuffer(8)); -let numVal: Number = new Number(55); -let strVal: String = new String('zhangsan'); -let boolVal: Boolean = new Boolean(true); -; +let numVal: number = 55.0; +let strVal: string = 'zhangsan'; +let boolVal: boolean = true; + for (let i: int = 0; i < int8Array.length; i++) { int8Array[i] = i; } -@Preview +// @Preview @Component export struct TypeCheck { @State checkResult: string = ''; - @State presetValue: Array = [numVal, strVal, boolVal, int8Array]; + @State presetValue: Array = [numVal, strVal, boolVal, int8Array]; build() { Scroll() { Column() { Text(this.checkResult) .width('100%') - .height(200) - .fontSize(20) - .margin(20) - .padding({ left: 5, right: 5 }) - .border({ width: 2, radius: 15, color: Color.Gray }) + .height(200.0) + .fontSize(20.0) + .margin(20.0) + .padding({ left: 5.0, right: 5.0 } as Padding) + .border({ width: 2.0, radius: 15.0, color: Color.Gray }) ShowKey({ presetValue: this.presetValue, checkResult: this.checkResult }) CheckType({ presetValue: this.presetValue, checkResult: this.checkResult }) } .width('100%') - .padding(16) + .padding(16.0) } .scrollBar(BarState.Off) .align(Alignment.Start) diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets index fe701df6ec258c2d7de77e64800cdef92949c3e9..8ad7956ce1060f57f1789f830e993260c870c72a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets @@ -25,48 +25,53 @@ import { ForEach, ListItem, Row, + $r, + Padding, + Margin, + ClickEvent, + } from '@kit.ArkUI'; @CustomDialog export struct ActionSheetDialog { private controller?: CustomDialogController; private title: string = ''; - private sheets: string[] = []; + private sheets: Array = new Array(); private action: (key: string) => void = () => {}; build() { Column() { Text(this.title) .width('100%') - .fontSize(18) + .fontSize(18.0) .fontColor(Color.Black) .textAlign(TextAlign.Center) - .margin({ top: 10, bottom: 10 }) + .margin({ top: 10.0, bottom: 10.0 } as Margin) List() { ForEach(this.sheets, (item: string) => { ListItem() { Row() { Text('key:') - .fontSize(18) + .fontSize(18.0) .fontColor(Color.Gray) Text(item) - .fontSize(18) + .fontSize(18.0) .fontColor(Color.Gray) } .key('getValueOfTheKey') .width('100%') - .margin(10) + .margin(10.0) } .width('100%') - .onClick(() => { + .onClick((e: ClickEvent) => { this.controller?.close(); this.action(item); }) }) } .width('100%') - .margin({ bottom: 56 }) - .divider({ strokeWidth: 1, color: Color.Gray, startMargin: 5, endMargin: 5 }) + .margin({ bottom: 56.0 } as Margin) + .divider({ strokeWidth: 1.0, color: Color.Gray, startMargin: 5.0, endMargin: 5.0 }) } .width('80%') } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets index 419fcd3c3cb432a0bdb5b89fd52c31101eb3a4e8..83b532c633d428c5ff9e00a5ff354baeb05cb11d 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets @@ -18,7 +18,6 @@ import { Component, Link, Resource, - $r, Row, Text, TextInput, @@ -26,6 +25,10 @@ import { FontStyle, FontWeight, EnterKeyType, + $r, + Padding, + Margin, + ClickEvent, } from '@kit.ArkUI'; @Component @@ -37,19 +40,19 @@ export struct InputItem { build() { Row() { Text(this.textValue) - .layoutWeight(1) - .fontSize(20) + .layoutWeight(1.0) + .fontSize(20.0) TextInput({ placeholder: this.placeHolder }) .key('shortestSleepTime') - .layoutWeight(1) + .layoutWeight(1.0) .type(InputType.Normal) - .fontSize(20) + .fontSize(20.0) .fontStyle(FontStyle.Italic) - .maxLength(20) + .maxLength(20.0) .fontWeight(FontWeight.Bold) - .placeholderFont({ size: 16, weight: FontWeight.Normal }) + .placeholderFont({ size: 16.0, weight: FontWeight.Normal }) .enterKeyType(EnterKeyType.Go) - .onChange((value: string) => { + .onChange((value: string):void => { this.value = Number(value); }) } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets index 16dc4b5759682484a16f19af6d33f13f960d426f..15161936c7583a87d1ad94b4d0458bd855c4812e 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets @@ -19,26 +19,31 @@ import { State, Column, Text, - $r, Color, TextAlign, Button, ButtonType, HorizontalAlign, FlexAlign, - getUIContext, - AlertDialog, + UIContext, + $r, + Padding, + Margin, + ClickEvent, + ColumnOptions, + AlertDialogParamWithConfirm, + ButtonOptions } from '@kit.ArkUI'; import promptAction from '@ohos.promptAction'; import util from '@ohos.util'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; import { InputItem } from './InputItem'; import { ScopeNumber } from '../../../model/ScopeNumber'; -const ZERO: number = 0; -const SLEEP_TIME_SHORT: int = 7; -const SLEEP_TIME_LONG: int = 10; +const ZERO: number = 0.0; +const SLEEP_TIME_SHORT: number = 7.0; +const SLEEP_TIME_LONG: number = 10.0; @Component export struct SleepView { @@ -46,13 +51,13 @@ export struct SleepView { @State longTime: number = ZERO; build() { - Column({ space: 12 }) { + Column({ space: 12.0 }as ColumnOptions) { Text($r('app.string.judge_sleep')) - .fontSize(20) + .fontSize(20.0) .fontColor(Color.White) .backgroundColor(Color.Gray) .textAlign(TextAlign.Start) - .margin({ top: 2 }) + .margin({ top: 2.0 } as Margin) InputItem({ textValue: $r('app.string.short_sleep'), @@ -66,22 +71,22 @@ export struct SleepView { }) Text($r('app.string.sleep_time')) - .fontSize(18) + .fontSize(18.0) .fontColor(Color.Red) - Button() { + Button({} as ButtonOptions) { Text($r('app.string.sleep_analyse')) .fontColor(Color.White) - .fontSize(16) + .fontSize(16.0) .textAlign(TextAlign.Center) } .key('sleepAnalysis') .type(ButtonType.Capsule) .width('100%') - .height(45) - .margin({ top: 10, bottom: 10 }) + .height(45.0) + .margin({ top: 10.0, bottom: 10.0 } as Margin) .backgroundColor(0x317aff) - .onClick(() => { + .onClick((e: ClickEvent) => { this.sleepRange(); }) } @@ -92,32 +97,32 @@ export struct SleepView { sleepRange() { if (this.shortTime <= ZERO || this.longTime <= ZERO) { - getUIContext().getPromptAction.showToast({ message: $r("app.string.scope_sleep_tips") }); + this.getUIContext().getPromptAction().showToast({ message: $r("app.string.scope_sleep_tips") }); return; } if (this.longTime <= this.shortTime) { - getUIContext().getPromptAction.showToast({ message: $r("app.string.scope_sleep_tips_less") }); + this.getUIContext().getPromptAction().showToast({ message: $r("app.string.scope_sleep_tips_less") }); return; } let timeLower = new ScopeNumber(SLEEP_TIME_SHORT); let timeUpper = new ScopeNumber(SLEEP_TIME_LONG); - let timeRange = new util.ScopeHelper(timeLower, timeUpper); + let timeRange = new util.ScopeHelper(timeLower, timeUpper); let yTimeLower = new ScopeNumber(this.shortTime); let yTimeUpper = new ScopeNumber(this.longTime); - let yTimeRange = new util.ScopeHelper(yTimeLower, yTimeUpper); - let message = getString($r("app.string.scope_expand")); + let yTimeRange = new util.ScopeHelper(yTimeLower, yTimeUpper); + let message = getString($r("app.string.scope_expand"), this.getUIContext()); try { message += `${timeRange.expand(yTimeRange)}`; - } catch { - message += getString($r('app.string.empty')); + } catch(e) { + message += getString($r('app.string.empty'), this.getUIContext()); } - message += getString($r("app.string.scope_intersect")); + message += getString($r("app.string.scope_intersect"), this.getUIContext()); try { message += `${timeRange.intersect(yTimeRange)}`; - } catch { - message += getString($r('app.string.empty')); + } catch(e) { + message += getString($r('app.string.empty'), this.getUIContext()); } - getUIContext().showAlertDialog( + this.getUIContext().showAlertDialog( { title: $r('app.string.sleep_analyse'), message: message, @@ -126,7 +131,7 @@ export struct SleepView { action: () => { } }, - } + } as AlertDialogParamWithConfirm ); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets index 447597abdead29d2e1347d633e18b62930b6bbf2..947e49e458f6009462a561a188ae42281edd3944 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets @@ -19,7 +19,6 @@ import { State, Column, Text, - $r, Color, TextAlign, Button, @@ -27,18 +26,23 @@ import { HorizontalAlign, FlexAlign, ResourceStr, - getUIContext, - AlertDialog, + $r, + Padding, + Margin, + ClickEvent, + ColumnOptions, + UIContext, + AlertDialogParamWithConfirm, + ButtonOptions } from '@kit.ArkUI'; -import promptAction from '@ohos.promptAction'; import util from '@ohos.util'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; import { InputItem } from './InputItem'; import { ScopeNumber } from '../../../model/ScopeNumber'; -const ZERO: int = 0; -const TEMPERATURE_MIN: int = 36; +const ZERO: number = 0.0; +const TEMPERATURE_MIN: number = 36.0; const TEMPERATURE_MAX: number = 37.2; @Component @@ -48,13 +52,13 @@ export struct TempView { @State tempNight: number = ZERO; build() { - Column({ space: 12 }) { + Column({ space: 12.0 }as ColumnOptions) { Text($r('app.string.judge_temp')) - .fontSize(20) + .fontSize(20.0) .fontColor(Color.White) .backgroundColor(Color.Gray) .textAlign(TextAlign.Start) - .margin({ top: 2 }) + .margin({ top: 2.0 } as Margin) InputItem({ textValue: $r('app.string.temp_morning'), placeHolder: $r('app.string.morning_placeholder'), @@ -70,17 +74,17 @@ export struct TempView { placeHolder: $r('app.string.night_placeholder'), value: this.tempNight }) - Button() { + Button({} as ButtonOptions) { Text($r('app.string.temp_analyse')) .fontColor(Color.White) - .fontSize(16) + .fontSize(16.0) } .key('temperatureAnalysis') .type(ButtonType.Capsule) .width('100%') - .height(45) + .height(45.0) .backgroundColor(0x317aff) - .onClick(() => { + .onClick((e: ClickEvent) => { this.tempRange(); }) } @@ -90,7 +94,7 @@ export struct TempView { } alertDialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) { - getUIContext().showAlertDialog( + this.getUIContext().showAlertDialog( { title: title, message: message, @@ -99,24 +103,26 @@ export struct TempView { action: () => { } }, - } + } as AlertDialogParamWithConfirm ); } tempRange() { if (this.tempMorning <= ZERO || this.tempNoon <= ZERO || this.tempNight <= ZERO) { - getUIContext().getPromptAction.showToast({ message: $r("app.string.scope_temp_tips") }); + this.getUIContext().getPromptAction().showToast({ message: $r("app.string.scope_temp_tips") }); return; } - let arr = [this.tempMorning, this.tempNoon, this.tempNight].sort(); + let arrLength: number = 3.0; + let arr: Array = new Array(this.tempMorning, this.tempNoon, this.tempNight).sort(); let max = new ScopeNumber(arr[2]); let min = new ScopeNumber(arr[0]); let tempLower = new ScopeNumber(TEMPERATURE_MIN); let tempUpper = new ScopeNumber(TEMPERATURE_MAX); - let standardRange = new util.ScopeHelper(tempLower, tempUpper); + let standardRange = new util.ScopeHelper(tempLower, tempUpper); if (standardRange.contains(min) && standardRange.contains(max)) { - this.alertDialog($r('app.string.temperature'), getString($r('app.string.temp_min')) + min + getString($r('app.string.temp_max')) - + max + getString($r('app.string.temp_normal_range')), $r('app.string.determine')); + this.alertDialog($r('app.string.temperature'), getString($r('app.string.temp_min'), this.getUIContext()) + + min + getString($r('app.string.temp_max'), this.getUIContext()) + max + + getString($r('app.string.temp_normal_range'), this.getUIContext()), $r('app.string.determine')); } else { this.alertDialog($r('app.string.temperature'), $r('app.string.temp_message_abnormal'), $r('app.string.determine')); } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets index a26f13e9a13b4a6b7b6f9231eb3a2e726a30a20c..4d6f9e842955db89f7232918d2485b76c6e22190 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets @@ -17,11 +17,11 @@ import { Component, Resource, - $r, Link, Row, Text, TextAlign, + $r, } from '@kit.ArkUI'; @Component @@ -32,15 +32,15 @@ export struct SpecInput { build() { Row() { Text(this.result_str) - .height(30) - .fontSize(15) + .height(30.0) + .fontSize(15.0) .textAlign(TextAlign.Start) Text(this.specStrInput) - .height(30) - .layoutWeight(1) - .fontSize(15) + .height(30.0) + .layoutWeight(1.0) + .fontSize(15.0) .textAlign(TextAlign.Start) - .border({ width: 2, radius: 5, color: "#0D9FFB" }) + .border({ width: 2.0, radius: 5.0, color: "#0D9FFB" }) } .width('100%') } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets index c1bfc232c54ee972f393337d365cb2cc29f4b9b6..0aefae00ef761c31e8f80247930c8491c1f635a6 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets @@ -20,10 +20,12 @@ import { Link, Button, Text, - $r, Color, TextAlign, ButtonType, + $r, + Margin, + ButtonOptions } from '@kit.ArkUI'; import util from '@ohos.util'; @@ -36,20 +38,22 @@ export struct CheckType { check(value: Object) { let utilType: util.types = new util.types(); - let utilData: Map | null = new Map([ - ['ArrayBuffer', utilType.isAnyArrayBuffer(value)], - ['Int8Array', utilType.isInt8Array(value)], - ['Number', utilType.isNumberObject(value)], - ['String', utilType.isStringObject(value)], - ['Boolean', utilType.isBooleanObject(value)], - ['ArrayBuffer', utilType.isAnyArrayBuffer(value)], + let mapArray: Array<[string, boolean]> = [ + ['AnyArrayBuffer', utilType.isAnyArrayBuffer(value)], + ['ArrayBuffer', utilType.isArrayBuffer(value)], + ['ArrayBufferView', utilType.isArrayBufferView(value)], ['DataView', utilType.isDataView(value)], - ['Arguments', utilType.isArgumentsObject(value)], - ['AsyncFunction', utilType.isAsyncFunction(value)], - ['External', utilType.isExternal(value)], + ['Int8Array', utilType.isInt8Array(value)], ['Float32Array', utilType.isFloat32Array(value)], - ['Generator', utilType.isGeneratorFunction(value)] - ]); + // ['Number', utilType.isNumberObject(value)], + // ['String', utilType.isStringObject(value)], + // ['Boolean', utilType.isBooleanObject(value)], + // ['Arguments', utilType.isArgumentsObject(value)], + // ['AsyncFunction', utilType.isAsyncFunction(value)], + // ['External', utilType.isExternal(value)], + // ['Generator', utilType.isGeneratorFunction(value)] + ] + let utilData: Map | null = new Map(mapArray); for (let item of utilData) { if (item[1] === true) { this.result = item[0]; @@ -61,26 +65,26 @@ export struct CheckType { show() { let showResult: string = ''; - for (let i: int = 0; i < this.presetValue.length; i++) { - let typeResult = this.check(this.presetValue[i]); - showResult = showResult + `${this.presetValue[i]} check success,this value type is ${typeResult}\n`; + for (let i: number = 0.0; i < this.presetValue.length; i++) { + let typeResult = this.check(this.presetValue[i as int]); + showResult = showResult + `${this.presetValue[i as int]} check success,this value type is ${typeResult}\n`; } this.checkResult = showResult; } build() { - Button() { + Button({} as ButtonOptions) { Text($r('app.string.check')) .fontColor(Color.Black) - .fontSize(20) + .fontSize(20.0) .textAlign(TextAlign.Center) .width('85%') } .key('checkPresetValue') .type(ButtonType.Capsule) .backgroundColor('#0D9FFB') - .padding(5) - .margin({ top: 10 }) + .padding(5.0) + .margin({ top: 10.0 } as Margin) .onClick(() => { this.show(); }) diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets index 6fe422a510edb0a2515b10a0c311e0a0455d5488..2b83140aa3d0420974d700328a55444125bd06da 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets @@ -20,10 +20,12 @@ import { Link, Button, Text, - $r, Color, TextAlign, ButtonType, + Margin, + $r, + ButtonOptions } from '@kit.ArkUI'; @Component @@ -33,18 +35,18 @@ export struct ShowKey { @Link presetValue: Array; build() { - Button() { + Button({} as ButtonOptions) { Text($r('app.string.show')) .fontColor(Color.Black) - .fontSize(20) + .fontSize(20.0) .textAlign(TextAlign.Center) .width('85%') } .key('displayPresetValue') .type(ButtonType.Capsule) .backgroundColor('#0D9FFB') - .padding(5) - .margin({ top: 10 }) + .padding(5.0) + .margin({ top: 10.0 } as Margin) .onClick(() => { this.checkResult = `numberVal = ${this.presetValue[0]}\n` +`stringVal = ${this.presetValue[1]}\n` diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets index 8506b263ae5e58971471c71957cdbe75fb59f43f..7e97208dbee65810641e629060f97c2fc889258a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets @@ -1,4 +1,4 @@ -'use static' +// 'use static' /* * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,30 +14,31 @@ * limitations under the License. */ -import Vector from '@ohos.util.Vector'; -import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; -import { Information } from '../../model/Information'; - -export class VectorDataSource extends BaseDataSource { - private dataArr: Vector = new Vector(); - - public totalCount(): number { - return this.dataArr.length; - } - - public getData(index: number): Information { - return this.dataArr.get(index); - } - - public addData(information: Information): void { - this.dataArr.add(information); - this.notifyDataAdd(this.dataArr.length - 1); - this.notifyDataReload(); - } - - public deleteData(index: number): void { - this.dataArr.removeByIndex(index); - this.notifyDataDelete(index); - this.notifyDataReload(); - } -} \ No newline at end of file +// // import { Vector } from '@kit.ArkTS'; +// // import Vector from '@ohos.util.Vector'; +// import { BaseDataSource } from 'common'; +// import { Information } from '../../model/Information'; +// +// export class VectorDataSource extends BaseDataSource { +// private dataArr: Vector = new Vector(); +// +// public totalCount(): number { +// return this.dataArr.length; +// } +// +// public getData(index: number): Information { +// return this.dataArr.get(index); +// } +// +// public addData(information: Information): void { +// this.dataArr.add(information); +// this.notifyDataAdd(this.dataArr.length - 1.0); +// this.notifyDataReload(); +// } +// +// public deleteData(index: int): void { +// this.dataArr.removeByIndex(index); +// this.notifyDataDelete(index); +// this.notifyDataReload(); +// } +// } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets index 5d50efc9dd981e5b23c0ab6625ce88934f492d5e..ad64e74bd7158d8151886e350484f4cbfd4c7177 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets @@ -13,23 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from '@ohos.util' -export class ScopeNumber { +export class ScopeNumber implements util.ScopeComparable { temp: number; constructor(value: number) { this.temp = value; } - compareTo(value: ScopeNumber) { - return this.temp >= value.getTemp(); + compareTo(other: ScopeNumber): boolean { + return this.getTemp() >= other.getTemp(); } - getTemp() { + getTemp(): number { return this.temp; } - toString() { + toString(): string { return this.temp.toString(); } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets index ea8f8cf82ed1d6ae8006c9e89a2200161a545cb0..aaa2ce38f4781f495ffbd2899028564568da4b24 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets @@ -16,12 +16,12 @@ import ConvertXML from '@ohos.convertxml'; import xml from '@ohos.xml'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { logger } from 'common'; const TAG: string = 'ConvertXmlUtil'; export function serializerNode(): string { - let arrayBuffer = new ArrayBuffer(1024); + let arrayBuffer = new ArrayBuffer(1024.0); let serializer = new xml.XmlSerializer(arrayBuffer); serializer.setDeclaration(); serializer.setNamespace('h', 'https://gitee.com/openharmony'); @@ -35,22 +35,22 @@ export function serializerNode(): string { serializer.endElement(); let array = new Uint8Array(arrayBuffer); let serializerStr = ''; - for (let i: int = 0; i < array.length; ++i) { - serializerStr = serializerStr + String.fromCodePoint(array[i]); + for (let i: number = 0.0; i < array.length; ++i) { + serializerStr = serializerStr + String.fromCodePoint(array[i as int]); } return serializerStr; } export function parserNode(input: string): string { - let arrayBuffer = new ArrayBuffer(input.length * 2); + let arrayBuffer = new ArrayBuffer(input.length * 2.0); let bufView = new Uint8Array(arrayBuffer); - let strLen = input.length; - for (let k: int = 0; k < strLen; ++k) { - bufView[k] = input.charCodeAt(k); + let strLen: number = input.length; + for (let k: number = 0.0; k < strLen; ++k) { + bufView[k as int] = input.charCodeAt(k); } let parser = new xml.XmlPullParser(arrayBuffer); let arr: Record = {}; - let i: int = 0; + let i: number = 0.0; let func = (key: xml.EventType, info: xml.ParseInfo) => { arr[i] = `key:${key}, value:${info.getDepth()} ${info.getColumnNumber()} ` + @@ -61,9 +61,9 @@ export function parserNode(input: string): string { } let options: xml.ParseOptions = { supportDoctype: true, ignoreNameSpace: true, tokenValueCallbackFunction: func }; - parser.parse(options); + parser.parseXml(options); let str = ''; - for (let j: int = 0; j < i; ++j) { + for (let j: number = 0.0; j < i; ++j) { str = str + arr[j]; } return str; @@ -90,4 +90,5 @@ export function convertNode(input: string): string { let result = JSON.stringify(conv.convertToJSObject(input, options)); logger.info(TAG, `convertNode conv.convert result = ${result}`); return JSON.stringify(result); -} + return '' +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets index 7ef90dc47e11890d0cf5c22131cd51a613259a1b..eaed7b1c68c0ac8eff83f1734b0ed02d5398b67d 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets @@ -15,19 +15,20 @@ */ import { - $r, Resource, - getUIContext, + $r, + UIContext, } from '@kit.ArkUI'; +import { getString } from 'common'; import common from '@ohos.app.ability.common'; import util from '@ohos.util'; export let lruBuffer: util.LRUCache = new util.LRUCache(); -export function initLRUCache(): string { +export function initLRUCache(uIContext: UIContext): string { lruBuffer = new util.LRUCache(); - return getString($r('app.string.create_lru_cache')); + return getString($r('app.string.create_lru_cache'), uIContext); } export function getCapacity(): string { @@ -35,7 +36,7 @@ export function getCapacity(): string { } export function updateCapacity(): string { - lruBuffer.updateCapacity(100); + lruBuffer.updateCapacity(100.0); return `update capacity success,capacity=${lruBuffer.getCapacity()}`; } @@ -43,14 +44,14 @@ export function getCacheString(): string { return lruBuffer.toString(); } -export function clear(): string { +export function clear(uIContext: UIContext): string { lruBuffer.clear(); - return getString($r('app.string.clear')); + return getString($r('app.string.clear'), uIContext); } -export function putKeyValue(): string { - lruBuffer.put(randomString(3), randomString(5)); - return getString($r('app.string.put_success')); +export function putKeyValue(uIContext: UIContext): string { + lruBuffer.put(randomString(3.0), randomString(5.0)); + return getString($r('app.string.put_success'), uIContext); } export function operationLog(): string { @@ -63,19 +64,13 @@ export function operationLog(): string { + `getPutCount=${lruBuffer.getPutCount()}\n`; } -export function getString(resource: Resource) { - let context = getUIContext().getHostContext() as common.UIAbilityContext; - let resultStr = context.resourceManager.getStringSync(resource); - return resultStr; -} - export function randomString(length: number): string { - length = length || 32; - let string = 'abcdefhijkmnprstwxyz123456789'; - let maxLength = string.length; + length = length || 32.0; + let str = 'abcdefhijkmnprstwxyz123456789'; + let maxLength: number = str.length; let resultString = ''; - for (let i: int = 0; i < length; i++) { - resultString += string.charAt(Math.floor(Math.random() * maxLength)); + for (let i: number = 0.0; i < length; i++) { + resultString += str.charAt(Math.floor(Math.random() * maxLength)); } return resultString; } @@ -87,6 +82,5 @@ export function getAllKeyValues(): string { keyArr.forEach((key: string, index: number) => { result += `key: ${key}, value: ${valueArr[index as int]}\n`; }) - return result; } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets index 2d073aea685a54d0186553cd752d3a4bce211558..e1620192180cde789ba16252635979f7a562e5ee 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets @@ -1,4 +1,4 @@ -'use static' +'use static'; /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,69 +13,68 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { $r } from '@kit.ArkUI'; +import { $r, UIContext } from '@kit.ArkUI'; import util from '@ohos.util'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; -const NUMERATOR1: int = 1; -const DENOMINATOR1: int = 2; -const NUMERATOR2: int = 3; -const DENOMINATOR2: int = 4; +const NUMERATOR1: number = 1.0; +const DENOMINATOR1: number = 2.0; +const NUMERATOR2: number = 3.0; +const DENOMINATOR2: number = 4.0; const RATIONAL_NUMBER1 = util.RationalNumber.parseRationalNumber(NUMERATOR1, DENOMINATOR1); const RATIONAL_NUMBER2 = util.RationalNumber.parseRationalNumber(NUMERATOR2, DENOMINATOR2); -export function compareTo(): string { - let result = RATIONAL_NUMBER1.compare(RATIONAL_NUMBER2) - if (result === 0) { - return getString($r('app.string.equal_to')); +export function compareTo(uIContext: UIContext): string { + let result: number = RATIONAL_NUMBER1.compare(RATIONAL_NUMBER2); + if (result === 0.0) { + return getString($r('app.string.equal_to'), uIContext); } - if (result === 1) { - return getString($r('app.string.greater_than')); + if (result === 1.0) { + return getString($r('app.string.greater_than'), uIContext); } - if (result === -1) { - return getString($r('app.string.less_than')); + if (result === -1.0) { + return getString($r('app.string.less_than'), uIContext); } return ''; } -export function getValueOf(): string { - let valueOf = RATIONAL_NUMBER1.valueOf(); - return `${getString($r('app.string.rational_number_value_of'))}${valueOf}`; +export function getValueOf(uIContext: UIContext): string { + let valueOf: number = RATIONAL_NUMBER1.valueOf(); + return `${getString($r('app.string.rational_number_value_of'), uIContext)}${valueOf}`; } -export function getDenominator(): string { - let numerator = RATIONAL_NUMBER1.getNumerator(); - let denominator = RATIONAL_NUMBER1.getDenominator(); - return `${getString($r('app.string.numerator'))}${numerator}, ${getString($r('app.string.denominator'))}${denominator}`; +export function getDenominator(uIContext: UIContext): string { + let numerator: number = RATIONAL_NUMBER1.getNumerator(); + let denominator: number = RATIONAL_NUMBER1.getDenominator(); + return `${getString($r('app.string.numerator'), uIContext)}${numerator}, + ${getString($r('app.string.denominator'), uIContext)}${denominator}`; } -export function isZero(): string { +export function isZero(uIContext: UIContext): string { let isZero = RATIONAL_NUMBER1.isZero(); console.log('ButtonComponent isZero' + isZero); if (isZero) { - return `${getString($r('app.string.first_rational_number'))} is zero`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is zero`; } else { - return `${getString($r('app.string.first_rational_number'))} is not zero`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is not zero`; } } -export function isNaN(): string { +export function isNaN1(uIContext: UIContext): string { let isNaN = RATIONAL_NUMBER1.isNaN(); if (isNaN) { - return `${getString($r('app.string.first_rational_number'))} is NaN`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is NaN`; } else { - return `${getString($r('app.string.first_rational_number'))} is not NaN`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is not NaN`; } } -export function isFinite(): string { +export function isFinite1(uIContext: UIContext): string { let isFinite = RATIONAL_NUMBER1.isFinite(); if (isFinite) { - return `${getString($r('app.string.first_rational_number'))} is Finite`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is Finite`; } else { - return `${getString($r('app.string.first_rational_number'))} is not Finite`; + return `${getString($r('app.string.first_rational_number'), uIContext)} is not Finite`; } -} - +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets index b56be07232721615d24ccdcd289dfaee1712c63e..cce0da5764903d2adcc73dc6a5bd0e9d31f47631 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets @@ -1,29 +1,28 @@ -'use static' +'use static'; /* -* Copyright (c) 2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import { $r } from '@kit.ArkUI'; + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { $r, UIContext } from '@kit.ArkUI'; import url from '@ohos.url'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { getString } from 'common'; let urlObject = url.URL.parseURL('https://gitee.com/openharmony/'); -let paramsObject = new url.URLParams(urlObject.search.slice(1)); +let paramsObject = new url.URLParams(urlObject.search.slice(1.0)); let nodeValue: string = 'nodeValue'; let nodeKey: string = 'node'; -let nodeNum: int = 0; +let nodeNum: number = 0.0; export function insertNode(): string { nodeNum++; @@ -34,24 +33,24 @@ export function insertNode(): string { export function deleteNode(): string { if (paramsObject.has(nodeKey)) { paramsObject.delete(nodeKey); - nodeNum = 0; + nodeNum = 0.0; return urlObject.toString() + paramsObject.toString(); } else { - return "It does not exist. Please insert first"; + return 'It does not exist. Please insert first'; } } -export function getFirstNode(): string { +export function getFirstNode(uIContext: UIContext): string { if (paramsObject.has(nodeKey)) { - let fod = paramsObject.get(nodeKey); + let fod = paramsObject.get(nodeKey) as string;; return fod !== null ? fod.toString() : ''; } else { - return getString($r('app.string.please_insert')); + return getString($r('app.string.please_insert'), uIContext); } } export function changeValue(): string { paramsObject.set(nodeKey, 'newValue'); - nodeNum = 0; + nodeNum = 0.0; return urlObject.toString() + paramsObject.toString(); } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 index 2cff837a1f1873cb9ad84518e5b6fa847767c2ba..260197ff2e4a1a70dd8d3e7eca611ed96c7d8f70 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,7 @@ "name": "capabilities", "type": "har", "deviceTypes": [ - "default", - "tablet" + "default" ] } -} \ No newline at end of file +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/float.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json index f0ca7048c81c72859e39de84e272290ac446e712..af9e12f4ff3963d26254c172cf00b3adc9af37e5 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json @@ -48,6 +48,10 @@ "name": "close_success", "value": "close success" }, + { + "name": "process", + "value": "process" + }, { "name": "child_null", "value": "child process is null" @@ -389,4 +393,4 @@ "value": "key must be a number" } ] -} +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2b1fa431d1cb1bd0c2541ab66674b982a181209b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "capabilities_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/LocalUnit.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore index 5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96..e2713a2779c5a3e0eb879efe6115455592caeea5 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore @@ -1,4 +1,6 @@ /node_modules +/oh_modules /.preview /build -/.cxx \ No newline at end of file +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 index 12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1..aefa5f6959f0e65b9347a5182401ee9f4873007a 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,9 +17,30 @@ "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], "targets": [ { "name": "default" + }, + { + "name": "ohosTest" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/consumer-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts index 6522df25794b80abde0b0aa8654f3970c4a35cfa..8b916a32c526d654b0110abdb28f04e0bc874769 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,5 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file + +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets index 4bf4e3a769b3ca072777bf2cbf56ccd1615a07bb..8fd611cda2b40b6b7f3241e9c0786e9664a15557 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets @@ -1,3 +1,4 @@ +'use static' /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,4 +16,4 @@ export { MenuList } from './src/main/ets/menulist/MenuList'; -export { MenuNavRouter } from './src/main/ets/components/MenuNavRouter'; +// export { MenuNavRouter } from './src/main/ets/components/MenuNavRouter'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package-lock.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f5e7f8631140c165b9e021c472068f90760d052f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package-lock.json5 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "common@../../common": "common@../../common" + }, + "packages": { + "common@../../common": { + "name": "common", + "version": "1.2.0", + "resolved": "", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 index e6ebdefa6c9f787dd38f8fd8b10f43ed1db852dd..455bce95da750c612bd8b2c775e05f608d94e154 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,14 +14,13 @@ */ { - "license": "ISC", - "types": "", - "devDependencies": {}, "name": "menuitems", - "description": "a npm package which contains arkUI2.0 page", - "main": "index.ets", - "version": "1.0.0", + "version": "1.2.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", "dependencies": { - "@ohos/common": "file:../../common" + "common": "file:../../common" } } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets index c3293c817472b68797a46aec85f56fac0554bdfa..f82b692899cba99f5036be352836c95e1dda78ee 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets @@ -19,20 +19,21 @@ import { BuilderParam, Column, $r, + Margin } from '@kit.ArkUI'; @Component export struct ItemGroup { - @BuilderParam noParam: () => void; + @BuilderParam noParam: () => void = () =>{}; build() { Column() { this.noParam() } .width('100%') - .borderRadius(24) + .borderRadius(24.0) .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) - .padding(4) - .margin({ bottom: 12 }) + .padding(4.0) + .margin({ bottom: 12.0 } as Margin) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets index b06a1746fdd48ce5f0b8d93b6997c6c7c92b3169..d765c5f31a381e56149935f961f72e3a496b9092 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets @@ -14,8 +14,6 @@ * limitations under the License. */ -import { LocalStoragePropRef } from '@kit.ArkUI'; - import { Component, Resource, @@ -23,45 +21,54 @@ import { Row, Text, FontWeight, - $r, Alignment, Blank, Image, VerticalAlign, TouchEvent, TouchType, + Margin, + Padding, + $r, + StorageLink, + NavPathStack, + AppStorage } from '@kit.ArkUI'; @Component export struct MainItem { - private title: string | Resource = ''; - @LocalStoragePropRef('isSplitMode') isSplitMode: boolean = false; @State isTouched: boolean = false; + @StorageLink('selectedLabel') selectedLabel: string = ''; + @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; + private title: string | Resource = ''; + pageStack: NavPathStack = AppStorage.get('PathStack') as NavPathStack; + private isSecond: boolean = false; + build() { Row() { Text(this.title) - .fontSize(16) - .lineHeight(22) + .fontSize(16.0) + .lineHeight(22.0) .fontWeight(FontWeight.Medium) .fontFamily('HarmonyHeiTi') .fontColor($r('sys.color.ohos_id_color_text_primary')) .align(Alignment.Start) - .margin({ left: 16 }) + .margin({ left: 16.0 } as Margin) Blank() Image($r('app.media.ic_arrow')) - .width(12) - .height(24) - .margin({ left: 4 }) + .width(12.0) + .height(24.0) + .margin({ left: 4.0 } as Margin) .fillColor($r('sys.color.ohos_id_color_fourth')) } .alignItems(VerticalAlign.Center) .width('100%') - .height(56) - .borderRadius(20) - .padding({ left: 8, right: 8 }) + .height(56.0) + .borderRadius(20.0) + .padding({ left: 8.0, right: 8.0 } as Padding) .backgroundColor(this.isTouched ? $r('app.color.itemActivated') : $r('app.color.itemInactivated')) .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { @@ -70,5 +77,14 @@ export struct MainItem { this.isTouched = false; } }) + .onClick(() => { + if (this.isSecond == false) { + this.selectedLabel = this.title as string + this.pageStack.pushPathByName('Capabilities', new Object(), () => {}) + } else { + this.selectedSecondLabel = this.title as string + this.pageStack.pushPathByName('Util', new Object(), () => {}) + } + }) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets index 726ac44ed43e3b60e733444d9a99d2629449c98f..affced852a7e9823a05201f3948eb5ec500f8642 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets @@ -1,4 +1,4 @@ -'use static' +// 'use static' /** * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,146 +14,136 @@ * limitations under the License. */ -import { - Component, - StorageLink, - BuilderParam, - Builder, - Divider, - $r, - Column, - ForEach, - NavRouter, - NavDestination, - Row, - Text, - FontWeight, - Image, - ImageFit, - Visibility, - FlexAlign, - Resource, - getUIContext, -} from '@kit.ArkUI'; - -import common from '@ohos.app.ability.common'; -import { ItemGroup } from './ItemGroup'; -import { logger } from '@ohos/common/src/main/ets/util/Logger'; -import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; -import { MainItem } from './MainItem'; - -const TAG: string = 'MenuNavRouter'; - -@Component -export struct MenuNavRouter { - @StorageLink('selectedLabel') selectedLabel: string = ''; - @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; - @BuilderParam navDestination: () => void; - private childList: Array = []; - private addAction?: (title: string) => void; - - @Builder CustomDivider() { - Divider() - .strokeWidth('1px') - .color($r('sys.color.ohos_id_color_list_separator')) - .margin({ left: 8, right: 8 }) - } - - build() { - ItemGroup() { - Column() { - ForEach(this.childList, (item: string, index: number) => { - if (index > 0) { - this.CustomDivider() - } - NavRouter() { - MainItem({ - title: item - }) - NavDestination() { - this.navDestination() - } - .title(() => { - this.CustomTitle(item) - }) - .backgroundColor($r('sys.color.ohos_id_color_sub_background')) - } - .onStateChange((isActivated: boolean) => { - // 组件激活状态切换时 - if (isActivated) { - // 点击一级路由菜单进入时 - if (this.addAction) { - this.selectedLabel = item; - logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedLabel=${item}`); - } - // 点击二级路由菜单进入时 - else { - this.selectedSecondLabel = item; - logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedSecondLabel=${item}`); - } - } - }) - }, (item: string) => JSON.stringify(item)) - } - } - } - - @Builder - CustomTitle(title: string) { - Row() { - Text(title) - .fontColor($r('app.color.black')) - .fontSize(16) - .fontWeight(FontWeight.Bold) - - Row() { - Image($r('app.media.ic_public_add')) - .height(24) - .aspectRatio(1) - .objectFit(ImageFit.Contain) - } - .id('add') - .height('100%') - .aspectRatio(1) - .visibility(this.showAddButton(title) ? Visibility.Visible : Visibility.None) - .onClick(() => { - logger.info(TAG, 'addAction') - if (this.addAction) { - this.addAction(title) - } - }) - } - .width('85%') - .height(56) - .justifyContent(FlexAlign.SpaceBetween) - } - - showAddButton(title: string) { - let ret = false - switch (title) { - case getString($r('app.string.deque')): - case getString($r('app.string.hash_map')): - case getString($r('app.string.hash_set')): - case getString($r('app.string.light_weight_map')): - case getString($r('app.string.light_weight_set')): - case getString($r('app.string.linked_list')): - case getString($r('app.string.list')): - case getString($r('app.string.plain_array')): - case getString($r('app.string.queue')): - case getString($r('app.string.stack')): - case getString($r('app.string.tree_map')): - case getString($r('app.string.tree_set')): - case getString($r('app.string.vector')): - ret = true - break; - } - return ret - } - - getString(resource: Resource) { - let context = getUIContext().getHostContext(this) as common.UIAbilityContext; - let resultStr = context.resourceManager.getStringSync(resource); - logger.info(TAG, `getString = ${resultStr}`); - return resultStr; - } -} \ No newline at end of file +// import { +// Component, +// StorageLink, +// BuilderParam, +// Builder, +// Divider, +// Column, +// ForEach, +// NavDestination, +// NavPathStack, +// Row, +// Text, +// FontWeight, +// Image, +// ImageFit, +// Visibility, +// FlexAlign, +// Resource, +// $r, +// Margin, +// Padding, +// ClickEvent +// } from '@kit.ArkUI'; +// import { common } from '@kit.AbilityKit'; +// import { logger } from 'common'; +// import { ItemGroup } from './ItemGroup'; +// import { MainItem } from './MainItem'; +// +// @Component +// export struct MenuNavRouter { +// // @StorageLink('selectedLabel') selectedLabel: string = ''; +// // @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; +// // @BuilderParam navDestination: () => void = ()=>{}; +// private childList: Array = ['']; +// // private addAction: (title: string) => void = ()=>{}; +// +// @Builder CustomDivider() { +// Divider() +// .strokeWidth('1px') +// .color($r('sys.color.ohos_id_color_list_separator')) +// .margin({ left: 8.0, right: 8.0 }as Margin) +// } +// +// build() { +// ItemGroup() { +// Column() { +// ForEach(this.childList, (item: string, index: number) => { +// if (index > 0.0) { +// this.CustomDivider() +// } +// MainItem({ title: item }) +// +// // NavDestination() { this.navDestination } +// // .title(() => { +// // this.CustomTitle(item) +// // }) +// // .backgroundColor($r('sys.color.ohos_id_color_sub_background')) +// // .onActive(() => { +// // // 点击一级路由菜单进入时 +// // if (this.addAction) { +// // this.selectedLabel = item; +// // logger.info(TAG, `NavRouter selectedLabel=${item}`); +// // } +// // // 点击二级路由菜单进入时 +// // else { +// // this.selectedSecondLabel = item; +// // logger.info(TAG, `NavRouter selectedSecondLabel=${item}`); +// // } +// // }) +// }, (item: string) => JSON.stringify(item)) +// } +// } +// } +// +// @Builder +// CustomTitle(title: string) { +// Row() { +// Text(title) +// .fontColor($r('app.color.black')) +// .fontSize(16.0) +// .fontWeight(FontWeight.Bold) +// +// Row() { +// Image($r('app.media.ic_public_add')) +// .height(24.0) +// .aspectRatio(1.0) +// .objectFit(ImageFit.Contain) +// } +// .id('add') +// .height('100%') +// .aspectRatio(1.0) +// .visibility(this.showAddButton(title) ? Visibility.Visible : Visibility.None) +// .onClick((e: ClickEvent) => { +// logger.info(TAG, 'addAction') +// if (this.addAction) { +// this.addAction(title) +// } +// }) +// } +// .width('85%') +// .height(56.0) +// .justifyContent(FlexAlign.SpaceBetween) +// } +// +// showAddButton(title: string) { +// let ret = false +// switch (title) { +// case this.getString($r('app.string.deque')): +// case this.getString($r('app.string.hash_map')): +// case this.getString($r('app.string.hash_set')): +// case this.getString($r('app.string.light_weight_map')): +// case this.getString($r('app.string.light_weight_set')): +// case this.getString($r('app.string.linked_list')): +// case this.getString($r('app.string.list')): +// case this.getString($r('app.string.plain_array')): +// case this.getString($r('app.string.queue')): +// case this.getString($r('app.string.stack')): +// case this.getString($r('app.string.tree_map')): +// case this.getString($r('app.string.tree_set')): +// case this.getString($r('app.string.vector')): +// ret = true +// break; +// } +// return ret +// } +// +// getString(resource: Resource): string { +// let context = this.getUIContext().getHostContext() as common.UIAbilityContext; +// let resultStr = context.resourceManager.getStringSync(resource.id); +// logger.info(TAG, `getString = ${resultStr}`); +// return resultStr +// } +// } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets index 3c77630adc90ab6fd0e7aa36ac7f90173f4546fa..a632cb9dd66840759bab30dab55a1e61a6968774 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets @@ -16,50 +16,72 @@ import { Component, - State, - BuilderParam, + // BuilderParam, Resource, List, ListItem, - $r, BarState, + Padding, + Margin, + $r, + Column, + ForEach, + Builder, + Divider } from '@kit.ArkUI'; - -import { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; -import { MenuNavRouter } from '../components/MenuNavRouter'; +import { getStringArray } from 'common'; +import { MainItem } from '../components/MainItem'; +import { ItemGroup } from '../components/ItemGroup'; +// import { MenuNavRouter } from '../components/MenuNavRouter'; @Component export struct MenuList { - @State menuListData: Array = []; - @BuilderParam childNavDestination: () => void; + // @BuilderParam childNavDestination: () => void = ()=>{}; + private menuListData: Array = ['']; private menuList: Resource | undefined = undefined; - private addAction?: (title: string) => void; + // private addAction?: (title: string) => void; + private isSecond: boolean = false; + + aboutToAppear() { + if (this.menuList) { + this.menuListData = getStringArray(this.menuList as Resource, this.getUIContext()); + } + } build() { - List({ space: 12 }) { + List({ space: 12.0 }) { ListItem() { if (this.menuListData.length > 0) { - MenuNavRouter({ childList: this.menuListData, addAction: this.addAction }) { - this.childNavDestination() + // MenuNavRouter({ + // childList: this.menuListData, + // addAction: this.addAction, + // navDestination: this.childNavDestination + // }) + ItemGroup() { + Column() { + ForEach(this.menuListData, (item: string, index: number) => { + if (index > 0.0) { + this.CustomDivider() + } + MainItem({ title: item, isSecond: this.isSecond }) + }, (item: string) => JSON.stringify(item)) + } } } } } .id('menu_list') .width('100%') - .padding({ left: 12, right: 12 }) - .margin({ top: 12 }) + .height('100%') + .padding({ left: 12.0, right: 12.0, top: 12.0, bottom: 12.0 } as Padding) .backgroundColor($r('sys.color.ohos_id_color_sub_background')) .scrollBar(BarState.Off) } - aboutToAppear() { - this.getData(); - } - - getData = async () => { - if (this.menuList) { - this.menuListData = await getStringArray(this.menuList); - } + @Builder CustomDivider() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + .margin({ left: 8.0, right: 8.0 }as Margin) } } \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 index d5bce3912c27bc0bb32977eb83fc2493c46e5af3..8d7eab58cbd83306ef774b9a6b0ca3c37a13ce1d 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,7 @@ "name": "menuitems", "type": "har", "deviceTypes": [ - "default", - "tablet" + "default" ] } -} \ No newline at end of file +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/float.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json index 1e76de0c66777cfe83568615c5c2e68c61d23fed..f51a9c8461a55f6312ef950344e3145b7f82d607 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "page_show", - "value": "page from npm package" + "value": "page from package" } ] } diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..86effc91891b1b40563249bedcdbe2b3b2bead72 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "menuitems_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/LocalUnit.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 index 60aee16f9b75d1139368466750297c635597eab4..b8fea3f097bd68b0bc4d87de986d2cb7732c1d9b 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 @@ -14,8 +14,25 @@ */ { - "hvigorVersion": "3.0.2", + "modelVersion": "6.0.0", "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ } -} \ No newline at end of file +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts index 988feb9d12f64df2ee8460ffcaee81e8c2a010c7..e3340f07e45ddc5dcadbb87012668555def2e6e0 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,5 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 index 20e090ffed4f154a8aa9f2787b33ad18019e7735..2c9f72aa328383f74c4a5987b21e4f70998c2c5f 100644 --- a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,13 +14,10 @@ */ { - "license": "ISC", - "devDependencies": { - "@ohos/hypium": "1.0.6" + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { }, - "name": "devicemanagementcollection", - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} + "devDependencies": { + } }