diff --git a/ArkUIKit/ArktsNewOnce/AppScope/app.json5 b/ArkUIKit/ArktsNewOnce/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..063bc3861fecfdbc2411edb0f264c044c2c5abe3 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * 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. + */ + +{ + "app": { + "bundleName": "com.sample.arktsnewonce", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/ArktsNewOnce/AppScope/resources/base/element/string.json b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b21daab8c4bb8e3374c0a36d1ca6289378c62984 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ArktsNevOnce" + } + ] +} diff --git a/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/background.png b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/foreground.png b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/layered_image.json b/ArkUIKit/ArktsNewOnce/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/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/ArkUIKit/ArktsNewOnce/README_zh.md b/ArkUIKit/ArktsNewOnce/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..9998b8b0cffa02837a913355bc25a8bc4e5b4847 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/README_zh.md @@ -0,0 +1,70 @@ +# @Once:初始化同步一次 + +### 介绍 + +本示例展示了[@Once:初始化同步一次](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/state-management/arkts-new-once.md)装饰器的使用方法: + +1. @Once用于期望变量仅初始化同步数据源一次,之后不再继续同步变化的场景; +2. 当@Once与@Param结合使用时,可以解除@Param无法在本地修改的限制,并能够触发UI刷新。此时,使用@Param和@Once的效果类似于@Local,但@Param和@Once还能接收外部传入的初始值; + +### 效果预览 + +1.变量仅初始化同步一次 + +| 应用初始页面 | 任务完成界面 | +|------------------------------------------|--------------------------------------| +| ![](screenshots/PreviousMyComponent.png) | ![](screenshots/NextMyComponent.png) | + +2.本地修改@Param变量 + +| 应用初始页面 | 任务完成界面 | +|------------------------------------|--------------------------------| +| ![](screenshots/PreviousIndex.png) | ![](screenshots/NextIndex.png) | + +### 测试代码说明 + +执行测试用例会先打开相应界面,然后会将界面上的按钮点击一遍,演示初始化同步数据源。 + +### 工程目录 +``` +entry/src/ +├── main +│ ├── ets +│ │ ├── entryability +│ │ ├── entrybackupability +│ │ └── pages +│ │ ├── Index.ets //变量仅初始化同步一次界面 +│ │ └── MyComponent.ets //本地修改@Param变量界面 +│ ├── module.json5 +│ └── resources +└── ohosTest + └── ets + └── test + ├── Ability.test.ets // 自动化测试代码 + └── List.test.ets // 测试套执行列表 + +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例已适配API version 20及以上版本SDK。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUISample/ArktsNewOnce/ > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/build-profile.json5 b/ArkUIKit/ArktsNewOnce/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..724b825f1ee429691a14b6b6d138c70fd7c56db9 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "targetSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/code-linter.json5 b/ArkUIKit/ArktsNewOnce/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed05653cca31b61d64cf6471529eaf50d4f70709 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/code-linter.json5 @@ -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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/build-profile.json5 b/ArkUIKit/ArktsNewOnce/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6bf0d132e6f78049e712446c63f2633b2d1613d3 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/build-profile.json5 @@ -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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/hvigorfile.ts b/ArkUIKit/ArktsNewOnce/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * 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 { 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/ArkUIKit/ArktsNewOnce/entry/obfuscation-rules.txt b/ArkUIKit/ArktsNewOnce/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/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/ArkUIKit/ArktsNewOnce/entry/oh-package.json5 b/ArkUIKit/ArktsNewOnce/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * 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. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..62f53acbc95e5be7985f8fb1fe2db591cea260bd --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/Index.ets b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..54b2cfbd09a9d5b4a2662cc173006886c130e5bf --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start once_param_modify_init] +@ObservedV2 +class Info { + @Trace name: string; + constructor(name: string) { + this.name = name; + } +} +@ComponentV2 +struct Child { + @Param @Once onceParamNum: number = 0; + @Param @Once @Require onceParamInfo: Info; + + build() { + Column() { + Text(`Child onceParamNum: ${this.onceParamNum}`) + Text(`Child onceParamInfo: ${this.onceParamInfo.name}`) + Button('changeOnceParamNum') + .onClick(() => { + this.onceParamNum++; + }) + Button('changeParamInfo') + .onClick(() => { + this.onceParamInfo = new Info('Cindy'); + }) + } + } +} +@Entry +@ComponentV2 +struct Index { + @Local localNum: number = 10; + @Local localInfo: Info = new Info('Tom'); + + build() { + Column() { + Text(`Parent localNum: ${this.localNum}`); + Text(`Parent localInfo: ${this.localInfo.name}`); + Button('changeLocalNum') + .onClick(() => { + this.localNum++; + }); + Button('changeLocalInfo') + .onClick(() => { + this.localInfo = new Info('Cindy'); + }); + Child({ + onceParamNum: this.localNum, + onceParamInfo: this.localInfo + }); + } + } +} +// [End once_param_modify_init] \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/MyComponent.ets b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/MyComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bbfb68cc8b198476923af716581e344f8e31fe8 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/ets/pages/MyComponent.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start once_init_sync_noMore] +@ComponentV2 +struct ChildComponent { + @Param @Once onceParam: string = ''; + + build() { + Column() { + Text(`onceParam: ${this.onceParam}`); + } + } +} + +@Entry +// [Start once_param_componentV2_pair] +// [Start once_param_order_irrelevant] +@ComponentV2 +struct MyComponent { + // [StartExclude once_init_sync_noMore] + // [StartExclude once_param_order_irrelevant] + @Param @Once onceParam: string = 'onceParam'; // 正确用法 + // [EndExclide once_param_order_irrelevant] + // [StartExclude once_param_componentV2_pair] + @Param @Once param1: number = 0; + @Once @Param param2: number = 0; + // [StartExclude once_param_order_irrelevant] + // [EndExclide once_init_sync_noMore] + @Local message: string = 'Hello World'; + + build() { + Column() { + Text(`Parent message: ${this.message}`); + Button('change message') + .onClick(() => { + this.message = 'Hello Tomorrow'; + }); + ChildComponent({ onceParam: this.message }); + } + } + // [EndExclide once_param_componentV2_pair] + // [EndExclide once_param_order_irrelevant] +} +//[End once_param_componentV2_pair] +// [End once_param_order_irrelevant] +// [End once_init_sync_noMore] \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/module.json5 b/ArkUIKit/ArktsNewOnce/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e4226557b12a7322c888516a211fcf6c981c7122 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * 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": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/color.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/float.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/string.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/background.png b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/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/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..27c3804184d4736fff712056979fc433a5c9560f --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/Index", + "pages/MyComponent" + ] +} diff --git a/ArkUIKit/ArktsNewOnce/entry/src/main/resources/dark/element/color.json b/ArkUIKit/ArktsNewOnce/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/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/ArkUIKit/ArktsNewOnce/entry/src/mock/mock-config.json5 b/ArkUIKit/ArktsNewOnce/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * 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. + */ + +{ +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7438264f9dc6281a8427e4be49bffd783060ada2 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,122 @@ +/* + * 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, TestType, Level, Size } from '@ohos/hypium'; +import Want from '@ohos.app.ability.Want'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { router } from '@kit.ArkUI'; +import { Driver, ON, Component, Point, On } from '@ohos.UiTest'; + +let driver = Driver.create(); + +const DELAY_TIME01 = 1000; //异步等待1秒 + +async function sleep(time: number): Promise { + return new Promise((re, je) => { + setTimeout(() => { + re() + }, time) + }) +} + +async function getCenterPoint(comp: Component, offset: number): Promise { + // 获取文件控件边框 + let rect = await comp.getBounds(); + // 计算文字控件高度 + let height = rect.bottom - rect.top; + // 获取文字控件中心点 + let point: Point = await comp.getBoundsCenter(); + point = {x: point.x, y:point.y - height*offset}; + return point; +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + const delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let want:Want = { + bundleName:"com.sample.arktsnewonce", + abilityName:"EntryAbility", + moduleName:"entry" + } + delegator.startAbility(want) + // 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. + }) + + /** + * @tc.number : SUB_ARKUI_DECORATOR_ONCE_0100 + * @tc.name : SUB_ARKUI_DECORATOR_ONCE_0100 + * @tc.desc : Testing DestroyChildProcessConfigs returns an invalid parameter error code. + * @tc.level : Level1 + * @tc.size : MediumTest + * @tc.type : Function + */ + it('SUB_ARKUI_DECORATOR_ONCE_0100', + TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, async (done: Function) => { + let changeLocalNumCom :Component = await driver.findComponent(ON.text("changeLocalNum")); + let coordinate1 = await getCenterPoint(changeLocalNumCom,0); + await driver.click(coordinate1.x,coordinate1.y); + await sleep(DELAY_TIME01); + let changeLocalInfoCom :Component = await driver.findComponent(ON.text("changeLocalInfo")); + let coordinate2 = await getCenterPoint(changeLocalInfoCom,0); + await driver.click(coordinate2.x,coordinate2.y); + await sleep(DELAY_TIME01); + let changeOnceParamNumCom :Component = await driver.findComponent(ON.text("changeOnceParamNum")); + let coordinate3 = await getCenterPoint(changeOnceParamNumCom,0); + await driver.click(coordinate3.x,coordinate3.y); + await sleep(DELAY_TIME01); + let changeParamInfoCom :Component = await driver.findComponent(ON.text("changeParamInfo")); + let coordinate4 = await getCenterPoint(changeParamInfoCom,0); + await driver.click(coordinate4.x,coordinate4.y); + await sleep(DELAY_TIME01); + done(); + }) + + /** + * @tc.number : SUB_ARKUI_DECORATOR_ONCE_0200 + * @tc.name : SUB_ARKUI_DECORATOR_ONCE_0200 + * @tc.desc : Testing DestroyChildProcessConfigs returns an invalid parameter error code. + * @tc.level : Level1 + * @tc.size : MediumTest + * @tc.type : Function + */ + it('SUB_ARKUI_DECORATOR_ONCE_0200', + TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, async (done: Function) => { + router.push({url:"pages/MyComponent"}); + await sleep(DELAY_TIME01); + let changeMessageCom :Component = await driver.findComponent(ON.text("change message")); + let coordinate1 = await getCenterPoint(changeMessageCom,0); + await driver.click(coordinate1.x,coordinate1.y); + await sleep(DELAY_TIME01); + done(); + }) + }) +} \ No newline at end of file diff --git a/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/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/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/module.json5 b/ArkUIKit/ArktsNewOnce/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..84d30586d591412f4252801cc483bbc6d8554104 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/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": "entry_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkUIKit/ArktsNewOnce/entry/src/test/List.test.ets b/ArkUIKit/ArktsNewOnce/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/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/ArkUIKit/ArktsNewOnce/entry/src/test/LocalUnit.test.ets b/ArkUIKit/ArktsNewOnce/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/entry/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/ArkUIKit/ArktsNewOnce/hvigor/hvigor-config.json5 b/ArkUIKit/ArktsNewOnce/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b8fea3f097bd68b0bc4d87de986d2cb7732c1d9b --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/hvigor/hvigor-config.json5 @@ -0,0 +1,38 @@ +/* + * 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. + */ + +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "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*/ + } +} diff --git a/ArkUIKit/ArktsNewOnce/hvigorfile.ts b/ArkUIKit/ArktsNewOnce/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3340f07e45ddc5dcadbb87012668555def2e6e0 --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * 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 { 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/ArkUIKit/ArktsNewOnce/oh-package.json5 b/ArkUIKit/ArktsNewOnce/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..69cb43cba3addcee1840403c67405134a2a9102c --- /dev/null +++ b/ArkUIKit/ArktsNewOnce/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * 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. + */ + +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.24", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkUIKit/ArktsNewOnce/screenshots/NextIndex.png b/ArkUIKit/ArktsNewOnce/screenshots/NextIndex.png new file mode 100644 index 0000000000000000000000000000000000000000..4b87a2715cbb31085a6f70734a012975373ff89b Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/screenshots/NextIndex.png differ diff --git a/ArkUIKit/ArktsNewOnce/screenshots/NextMyComponent.png b/ArkUIKit/ArktsNewOnce/screenshots/NextMyComponent.png new file mode 100644 index 0000000000000000000000000000000000000000..14ff31041ff3d7761933e9a2cb41a58a2edd466a Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/screenshots/NextMyComponent.png differ diff --git a/ArkUIKit/ArktsNewOnce/screenshots/PreviousIndex.png b/ArkUIKit/ArktsNewOnce/screenshots/PreviousIndex.png new file mode 100644 index 0000000000000000000000000000000000000000..53a40a346944857e159c03aa6570b8d34b2fa2ef Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/screenshots/PreviousIndex.png differ diff --git a/ArkUIKit/ArktsNewOnce/screenshots/PreviousMyComponent.png b/ArkUIKit/ArktsNewOnce/screenshots/PreviousMyComponent.png new file mode 100644 index 0000000000000000000000000000000000000000..8130500f9fdd87dd99dd09b84a2de7d71b74c351 Binary files /dev/null and b/ArkUIKit/ArktsNewOnce/screenshots/PreviousMyComponent.png differ diff --git a/ArkUIKit/BindSheet/AppScope/app.json5 b/ArkUIKit/BindSheet/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..867532eb9a552b283ee74bd5fc009dec4733a4fa --- /dev/null +++ b/ArkUIKit/BindSheet/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "app": { + "bundleName": "com.samples.bindsheet", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/BindSheet/AppScope/resources/base/element/string.json b/ArkUIKit/BindSheet/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..53a288c841496a30f98c0bf0d583722c7d91fa09 --- /dev/null +++ b/ArkUIKit/BindSheet/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "BindSheet" + } + ] +} diff --git a/ArkUIKit/BindSheet/AppScope/resources/base/media/background.png b/ArkUIKit/BindSheet/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/BindSheet/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/BindSheet/AppScope/resources/base/media/foreground.png b/ArkUIKit/BindSheet/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/BindSheet/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/BindSheet/AppScope/resources/base/media/layered_image.json b/ArkUIKit/BindSheet/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/BindSheet/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/ArkUIKit/BindSheet/README_zh.md b/ArkUIKit/BindSheet/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6915cb2af7eb5a335e4fb8e530606810b60b03bf --- /dev/null +++ b/ArkUIKit/BindSheet/README_zh.md @@ -0,0 +1,114 @@ +# ArkUI使用模态组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [全模态转场](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-modal-transition.md)。 +2. [半模态转场](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-sheet-transition.md)。 +3. [命令式打开半模态](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-arkui-UIContext.md#openbindsheet12)。 +4. [模态转场](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-modal-transition.md)。 +5. [绑定全模态页面](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-contentcover-page.md)。 + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---bindContentCover // 全模态转场 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| |---bindSheet // 半模态转场 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| | |---template8 +| | | |---Index.ets +| | |---template9 +| | | |---Index.ets +| | |---template10 +| | | |---Index.ets +| |---bindSheetCmd // 命令式打开半模态 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---BindContentCover.test.ets // 全模态转场示例代码测试代码 +| | |---BindSheet.test.ets // 半模态转场示例代码测试代码 +| | |---OpenSheet.test.ets // 命令式打开半模态示例代码测试代码 + +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.33,镜像版本号:OpenHarmony_6.0.0.33。 + +3.本示例需要使用DevEco Studio 6.0.0 Canary1 (Build Version: 6.0.0.270, built on May 9, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/BindSheet > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/ArkUIKit/BindSheet/build-profile.json5 b/ArkUIKit/BindSheet/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3ca5a93fb814017ac4c398aacbdf17b1d8b0a237 --- /dev/null +++ b/ArkUIKit/BindSheet/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * 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. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "targetSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/code-linter.json5 b/ArkUIKit/BindSheet/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/ArkUIKit/BindSheet/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * 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. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/build-profile.json5 b/ArkUIKit/BindSheet/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/hvigorfile.ts b/ArkUIKit/BindSheet/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/ArkUIKit/BindSheet/entry/hvigorfile.ts @@ -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 { 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. */ +} diff --git a/ArkUIKit/BindSheet/entry/obfuscation-rules.txt b/ArkUIKit/BindSheet/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/BindSheet/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/ArkUIKit/BindSheet/entry/oh-package.json5 b/ArkUIKit/BindSheet/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/ArkUIKit/BindSheet/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/common/resource.ets b/ArkUIKit/BindSheet/entry/src/main/ets/common/resource.ets new file mode 100644 index 0000000000000000000000000000000000000000..723a394265ee2e6bf6d895e9503c4b2d8e49207a --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/common/resource.ets @@ -0,0 +1,25 @@ +/* + * 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. + */ + +export class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { display, uiObserver, window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +function callBackFunc2(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag2 navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + uiObserver.on('navDestinationSwitch', this.context, callBackFunc); + uiObserver.on('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc2); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + uiObserver.off('navDestinationSwitch', this.context, callBackFunc); + uiObserver.off('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let mainWindow: window.Window; + try { + mainWindow = windowStage.getMainWindowSync(); + let displayClass: display.Display = display.getDefaultDisplaySync(); + AppStorage.setOrCreate('orientation', displayClass.orientation); + // 监听窗口的windowsSizeChange事件,旋转屏时会触发该事件 + mainWindow.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let displayClass: display.Display | null = null; + try { + displayClass = display.getDefaultDisplaySync(); + console.info('display orientation is ' + JSON.stringify(displayClass.orientation)); + // 获取屏幕的显示方向 + AppStorage.set('orientation', displayClass.orientation); + } catch { + return; + } + }) + } catch { + hilog.info(0x0000, 'testTag', '%{public}s', 'error'); + return; + } + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/Index.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f66347f114c366fe07800c07dfcaee6694ce1482 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,181 @@ +/* + * 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 curves from '@ohos.curves'; +import { Route, RouteGroup } from './common/Index'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; +import router from '@ohos.router'; + +@Styles +function cardPressedStyle() { + .backgroundColor('rgba(0,0,0,0.1)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardNormalStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardDisabledStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(0.5) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + + +@Entry +@Component +struct Index { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: "bindContentCover", + label: $r('app.string.bindContentCover_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindContentCover_label1') }, + { name:"template2/Index", label: $r('app.string.bindContentCover_label2') }, + { name:"template3/Index", label: $r('app.string.bindContentCover_label3') }, + { name:"template4/Index", label: $r('app.string.bindContentCover_label4') }, + { name:"template5/Index", label: $r('app.string.bindContentCover_label5') }, + { name:"template6/Index", label: $r('app.string.bindContentCover_label6') }, + { name:"template7/Index", label: $r('app.string.bindContentCover_label7') }, + + ] + }, { + name: "bindSheet", + label: $r('app.string.bindSheet_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindSheet_label1') }, + { name:"template2/Index", label: $r('app.string.bindSheet_label2') }, + { name:"template3/Index", label: $r('app.string.bindSheet_label3') }, + { name:"template4/Index", label: $r('app.string.bindSheet_label4') }, + { name:"template5/Index", label: $r('app.string.bindSheet_label5') }, + { name:"template6/Index", label: $r('app.string.bindSheet_label6') }, + { name:"template7/Index", label: $r('app.string.bindSheet_label7') }, + { name:"template8/Index", label: $r('app.string.bindSheet_label8') }, + { name:"template9/Index", label: $r('app.string.bindSheet_label9') }, + { name:"template10/Index", label: $r('app.string.bindSheet_label10') }, + ] + }, { + name: "bindSheetCmd", + label: $r('app.string.bindSheetCmd_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindSheetCmd_label1') }, + { name:"template2/Index", label: $r('app.string.bindSheetCmd_label2') }, + { name:"template3/Index", label: $r('app.string.bindSheetCmd_label3') }, + ] + } + ]; + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(route: RouteGroup) { + Row() { + Text(route.label) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Medium) + + Blank() + + Text(`${route.children.length}`) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .opacity(this.selection === route.name ? 0 : 1) + + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + .rotate({ angle: this.selection === route.name ? 90 : 0 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 30) }) + } + .borderRadius(20) + .width('100%') + .padding(8) + .enabled(!!route.children.length) + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .onClick(() => { + animateTo( + { curve: curves.interpolatingSpring(0, 1, 228, 25) }, + () => { + if (this.selection === route.name) { + this.selection = null; + } else { + this.selection = route.name; + } + }); + }) + } + + aboutToAppear(): void{ + this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + } + build() { + Column() { + Text('Index') + List() { + ForEach(this.routes, (routeGroup: RouteGroup) => { + ListItemGroup({ + header: this.ListItemGroupHeader(routeGroup), + style: ListItemGroupStyle.CARD, + }) { + if (routeGroup.name === this.selection) { + ForEach(routeGroup.children, (route: Route) => { + ListItem() { + Row() { + Text(route.label).fontSize(16) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + } + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .borderRadius(20) + .padding(8) + .transition( + TransitionEffect.OPACITY.animation({ + curve: curves.interpolatingSpring(0, 1, 228, 30) + }) + ) + .width('100%') + .onClick(() => { + const name = `pages/${routeGroup.name}/${route.name}`; + router.pushUrl({url: name}) + }) + } + .width('100%') + }) + } + } + .padding(2) + .divider({ strokeWidth: 0.5 }) + }) + }.padding({bottom: 10}) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/ModalTransitionExample.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/ModalTransitionExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..331dc29efbb7441ae200e27d97179c91872caebb --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/ModalTransitionExample.ets @@ -0,0 +1,102 @@ +/* + * 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. + */ +@Entry +@Component +struct ModalTransitionExample { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button('close modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button('transition modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Orange, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button('close modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#ff49c8ab') + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/ModalTransitionExample2.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/ModalTransitionExample2.ets new file mode 100644 index 0000000000000000000000000000000000000000..5dfb976666d5ec43af66f6da78461a9a3fa27e5f --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/ModalTransitionExample2.ets @@ -0,0 +1,118 @@ +/* + * 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 { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct ModalTransitionExample2 { + @State @Watch('isShow1Change') isShow: boolean = false; + @State @Watch('isShow2Change') isShow2: boolean = false; + @State isScale1: number = 1; + @State isScale2: number = 1; + + isShow1Change() { + this.isShow ? this.isScale1 = 0.95 : this.isScale1 = 1; + } + + isShow2Change() { + this.isShow2 ? this.isScale2 = 0.95 : this.isScale2 = 1; + } + + @Builder + myBuilder2() { + Column() { + Button('close modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button('transition modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Orange, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button('close modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + .scale({ x: this.isScale2, y: this.isScale2 }) + .animation({ curve: curves.springMotion() }) + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#ff49c8ab') + .width('100%') + .height('100%') + .scale({ x: this.isScale1, y: this.isScale1 }) + .animation({ curve: curves.springMotion() }) + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/ModalTransitionExample3.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/ModalTransitionExample3.ets new file mode 100644 index 0000000000000000000000000000000000000000..2453756262f1aeaebb6a2a832b4d406b7ae81713 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/ModalTransitionExample3.ets @@ -0,0 +1,102 @@ +/* + * 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. + */ +@Entry +@Component +struct ModalTransitionExample3 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button('close modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button('transition modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Gray, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button('close modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/ModalTransitionExample4.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/ModalTransitionExample4.ets new file mode 100644 index 0000000000000000000000000000000000000000..bdf0db41142a12dac07ba65c8f2dc6738fcaf34d --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/ModalTransitionExample4.ets @@ -0,0 +1,103 @@ +/* + * 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. + */ +@Entry +@Component +struct ModalTransitionExample4 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button('close modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + @Builder + myBuilder() { + Column() { + Button('transition modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.ALPHA, + backgroundColor: Color.Gray, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button('close modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.ALPHA, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/ModalTransitionExample5.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/ModalTransitionExample5.ets new file mode 100644 index 0000000000000000000000000000000000000000..42a56bf0b6c18408405bb121c7e18e7dd83d4e88 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/ModalTransitionExample5.ets @@ -0,0 +1,120 @@ +/* + * 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. + */ +@Entry +@Component +struct ModalTransitionExample5 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button('Close Modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + @Builder + myBuilder() { + Column() { + Button('Transition Modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }) + .bindContentCover( + this.isShow2, + this.myBuilder2(), + { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Gray, + transition: TransitionEffect.SLIDE.animation({ duration: 5000, curve: Curve.LinearOutSlowIn }), + onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => { + if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) { + console.log('BindContentCover dismiss reason is back pressed'); + } + dismissContentCoverAction.dismiss(); + }), + onAppear: () => { + console.info('BindContentCover onAppear.'); + }, + onDisappear: () => { + this.isShow2 = false; + console.info('BindContentCover onDisappear.'); + } + }) + + Button('Close Modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button('Transition Modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover( + this.isShow, + this.myBuilder(), + { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Pink, + transition: TransitionEffect.asymmetric( + TransitionEffect.OPACITY.animation({ duration: 1100 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ delay: 1000, duration: 1000 })) + , + TransitionEffect.OPACITY.animation({ duration: 1200 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ duration: 1300 })) + ), + onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => { + if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) { + console.log('back pressed'); + } + dismissContentCoverAction.dismiss(); + }), + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onDisappear: () => { + this.isShow = false; + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/BindContentCoverDemo.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/BindContentCoverDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..f382c95854c674f2d0d2d207e0b7ee5723d27ea5 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/BindContentCoverDemo.ets @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start bindContentCover_demo] +import { curves } from '@kit.ArkUI'; +import resource from '../../../common/resource'; + +interface PersonList { + name: string, + cardnum: string +} + +@Entry +@Component +struct BindContentCoverDemo { + private personList: Array = [ + // $r('app.string.xxxx')需要替换为开发者所需的资源文件 + { name: resource.resourceToString($r('app.string.Person_example1')), cardnum: '1234***********789' }, + { name: resource.resourceToString($r('app.string.Person_example2')), cardnum: '2345***********789' }, + { name: resource.resourceToString($r('app.string.Person_example3')), cardnum: '3456***********789' }, + { name: resource.resourceToString($r('app.string.Person_example4')), cardnum: '4567***********789' } + ]; + // 半模态转场控制变量 + @State isSheetShow: boolean = false; + // 全模态转场控制变量 + @State isPresent: boolean = false; + + @Builder + MyContentCoverBuilder() { + Column() { + // $r('app.string.MyContentCoverBuilder_text1')需要替换为开发者所需的资源文件 + Row() { + Text($r('app.string.MyContentCoverBuilder_text1')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 15 }) + } + .backgroundColor(0x007dfe) + + Row() { + // $r('app.string.MyContentCoverBuilder_text2')需要替换为开发者所需的资源文件 + Text($r('app.string.MyContentCoverBuilder_text2')) + .fontSize(16) + .fontColor(0x333333) + .margin({ top: 10 }) + .padding({ top: 20, bottom: 20 }) + .width('92%') + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + } + + Column() { + ForEach(this.personList, (item: PersonList, index: number) => { + Row() { + Column() { + if (index % 2 == 0) { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + .backgroundColor(0x007dfe) + } else { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + } + } + .width('20%') + + Column() { + Text(item.name) + .fontColor(0x333333) + .fontSize(18) + Text(item.cardnum) + .fontColor(0x666666) + .fontSize(14) + } + .width('60%') + .alignItems(HorizontalAlign.Start) + + Column() { + // $r('app.string.MyContentCoverBuilder_text3')需要替换为开发者所需的资源文件 + Text($r('app.string.MyContentCoverBuilder_text3')) + .fontColor(0x007dfe) + .fontSize(16) + } + .width('20%') + } + .padding({ top: 10, bottom: 10 }) + .border({ width: { bottom: 1 }, color: 0xf1f1f1 }) + .width('92%') + .backgroundColor(Color.White) + }) + } + .padding({ top: 20, bottom: 20 }) + // $r('app.string.bindSheetCmd_label4')需要替换为开发者所需的资源文件 + Text($r('app.string.bindSheetCmd_label4')) + .width('90%') + .height(40) + .textAlign(TextAlign.Center) + .borderRadius(10) + .fontColor(Color.White) + .backgroundColor(0x007dfe) + .onClick(() => { + this.isPresent = !this.isPresent; + }) + } + .size({ width: '100%', height: '100%' }) + .backgroundColor(0xf5f5f5) + } + + @Builder + TripInfo() { + Row() { + // $r('app.string.xxxx')需要替换为开发者所需的资源文件 + Column() { + Text('00:25') + Text($r('app.string.bindSheetCmd_label5')) + } + .width('25%') + + Column() { + Text('G1234') + Text($r('app.string.bindSheetCmd_label6')) + } + .width('25%') + + Column() { + Text('08:26') + Text($r('app.string.bindSheetCmd_label7')) + } + .width('25%') + } + } + + // 第二步:定义半模态展示界面 + // 通过@Builder构建模态展示界面 + @Builder + MySheetBuilder() { + Column() { + Column() { + this.TripInfo() + } + .width('92%') + .margin(15) + .backgroundColor(Color.White) + .shadow({ radius: 30, color: '#aaaaaa' }) + .borderRadius(10) + + Column() { + // $r('app.string.MySheetBuilder_text1')需要替换为开发者所需的资源文件 + Text($r('app.string.MySheetBuilder_text1')) + .fontSize(18) + .fontColor(Color.Orange) + .fontWeight(FontWeight.Bold) + .padding({ top: 10, bottom: 10 }) + .width('60%') + .textAlign(TextAlign.Center) + .borderRadius(15) + .onClick(() => { + // 第三步:通过全模态接口调起全模态展示界面,新拉起的模态面板默认显示在最上层 + this.isPresent = !this.isPresent; + }) + // 通过全模态接口,绑定模态展示界面MyContentCoverBuilder。transition属性支持自定义转场效果,此处定义了x轴横向入场 + .bindContentCover($$this.isPresent, this.MyContentCoverBuilder(), { + transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) }) + }) + } + .padding({ top: 60 }) + } + } + + build() { + Column() { + Row() { + this.TripInfo() + // $r('app.string.xxxx')需要替换为开发者所需的资源文件 + Text($r('app.string.MySheetBuilder_text2')) + .fontColor(Color.Blue) + .width('25%') + } + .width('100%') + .margin({top: 200, bottom: 30}) + .borderRadius(10) + .backgroundColor(Color.White) + .onClick(()=>{ + this.isSheetShow = !this.isSheetShow; + }) + // 第一步:定义半模态转场效果 + .bindSheet($$this.isSheetShow, this.MySheetBuilder(), { + height: SheetSize.MEDIUM, + title: {title: $r('app.string.MySheetBuilder_text3')}, + }) + } + .width('100%') + .height('100%') + .backgroundColor('#30aaaaaa') + } +} +// [End bindContentCover_demo] \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/BindContentCoverDemo.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/BindContentCoverDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..487b87b042a4fd6e49975459ac1e59f537eaaaea --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/BindContentCoverDemo.ets @@ -0,0 +1,190 @@ +/* + * 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 { curves } from '@kit.ArkUI'; + +interface PersonList { + name: string, + cardnum: string +} + +@Entry +@Component +struct BindContentCoverDemo { + private personList: Array = [ + { name: 'wang**', cardnum: '1234***********789' }, + { name: 'song*', cardnum: '2345***********789' }, + { name: 'xu**', cardnum: '3456***********789' }, + { name: 'tang*', cardnum: '4567***********789' } + ]; + // 第一步:定义全屏模态转场效果bindContentCover + // 模态转场控制变量 + @State isPresent: boolean = false; + + // 第二步:定义模态展示界面 + // 通过@Builder构建模态展示界面 + @Builder + MyBuilder() { + Column() { + Row() { + Text($r('app.string.MyContentCoverBuilder_text1')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 15 }) + } + .backgroundColor(0x007dfe) + + Row() { + Text($r('app.string.MyContentCoverBuilder_text2')) + .fontSize(16) + .fontColor(0x333333) + .margin({ top: 10 }) + .padding({ top: 20, bottom: 20 }) + .width('92%') + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + } + + Column() { + ForEach(this.personList, (item: PersonList, index: number) => { + Row() { + Column() { + if (index % 2 == 0) { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + .backgroundColor(0x007dfe) + } else { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + } + } + .width('20%') + + Column() { + Text(item.name) + .fontColor(0x333333) + .fontSize(18) + Text(item.cardnum) + .fontColor(0x666666) + .fontSize(14) + } + .width('60%') + .alignItems(HorizontalAlign.Start) + + Column() { + Text($r('app.string.MyContentCoverBuilder_text3')) + .fontColor(0x007dfe) + .fontSize(16) + } + .width('20%') + } + .padding({ top: 10, bottom: 10 }) + .border({ width: { bottom: 1 }, color: 0xf1f1f1 }) + .width('92%') + .backgroundColor(Color.White) + }) + } + .padding({ top: 20, bottom: 20 }) + + Text($r('app.string.MyContentCoverBuilder_text4')) + .width('90%') + .height(40) + .textAlign(TextAlign.Center) + .borderRadius(10) + .fontColor(Color.White) + .backgroundColor(0x007dfe) + .onClick(() => { + this.isPresent = !this.isPresent; + }) + } + .size({ width: '100%', height: '100%' }) + .backgroundColor(0xf5f5f5) + // 通过转场动画实现出现消失转场动画效果 + .transition(TransitionEffect.translate({ y: 1000 }).animation({ curve: curves.springMotion(0.6, 0.8) })) + } + + build() { + Column() { + Row() { + Text($r('app.string.MySheetBuilder_text')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 60 }) + } + .backgroundColor(0x007dfe) + + Column() { + Row() { + Column() { + Text('00:25') + Text($r('app.string.MyContentCoverBuilder_text5')) + } + .width('30%') + + Column() { + Text('G1234') + Text($r('app.string.MyContentCoverBuilder_text6')) + } + .width('30%') + + Column() { + Text('08:26') + Text($r('app.string.MyContentCoverBuilder_text7')) + } + .width('30%') + } + } + .width('92%') + .padding(15) + .margin({ top: -30 }) + .backgroundColor(Color.White) + .shadow({ radius: 30, color: '#aaaaaa' }) + .borderRadius(10) + + Column() { + Text($r('app.string.MyContentCoverBuilder_text2')) + .fontSize(18) + .fontColor(Color.Orange) + .fontWeight(FontWeight.Bold) + .padding({ top: 10, bottom: 10 }) + .width('60%') + .textAlign(TextAlign.Center) + .borderRadius(15) + .bindContentCover(this.isPresent, this.MyBuilder(), { + modalTransition: ModalTransition.DEFAULT, + onDisappear: () => { + if (this.isPresent) { + this.isPresent = !this.isPresent; + } + } + }) + .onClick(() => { + // 第三步:通过模态接口调起模态展示界面,通过转场动画或者共享元素动画去实现对应的动画效果 + // 改变状态变量,显示模态界面 + this.isPresent = !this.isPresent; + }) + } + .padding({ top: 60 }) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template1/SheetTransitionExample1.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template1/SheetTransitionExample1.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bf136f796d1f0e7310a3645534a6976c827a2d8 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template1/SheetTransitionExample1.ets @@ -0,0 +1,78 @@ +/* + * 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. + */ +@Entry +@Component +struct SheetTransitionExample1 { + @State isShow: boolean = false; + @State sheetHeight: number = 300; + + @Builder + myBuilder() { + Column() { + Button('change height') + .margin(10) + .fontSize(20) + .onClick(() => { + this.sheetHeight = 500; + }) + + Button('Set Illegal height') + .margin(10) + .fontSize(20) + .onClick(() => { + this.sheetHeight = -1; + }) + + Button('close modal 1') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: this.sheetHeight, + backgroundColor: Color.Green, + onWillAppear: () => { + console.log('BindSheet onWillAppear.'); + }, + onAppear: () => { + console.log('BindSheet onAppear.'); + }, + onWillDisappear: () => { + console.log('BindSheet onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindSheet onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template10/SheetDemo.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template10/SheetDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..384a7b9ae19740bb05353429228663e2e814f410 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template10/SheetDemo.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start Nested_scrolling_Sheet] + +@Entry +@Component +struct SheetDemo { + @State isShowSheet: boolean = false; + private items: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + @Builder + SheetBuilder() { + Column() { + // 第一步:自定义滚动容器 + List({ space: '10vp' }) { + ForEach(this.items, (item: number) => { + ListItem() { + Text(String(item)).fontSize(16).fontWeight(FontWeight.Bold) + }.width('90%').height('80vp').backgroundColor('#ff53ecd9').borderRadius(10) + }) + } + .alignListItem(ListItemAlign.Center) + .margin({ top: '10vp' }) + .width('100%') + .height('900px') + // 第二步:设置滚动组件的嵌套滚动属性 + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.SELF_FIRST, + }) + + Text($r('app.string.tSheetBuilder_text1')) + .width('100%') + .backgroundColor(Color.Gray) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .align(Alignment.Top) + }.width('100%').height('100%') + } + + build() { + Column() { + Button('Open Sheet').width('90%').height('80vp') + .onClick(() => { + this.isShowSheet = !this.isShowSheet; + }) + .bindSheet($$this.isShowSheet, this.SheetBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 600], + preferType: SheetType.BOTTOM, + title: { title: $r('app.string.tSheetBuilder_text2') }, + }) + }.width('100%').height('100%') + .justifyContent(FlexAlign.Center) + } +} + +// [End Nested_scrolling_Sheet] \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template11/OnWillDismiss_Dismiss.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template11/OnWillDismiss_Dismiss.ets new file mode 100644 index 0000000000000000000000000000000000000000..853d959af923252f4719e28dfc361dfc76bc94cf --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template11/OnWillDismiss_Dismiss.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start onWillDismiss_Dismiss] + +@Entry +@Component +struct OnWillDismiss_Dismiss { + @State isShow: Boolean = false; + + @Builder + myBuilder() { + Column() { + Button('Button') + } + } + + build() { + Button('OpenBindSheet') + .onClick(() => { + this.isShow = true + }) + .margin(120) + .bindSheet($$this.isShow, this.myBuilder(), { + height: SheetSize.MEDIUM, + blurStyle: BlurStyle.Thick, + dragBar: true, + detents: [SheetSize.MEDIUM, SheetSize.LARGE], + title: { title: 'title', subtitle: 'subtitle' }, + enableOutsideInteractive: false, + onWillDismiss: ((dismissSheetAction: DismissSheetAction) => { + // 第二步:确认二次回调交互能力,此处用AlertDialog提示 "是否需要关闭半模态" + this.getUIContext().showAlertDialog( + { + message: $r('app.string.bindContentCover_label2'), + autoCancel: true, + alignment: DialogAlignment.Bottom, + gridCount: 4, + offset: { dx: 0, dy: -20 }, + primaryButton: { + value: 'cancel', + action: () => { + } + }, + secondaryButton: { + enabled: true, + defaultFocus: true, + style: DialogButtonStyle.HIGHLIGHT, + value: 'ok', + // 第三步:确认关闭半模态逻辑所在,此处为AlertDialog的Button回调 + action: () => { + // 第四步:上述第三步逻辑触发的时候,调用dismiss()关闭半模态 + dismissSheetAction.dismiss(); + } + }, + } + ) + }) + }) + } +} + +// [End onWillDismiss_Dismiss] \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template12/SheetTransitionExample.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template12/SheetTransitionExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..783fa15e917d2e22029f11f538b8ca85949b259b --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template12/SheetTransitionExample.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start SheetTransitionExample] + +@Entry +@Component +struct SheetTransitionExample { + @State isShow: boolean = false; + @State enableHoverMode: boolean = true; + @State hoverModeArea: HoverModeAreaType = HoverModeAreaType.TOP_SCREEN; + + @Builder + myBuilder() { + Column() { + Button('enableHoverMode') + .margin(10) + .fontSize(20) + .onClick(() => { + this.enableHoverMode = !this.enableHoverMode; + }) + + Button('hoverModeArea') + .margin(10) + .fontSize(20) + .onClick(() => { + this.hoverModeArea = this.hoverModeArea === HoverModeAreaType.TOP_SCREEN ? + HoverModeAreaType.BOTTOM_SCREEN : HoverModeAreaType.TOP_SCREEN; + }) + + Button('close modal') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + } + + build() { + Column() { + Button($r('app.string.bindSheetCmd_label9')) + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: 300, + backgroundColor: Color.Green, + preferType: SheetType.CENTER, + enableHoverMode: this.enableHoverMode, + hoverModeArea: this.hoverModeArea + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} + +// [End SheetTransitionExample] \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template2/SheetTransitionExample2.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template2/SheetTransitionExample2.ets new file mode 100644 index 0000000000000000000000000000000000000000..1301297dbbaf839f92ba57290e0ed98f552ca0e5 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template2/SheetTransitionExample2.ets @@ -0,0 +1,53 @@ +/* + * 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. + */ +@Entry +@Component +struct SheetTransitionExample2 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button('content1') + .margin(10) + .fontSize(20) + + Button('content2') + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: 'title', subtitle: 'subtitle' }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template3/SheetTransitionExample3.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template3/SheetTransitionExample3.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0edd1e110335b38f089ca6079b63da9558e7237 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template3/SheetTransitionExample3.ets @@ -0,0 +1,58 @@ +/* + * 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 { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetTransitionExample3 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button('content1') + .margin(10) + .fontSize(20) + + Button('content2') + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + backgroundColor: Color.Gray, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: 'title', subtitle: 'subtitle' }, + borderWidth: { top: LengthMetrics.vp(10), start: LengthMetrics.vp(10), end: LengthMetrics.vp(20) }, + borderColor: { top: Color.Pink, start: Color.Blue, end: Color.Yellow }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template4/bindSheetExample4.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template4/bindSheetExample4.ets new file mode 100644 index 0000000000000000000000000000000000000000..29912093d30ab82081583abc96b89ad311501707 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template4/bindSheetExample4.ets @@ -0,0 +1,55 @@ +/* + * 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. + */ +@Entry +@Component +struct bindSheetExample4 { + @State isShow: Boolean = false; + + @Builder + myBuilder() { + Column() { + Button('CONTEXT') + .margin(10) + .fontSize(20) + } + } + + build() { + Column() { + Button('NoRegisterSpringback') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: SheetSize.MEDIUM, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: 'title', subtitle: 'subtitle' }, + preferType: SheetType.CENTER, + + onWillDismiss: ((dismissSheetAction: DismissSheetAction) => { + if (dismissSheetAction.reason == DismissReason.SLIDE_DOWN) { + dismissSheetAction.dismiss(); //注册dismiss行为 + } + }), + + onWillSpringBackWhenDismiss: ((springBackAction: SpringBackAction) => { + }), + }) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template5/bindSheetExample5.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template5/bindSheetExample5.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf546bd157c670c231c56b922d5a7a4bf6ae1886 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template5/bindSheetExample5.ets @@ -0,0 +1,53 @@ +/* + * 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. + */ +@Entry +@Component +struct bindSheetExample5 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Column() + .backgroundColor(Color.Blue) + .height(200) + .width('100%') + Column() + .backgroundColor(Color.Green) + .height(200) + .width('100%') + } + } + + build() { + Column() { + Button('BindSheet') + .onClick(() => { + this.isShow = true; + }) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [300, 600, 900], + uiContext: this.getUIContext(), + mode: SheetMode.OVERLAY, + scrollSizeMode: ScrollSizeMode.CONTINUOUS, + backgroundColor: Color.Orange, + title: { title: 'Title', subtitle: 'Subtitle' } + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template6/ListenKeyboardHeightChange.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template6/ListenKeyboardHeightChange.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3ee2dab9daffcf1bbdedb71e95e17c2af1e7d02 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template6/ListenKeyboardHeightChange.ets @@ -0,0 +1,121 @@ +/* + * 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 window from '@ohos.window'; +import { BusinessError } from '@ohos.base'; + +@Entry +@Component +struct ListenKeyboardHeightChange { + @State isShow: boolean = false; + @State avoidMode: SheetKeyboardAvoidMode = SheetKeyboardAvoidMode.RESIZE_ONLY; + scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6]; + windowClass: window.Window | undefined = undefined; + + aboutToAppear(): void { + try { + window.getLastWindow(this.getUIContext().getHostContext(), (err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the top window, Cause code: ${err.code}, message: ${err.message}`); + return; + } + this.windowClass = data; + try { + if (this.windowClass !== undefined) { + console.log('success in listen height change'); + this.windowClass.on('keyboardHeightChange', this.callback); + } + } catch (exception) { + console.error(`Failed to enable the listener for keyboard height changes, Cause code: ${exception.code}, message: ${exception.message}`); + } + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }); + } catch (exception) { + console.error(`Failed to obtain the top window, Cause code: ${exception.code}, message: ${exception.message}`); + } + } + + callback = (height: number) => { + console.log('height change: ' + height); + if (height !== 0) { + this.scroller.scrollTo({ + xOffset: 0, yOffset: height + this.scroller.currentOffset().yOffset, + animation: { duration: 1000, curve: Curve.Ease, canOverScroll: false } + }); + } + } + + @Builder + myBuilder() { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item: number) => { + Row() { + Text(item.toString()) + .width('80%') + .height(60) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, (item: number) => item.toString()) + + TextInput().height('100') + + Flex({ alignItems: ItemAlign.End }) { + Row() { + Button('click') + .margin(10) + .fontSize(20) + .width('45%') + + Button('cancel') + .margin(10) + .fontSize(20) + .width('45%') + }.width('100%') + }.height(100) + }.margin({ right: 15, bottom: 50 }) + } + .height('100%') + .scrollBar(BarState.On) + .scrollable(ScrollDirection.Vertical) + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: 750, + backgroundColor: Color.Gray, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: 'title', subtitle: 'subtitle' }, + keyboardAvoidMode: SheetKeyboardAvoidMode.RESIZE_ONLY, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template7/SheetTransitionExample7.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template7/SheetTransitionExample7.ets new file mode 100644 index 0000000000000000000000000000000000000000..2269a458bf979c6fbb73f9f7f246e2d21d74d725 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template7/SheetTransitionExample7.ets @@ -0,0 +1,54 @@ +/* + * 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 { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetTransitionExample7 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button('content1') + .margin(10) + .fontSize(20) + + Button('content2') + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button('transition modal 1') + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + title: { title: 'title', subtitle: 'subtitle' }, + radius: { topStart: LengthMetrics.vp(50), topEnd: LengthMetrics.vp(10) }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template8/SheetSideExample8.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template8/SheetSideExample8.ets new file mode 100644 index 0000000000000000000000000000000000000000..20ea76d7b5df65610823e3430aa37904934510ba --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template8/SheetSideExample8.ets @@ -0,0 +1,108 @@ +/* + * 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 { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetSideExample8 { + @State isShowSide: boolean = false; + @State enableOutsideInteractive: boolean = false; + @State borderWidths: LocalizedEdgeWidths | undefined = undefined; + @State borderColors: Resource | undefined = undefined; + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + @Builder + sideBuilder() { + Column() { + ForEach(this.arr, (item: number) => { + Row() { + Text(item.toString()) + .width('90%') + .height(60) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, (item: number) => item.toString()) + TextInput() + .margin({ top: 5 }) + Text($r('app.string.sideBuilder_text1')) + .fontSize(22).fontColor(0xFFFFFF).fontWeight(FontWeight.Bold).textAlign(TextAlign.Center) + .width('100%').height(50).backgroundColor('#2ebd82') + Button('change enableOutsideInteractive = ' + this.enableOutsideInteractive) + .margin({ top: 5 }) + .onClick(() => { + this.enableOutsideInteractive = !this.enableOutsideInteractive; + if (this.enableOutsideInteractive) { + this.borderWidths = {start : LengthMetrics.vp(1)}; + this.borderColors = $r('sys.color.comp_divider'); + } else { + this.borderWidths = undefined; + this.borderColors = undefined; + } + }) + } + .width('100%') + .height('auto') + } + + + build() { + Column({space:3}) { + Button($r('app.string.sideBuilder_text2')) + .onClick(() => { + this.isShowSide = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShowSide, this.sideBuilder(), { + title: { title: 'SideSheet', subtitle: $r('app.string.sideBuilder_text3') }, + backgroundColor: Color.Grey, + onWillAppear: () => { + console.log('SideSheet onWillAppear.'); + }, + onAppear: () => { + console.log('SideSheet onAppear.'); + }, + onWillDisappear: () => { + console.log('SideSheet onWillDisappear.'); + }, + onDisappear: () => { + console.log('SideSheet onDisappear.'); + }, + + preferType: SheetType.SIDE, + blurStyle: BlurStyle.Regular, + maskColor: '#4bffc62d', // 自定义蒙层颜色 + enableOutsideInteractive: this.enableOutsideInteractive, + + borderWidth: this.borderWidths, + borderColor: this.borderColors, + + onHeightDidChange: (height: number)=>{ + console.log('SideSheet eight change:' + height); + }, + onTypeDidChange: (type: SheetType) => { + console.log('SideSheet type change:' + type); + }, + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template9/BindSheetDemo9.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template9/BindSheetDemo9.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e3b7b5738e61956bd9f82a2dce374661f9bc4df --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheet/template9/BindSheetDemo9.ets @@ -0,0 +1,100 @@ +/* + * 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. + */ +@Entry +@Component +struct BindSheetDemo9 { + // 半模态转场显示隐藏控制 + @State isShowSheet: boolean = false; + private menuList: string[] = ['No spicy food', 'Put less chili', 'Add more chili', 'No coriander, please', 'No chives, please', 'No disposable tableware, please', 'Disposable tableware is needed']; + + // 通过@Builder构建半模态展示界面 + @Builder + mySheet() { + Column() { + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap }) { + ForEach(this.menuList, (item: string) => { + Text(item) + .fontSize(16) + .fontColor(0x333333) + .backgroundColor(0xf1f1f1) + .borderRadius(8) + .margin(10) + .padding(10) + }) + } + .padding({ top: 18 }) + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } + + build() { + Column() { + Text($r('app.string.temp9string_text8')) + .fontSize(28) + .padding({ top: 30, bottom: 30 }) + Column() { + Row() { + Row() + .width(10) + .height(10) + .backgroundColor('#a8a8a8') + .margin({ right: 12 }) + .borderRadius(20) + + Column() { + Text($r('app.string.temp9string_text9')) + .fontSize(16) + .fontWeight(FontWeight.Medium) + } + .alignItems(HorizontalAlign.Start) + + Blank() + + Row() + .width(12) + .height(12) + .margin({ right: 15 }) + .border({ + width: { top: 2, right: 2 }, + color: 0xcccccc + }) + .rotate({ angle: 45 }) + } + .borderRadius(15) + .shadow({ radius: 100, color: '#ededed' }) + .width('90%') + .alignItems(VerticalAlign.Center) + .padding({ left: 15, top: 15, bottom: 15 }) + .backgroundColor(Color.White) + .bindSheet(this.isShowSheet, this.mySheet(), { + height: 300, + dragBar: false, + onDisappear: () => { + this.isShowSheet = !this.isShowSheet; + } + }) + .onClick(() => { + this.isShowSheet = !this.isShowSheet; + }) + } + .width('100%') + } + .width('100%') + .height('100%') + .backgroundColor(0xf1f1f1) + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/UIContextBindSheet.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/UIContextBindSheet.ets new file mode 100644 index 0000000000000000000000000000000000000000..b28ac3c4c1f1bb1330b1289f5b83bb7112107ffb --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/UIContextBindSheet.ets @@ -0,0 +1,98 @@ +/* + * 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 { FrameNode, ComponentContent } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + text: string = ''; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: 'Title', subtitle: 'subtitle' } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/UIContextBindSheet.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/UIContextBindSheet.ets new file mode 100644 index 0000000000000000000000000000000000000000..4834049c1efe96c6385015bf7d4fd8e34db0608c --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/UIContextBindSheet.ets @@ -0,0 +1,98 @@ +/* + * 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 { FrameNode, ComponentContent } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + public text: string = ''; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: 'Title', subtitle: 'subtitle' } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/UIContextBindSheet.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/UIContextBindSheet.ets new file mode 100644 index 0000000000000000000000000000000000000000..4834049c1efe96c6385015bf7d4fd8e34db0608c --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/UIContextBindSheet.ets @@ -0,0 +1,98 @@ +/* + * 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 { FrameNode, ComponentContent } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + public text: string = ''; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: 'Title', subtitle: 'subtitle' } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/ets/pages/common/Index.ets b/ArkUIKit/BindSheet/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..02c5c6b987280c6731d3e40af7c56c416176a3af --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/ets/pages/common/Index.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export interface Route { + name: string; + label: ResourceStr; +} + +export interface RouteGroup extends Route { + children: Route[]; +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/module.json5 b/ArkUIKit/BindSheet/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..00d847b7bfd514973fbade9f670e96253df4a7be --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * 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": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "orientation": "auto_rotation", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/element/color.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/element/float.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/float.json @@ -0,0 +1,17 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, { + "name": "size_16", + "value": "16" + }, { + "name": "size_100", + "value": "100" + }, { + "name": "size_64", + "value": "64" + } + ] +} diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/element/string.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..627aa51dfd93dcff2d7c1c25cc8a08c47e04bfbb --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/element/string.json @@ -0,0 +1,214 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "BindSheet" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, { + "name": "please_click_button", + "value": "请点击按钮" + }, { + "name": "bindContentCover_label", + "value": "全模态转场" + }, { + "name": "bindContentCover_label1", + "value": "示例1(使用全屏模态转场)" + }, { + "name": "bindContentCover_label2", + "value": "示例2(自定义转场动画)" + }, { + "name": "bindContentCover_label3", + "value": "示例3(上下切换转场)" + }, { + "name": "bindContentCover_label4", + "value": "示例4(透明度渐变转场)" + }, { + "name": "bindContentCover_label5", + "value": "示例5(设置不同效果的自定义转场)" + }, { + "name": "bindContentCover_label6", + "value": "示例6(使用bindContentCover构建全屏模态内容覆盖半模态)" + }, { + "name": "bindContentCover_label7", + "value": "示例7(使用bindContentCover构建全屏模态转场效果)" + }, { + "name": "bindSheet_label", + "value": "半模态转场" + }, { + "name": "bindSheet_label1", + "value": "示例1(不同高度的半模态弹窗)" + }, { + "name": "bindSheet_label2", + "value": "示例2(设置三个不同高度的档位)" + }, { + "name": "bindSheet_label3", + "value": "示例3(使用边框宽度和颜色)" + }, { + "name": "bindSheet_label4", + "value": "示例4(使用关闭回调函数)" + }, { + "name": "bindSheet_label5", + "value": "示例5(设置内容区刷新时机)" + }, { + "name": "bindSheet_label6", + "value": "示例6(设置压缩模态内容)" + }, { + "name": "bindSheet_label7", + "value": "示例7(镜像场景下如何设置圆角属性)" + }, { + "name": "bindSheet_label8", + "value": "示例8(半模态Side侧边样式)" + }, { + "name": "bindSheet_label9", + "value": "示例9(使用bindSheet构建半模态转场效果)" + }, { + "name": "bindSheet_label10", + "value": "示例10(使用嵌套滚动交互)" + }, { + "name": "bindSheetCmd_label", + "value": "命令式打开半模态" + }, { + "name": "bindSheetCmd_label1", + "value": "示例1(openBindSheet)" + }, { + "name": "bindSheetCmd_label2", + "value": "示例2(updateBindSheet)" + }, { + "name": "bindSheetCmd_label3", + "value": "示例3(closeBindSheet)" + }, { + "name": "MyContentCoverBuilder_text1", + "value": "选择乘车人" + }, { + "name": "MyContentCoverBuilder_text2", + "value": "+ 添加乘车人" + }, { + "name": "MyContentCoverBuilder_text3", + "value": "编辑" + }, { + "name": "MyContentCoverBuilder_text4", + "value": "确认" + }, { + "name": "MyContentCoverBuilder_text5", + "value": "始发站" + }, { + "name": "MyContentCoverBuilder_text6", + "value": "8时1分" + }, { + "name": "MyContentCoverBuilder_text7", + "value": "终点站" + }, { + "name": "MySheetBuilder_text1", + "value": "+ 选择乘车人" + }, { + "name": "MySheetBuilder_text2", + "value": "有票" + }, { + "name": "Person_example1", + "value": "王**" + }, { + "name": "Person_example2", + "value": "宋*" + }, { + "name": "Person_example3", + "value": "许**" + }, { + "name": "Person_example4", + "value": "唐*" + }, { + "name": "sideBuilder_text1", + "value": "改变半模态交互模式" + }, { + "name": "sideBuilder_text2", + "value": "半模态弹窗-Side" + }, { + "name": "sideBuilder_text3", + "value": "默认宽度" + }, { + "name": "temp9string_text1", + "value": "不要辣" + }, { + "name": "temp9string_text2", + "value": "少放辣" + }, { + "name": "temp9string_text3", + "value": "多放辣" + }, { + "name": "temp9string_text4", + "value": "不要香菜" + }, { + "name": "temp9string_text5", + "value": "不要香葱" + }, { + "name": "temp9string_text6", + "value": "不要一次性餐具" + }, { + "name": "temp9string_text7", + "value": "需要一次性餐具" + }, { + "name": "temp9string_text8", + "value": "口味与餐具" + }, { + "name": "temp9string_text9", + "value": "选择点餐口味和餐具" + }, { + "name": "tSheetBuilder_text1", + "value": "非滚动区域" + }, { + "name": "tSheetBuilder_text2", + "value": "嵌套滚动场景" + }, { + "name": "MySheetBuilder_text", + "value": "确认订单" + }, { + "name": "MySheetBuilder_text3", + "value": "确认订单" + }, { + "name": "bindSheetCmd_label5", + "value": "始发站" + }, { + "name": "bindSheetCmd_label6", + "value": "8时1分" + }, { + "name": "bindSheetCmd_label7", + "value": "终点站" + }, { + "name": "bindSheetCmd_label4", + "value": "确认" + },{ + "name": "bindSheetCmd_label8", + "value": "是否选择关闭半模态" + },{ + "name": "bindSheetCmd_label9", + "value": "拉起半模态e" + },{ + "name": "bindSheetCmd_label10", + "value": "enableHoverMode切换" + },{ + "name": "bindSheetCmd_label11", + "value": "hoverModeArea切换" + },{ + "name": "bindSheetCmd_label12", + "value": "是否选择关闭半模态" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/background.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/bg.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/bg.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/book.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/book.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/drawer.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/drawer.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/forest.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/forest.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/heart.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/heart.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collect + + + + + + + + + + \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collected + + + + + + + + + + \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon_2.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/icon_2.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image_1.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/image_1.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/img_1.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/BindSheet/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/ArkUIKit/BindSheet/entry/src/main/resources/base/media/mountain.jpg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/r.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/r.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sky.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sky.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sun.jpg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/sun.jpg differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/test.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/test.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImage.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImg.jpg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image2.png b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/media/tree.JPG b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/ArkUIKit/BindSheet/entry/src/main/resources/base/media/tree.JPG differ diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..8a5718a08ed0635c2abee498fbc441f96a7b0af9 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,27 @@ +{ + "src": [ + "pages/Index", + "pages/bindContentCover/template1/ModalTransitionExample", + "pages/bindContentCover/template2/ModalTransitionExample2", + "pages/bindContentCover/template3/ModalTransitionExample3", + "pages/bindContentCover/template4/ModalTransitionExample4", + "pages/bindContentCover/template5/ModalTransitionExample5", + "pages/bindContentCover/template6/BindContentCoverDemo", + "pages/bindContentCover/template7/BindContentCoverDemo", + "pages/bindSheet/template1/SheetTransitionExample1", + "pages/bindSheet/template2/SheetTransitionExample2", + "pages/bindSheet/template3/SheetTransitionExample3", + "pages/bindSheet/template4/bindSheetExample4", + "pages/bindSheet/template5/bindSheetExample5", + "pages/bindSheet/template6/ListenKeyboardHeightChange", + "pages/bindSheet/template7/SheetTransitionExample7", + "pages/bindSheet/template8/SheetSideExample8", + "pages/bindSheet/template9/BindSheetDemo9", + "pages/bindSheet/template10/SheetDemo", + "pages/bindSheetCmd/template1/UIContextBindSheet", + "pages/bindSheetCmd/template2/UIContextBindSheet", + "pages/bindSheetCmd/template3/UIContextBindSheet", + "pages/bindSheet/template11/OnWillDismiss_Dismiss", + "pages/bindSheet/template12/SheetTransitionExample" + ] +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/main/resources/dark/element/color.json b/ArkUIKit/BindSheet/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/BindSheet/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/ArkUIKit/BindSheet/entry/src/mock/mock-config.json5 b/ArkUIKit/BindSheet/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * 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. + */ +{ +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f30942b81554a399e89aa253c7089eca4f8d8d1 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,49 @@ +/* + * 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/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..33e94cd44182c6638d18d29080f5afe3fe926620 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets @@ -0,0 +1,264 @@ +/* + * 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 { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; + +let aimComponent : Component + +export function BindContentCoverTest() { + describe('BindSheet_BindContentCoverTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_001 + * @tc.name: example_one_BindContentCover + * @tc.desc: example_one_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_001_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_002 + * @tc.name: example_two_BindContentCover + * @tc.desc: example_two_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label2')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_002_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_003 + * @tc.name: example_three_BindContentCover + * @tc.desc: example_three_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label3')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_003_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_004 + * @tc.name: example_four_BindContentCover + * @tc.desc: example_four_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label4')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_004_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_005 + * @tc.name: example_five_BindContentCover + * @tc.desc: example_five_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label5')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Transition Modal 1')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Transition Modal 2')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Close Modal 2')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Close Modal 1')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_005_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_006 + * @tc.name: example_six_BindContentCover + * @tc.desc: example_six_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label6')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MySheetBuilder_text2')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MySheetBuilder_text1')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text4')))) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_006_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_007 + * @tc.name: example_seven_BindContentCover + * @tc.desc: example_seven_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label7')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text2')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text4')))) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_007_end'); + }) + }) +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..33efd28be2fbb2c6d73977a68048406559c5a34f --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets @@ -0,0 +1,332 @@ +/* + * 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 { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function BindSheetTest() { + describe('BindSheet_BindSheetTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_BindSheetTest_001 + * @tc.name: example_one_BindSheet + * @tc.desc: example_one_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Set Illegal height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_001_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_002 + * @tc.name: example_two_BindSheet + * @tc.desc: example_two_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.565) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.21186) + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(endX, endY, startX, Math.floor(size.y * 0.53)); + await driver.delayMs(1000); + + await driver.swipe(endX, endY, startX, Math.floor(size.y * 0.883)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_002_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_003 + * @tc.name: example_three_BindSheet + * @tc.desc: example_three_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_003_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_004 + * @tc.name: example_four_BindSheet + * @tc.desc: example_four_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label4')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('NoRegisterSpringback')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let x = Math.floor(size.x * 0.5) + await driver.swipe(x, Math.floor(size.y * 0.4125), x, Math.floor(size.y * 0.95)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_004_end'); + }) + + + /* + * @tc.number: BindSheet_BindSheetTest_005 + * @tc.name: example_five_BindSheet + * @tc.desc: example_five_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label5')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let x = Math.floor(size.x * 0.5) + + await driver.swipe(x, Math.floor(size.y * 0.706), x, Math.floor(size.y * 0.353)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_005_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_006 + * @tc.name: example_six_BindSheet + * @tc.desc: example_six_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label6')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('TextInput')) + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.pressBack(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_006_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_007 + * @tc.name: example_seven_BindSheet + * @tc.desc: example_seven_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label7')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_007_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_008 + * @tc.name: example_eight_BindSheet + * @tc.desc: example_eight_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_008', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_008_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label8')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.sideBuilder_text2')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_008_end'); + }) + + + /* + * @tc.number: BindSheet_BindSheetTest_009 + * @tc.name: example_nine_BindSheet + * @tc.desc: example_nine_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_009', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_009_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label9')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.temp9string_text9')))); + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.pressBack(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_009_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_0010 + * @tc.name: example_ten_BindSheet + * @tc.desc: example_ten_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_0010', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_010_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label10')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open Sheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.353) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.106) + + await driver.swipe(startX, Math.floor(size.y * 0.6356), endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, Math.floor(size.y * 0.282), endX, Math.floor(size.y * 0.6356)); + await driver.delayMs(1000); + + await driver.swipe(startX, Math.floor(size.y * 0.53), endX, Math.floor(size.y * 0.8828)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_010_end'); + }) + + }) + +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..873936a37bce082d47eeada32a07cb2274e87c39 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 { BindSheetTest } from './BindSheet.test'; +import { BindContentCoverTest } from './BindContentCover.test'; +import { OpenSheetTest } from './OpenSheet.test'; + +export default function testsuite() { + BindSheetTest(); + BindContentCoverTest(); + OpenSheetTest(); +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca58826991bafd98e9d2d98ab6b0d9db992f99a9 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets @@ -0,0 +1,122 @@ +/* + * 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 { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function OpenSheetTest() { + describe('BindSheet_OpenSheetTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_001 + * @tc.name: example_one_OpenSheet + * @tc.desc: example_one_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_001_end'); + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_002 + * @tc.name: example_two_OpenSheet + * @tc.desc: example_two_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Update BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_002_end'); + + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_003 + * @tc.name: example_three_OpenSheet + * @tc.desc: example_three_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Close BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/BindSheet/entry/src/ohosTest/module.json5 b/ArkUIKit/BindSheet/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..59667117c86b64ab9863f7b382c435ae4a3c32fa --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * 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": "entry_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkUIKit/BindSheet/entry/src/test/List.test.ets b/ArkUIKit/BindSheet/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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/ArkUIKit/BindSheet/entry/src/test/LocalUnit.test.ets b/ArkUIKit/BindSheet/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/ArkUIKit/BindSheet/entry/src/test/LocalUnit.test.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. + */ +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/ArkUIKit/BindSheet/hvigor/hvigor-config.json5 b/ArkUIKit/BindSheet/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d435603637cbbfe92ac9865537a0c1051810bb1 --- /dev/null +++ b/ArkUIKit/BindSheet/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * 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. + */ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | 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 */ + }, + "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*/ + } +} diff --git a/ArkUIKit/BindSheet/hvigorfile.ts b/ArkUIKit/BindSheet/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/ArkUIKit/BindSheet/hvigorfile.ts @@ -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 { 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. */ +} diff --git a/ArkUIKit/BindSheet/oh-package.json5 b/ArkUIKit/BindSheet/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..38abfd099681aeb547cf83a4966111dd5f4f6d13 --- /dev/null +++ b/ArkUIKit/BindSheet/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkUIKit/BindSheet/ohosTest.md b/ArkUIKit/BindSheet/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..11efe52ebecd2768d1daa51e242a99faa1a14fd3 --- /dev/null +++ b/ArkUIKit/BindSheet/ohosTest.md @@ -0,0 +1,9 @@ +# BindSheet 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 全模态转场示例代码验证 | 设备正常运行 | 进入各个示例页面,唤起全模态 | 全模态行为正常,布局正确 | 是 | Pass | +| 半模态转场示例代码验证 | 设备正常运行 | 进入各个示例页面,唤起半模态 | 半模态行为正常,布局正确 | 是 | Pass | +| 命令式打开半模态示例代码验证 | 设备正常运行 | 进入各个示例页面,通过命令式打开半模态 | 半模态行为正常,布局正确 | 是 | Pass | diff --git a/ArkUIKit/BindSheet/screenshots/device/image1.png b/ArkUIKit/BindSheet/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..5c18b3a39d518f752050fd5193355d5a3884eea4 Binary files /dev/null and b/ArkUIKit/BindSheet/screenshots/device/image1.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/AppScope/app.json5 b/ArkUIKit/arktsobservedv2andtrace/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d23ec4256cacfbbbaaf72ce4fadec59f5b2ba56f --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "app": { + "bundleName": "com.samples.arktsobservedv2andtrace", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/element/string.json b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..951a0f6119090a1382fab580b7c9a123279cd39d --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "arktsobservedv2andtrace" + } + ] +} diff --git a/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/background.png b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/foreground.png b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/layered_image.json b/ArkUIKit/arktsobservedv2andtrace/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/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/ArkUIKit/arktsobservedv2andtrace/README_zh.md b/ArkUIKit/arktsobservedv2andtrace/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..14bc959cc02241f1993ade7c67211e4fd3f6acca --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/README_zh.md @@ -0,0 +1,100 @@ +# ArkUI使用@ObservedV2装饰器和@Trace装饰器:类属性变化观测指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitcode.com/openharmony/docs/tree/master/zh-cn/application-dev/ui) +中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [@ObservedV2装饰器和@Trace装饰器:类属性变化观测](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/state-management/arkts-new-observedV2-and-trace.md) + +### 效果预览 + +| 首页 | @Trace装饰Date类型 | +|--------------------------|----------------------------| +| ![](screenshots/img.png) | ![](screenshots/img_1.png) | + +### 使用说明 + +1. **强制搭配使用**:@ObservedV2(类装饰器)与 @Trace(成员属性装饰器)必须配合使用,单独使用无任何观测效果;仅被 @Trace + 装饰的属性变化时,会触发关联 UI 组件刷新,未装饰属性无法触发 UI 刷新。 + +2. **支持场景与类型**:适配嵌套类、继承类场景,嵌套类需同时用 @ObservedV2 装饰类和 @Trace 装饰属性;支持装饰 + number、string、数组、Map、Set、Date 等类型,数组 / 集合可观测 push、set、clear 等特定 API 操作带来的变化。 + +3. **实例化与混用限制**:被装饰的类需通过 new 操作符实例化后才具备观测能力,不支持 JSON.stringify 序列化;禁止与 + @Observed、@Track、@State 等 V1 装饰器混合使用,且 @ObservedV2 不能装饰自定义组件、@Trace 不能用于 struct。 + +4. **继承与静态属性规则**:继承类中,父类或子类的 @Trace 装饰属性均具备观测能力;类的静态属性被 @Trace 装饰后,其变化也可触发 + UI 刷新,无需额外配置。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---overview +| | |---InheritedChanges.ets +| | |---Limitations.ets +| | |---ObserveChanges.ets +| | |---RealizeObservation.ets +| | |---StaticAttribute.ets +| |---usagerestrictions +| | |---InheritanceMixture.ets +| | |---UiRefreshCannotTriggered.ets +| | |---UseMixture.ets +| |---usagescenarios +| | |---DecorateDate.ets +| | |---DecorationFoundation.ets +| | |---DecorationMap.ets +| | |---DecorationSet.ets +| | |---DecorativeObject.ets +| | |---InheritanceClass.ets +| | |---NestedClass.ets +| |---Index.ets // 应用主页面入口 +entry/src/ohosTest/ +|---ets +| |---index.test.ets // 示例代码测试代码 +``` + +### 具体实现 + +1. **基础计数器实现**:用 @ObservedV2 装饰计数器类,@Trace 装饰计数属性(如 number 类型的 count),在 UI 组件中绑定该属性并设置点击事件,通过修改 + count 值触发 UI 自动刷新,无需额外状态管理装饰器。 + +2. **嵌套对象计数实现**:在嵌套类结构中,外层类与内层类均用 @ObservedV2 装饰,内层类的计数属性用 @Trace 装饰,UI + 直接绑定内层属性,修改该属性时可跨层级触发关联组件刷新,无需拆分自定义组件。 + +3. **数组 / 集合计数实现**:用 @Trace 装饰数组或 Set 类型属性,通过 push、add 等支持的 API 修改集合元素数量,UI + 绑定集合长度属性,集合变化时自动同步刷新长度显示,适配批量计数场景。 + +4. **继承类计数实现**:在继承体系中,父类用 @ObservedV2 装饰并通过 @Trace 定义基础计数属性,子类继承父类后可直接复用该计数属性,修改子类实例的计数属性时,仍能正常触发 + UI 刷新,简化继承场景开发。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.47,镜像版本号:OpenHarmony_6.0.0.47。 + +3.本示例需要使用DevEco Studio NEXT Developer Preview2 (Build Version: 6.0.0.47, built on October 21, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUISample/arktsobservedv2andtrace > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/build-profile.json5 b/ArkUIKit/arktsobservedv2andtrace/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3ca5a93fb814017ac4c398aacbdf17b1d8b0a237 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * 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. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "targetSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/code-linter.json5 b/ArkUIKit/arktsobservedv2andtrace/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * 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. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/build-profile.json5 b/ArkUIKit/arktsobservedv2andtrace/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9016faf39f8a65cf648bae246a53575510fe8b9f --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/build-profile.json5 @@ -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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/hvigorfile.ts b/ArkUIKit/arktsobservedv2andtrace/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8b117a17af3b2d7cb87a7680e29e2bb8ccd5b46 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/hvigorfile.ts @@ -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 { 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/ArkUIKit/arktsobservedv2andtrace/entry/obfuscation-rules.txt b/ArkUIKit/arktsobservedv2andtrace/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/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/ArkUIKit/arktsobservedv2andtrace/entry/oh-package.json5 b/ArkUIKit/arktsobservedv2andtrace/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..98182799de1294d4c21194646a0c30eff08aea33 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/Index.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c5926c02a1dbe34f0cb10b922987bf8bdc015f8 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,66 @@ +/* + * 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. + */ +class CreateRouter{ + public pageName:string; + public routerName:string; + constructor(pageName:string,routerName:string){ + this.pageName = pageName; + this.routerName = routerName; + }; +}; +const createRouterList: CreateRouter[] = [ + new CreateRouter('LimitationsPage', 'pages/overview/Limitations'), + new CreateRouter('RealizeObservationPage', 'pages/overview/RealizeObservation'), + new CreateRouter('ObserveChangesPage', 'pages/overview/ObserveChanges'), + new CreateRouter('InheritedChangesPage', 'pages/overview/InheritedChanges'), + new CreateRouter('StaticAttributePage', 'pages/overview/StaticAttribute'), + new CreateRouter('UiRefreshCannotTriggeredPage', 'pages/usagerestrictions/UiRefreshCannotTriggered'), + new CreateRouter('UseMixturePage', 'pages/usagerestrictions/UseMixture'), + new CreateRouter('InheritanceMixturePage', 'pages/usagerestrictions/InheritanceMixture'), + new CreateRouter('NestedClassPage', 'pages/usagescenarios/NestedClass'), + new CreateRouter('InheritanceClassPage', 'pages/usagescenarios/InheritanceClass'), + new CreateRouter('DecorationFoundationPage', 'pages/usagescenarios/DecorationFoundation'), + new CreateRouter('DecorativeObjectPage', 'pages/usagescenarios/DecorativeObject'), + new CreateRouter('DecorationMapPage', 'pages/usagescenarios/DecorationMap'), + new CreateRouter('DecorationSetPage', 'pages/usagescenarios/DecorationSet'), + new CreateRouter('DecorateDatePage', 'pages/usagescenarios/DecorateDate') +]; +@Entry +@Component +struct Index { + @State createRouterListIndex:CreateRouter[] = createRouterList; + build() { + List({space:8}){ + ForEach(this.createRouterListIndex, (item:CreateRouter) => { + ListItem(){ + Text(item.pageName) + .textAlign(TextAlign.Center) + .width('90%') + .height(30) + .borderRadius(5) + .backgroundColor('#f5f5f5') + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: `${item.routerName}`, + }); + }); + } + }, (item:CreateRouter, index:number) => JSON.stringify(item)); + } + .alignListItem(ListItemAlign.Center) + .height('auto') + .width('auto') + } +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/InheritedChanges.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/InheritedChanges.ets new file mode 100644 index 0000000000000000000000000000000000000000..4577372ff26a6b1adcd37da29ba9fc42e383bf07 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/InheritedChanges.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Inherited_Changes] +@ObservedV2 +class FatherInheritance { + @Trace public name: string = 'Tom'; +} +class ChangesSon extends FatherInheritance { +} +@Entry +@ComponentV2 +struct InheritedChanges { + son: ChangesSon = new ChangesSon(); + + build() { + Column() { + // 当点击改变name时,Text组件会刷新 + Text(`${this.son.name}`) + .onClick(() => { + this.son.name = 'Jack'; + }); + } + } +} +// [End Inherited_Changes] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/Limitations.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/Limitations.ets new file mode 100644 index 0000000000000000000000000000000000000000..f54bb01ef05d78cfe0a53510518093a4e78af403 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/Limitations.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Observed_Limitations] +@Observed +class FatherLim { + public son: SonLim; + + constructor(name: string, age: number) { + this.son = new SonLim(name, age); + }; +}; +@Observed +class SonLim { + public name: string; + public age: number; + + constructor(name: string, age: number) { + this.name = name; + this.age = age; + }; +}; +@Entry +@Component +struct Limitations { + @State father: FatherLim = new FatherLim('John', 8); + + build() { + Row() { + Column() { + Text(`name: ${this.father.son.name} age: ${this.father.son.age}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.father.son.age++; + }); + } + .width('100%') + } + .height('100%') + } +} +// [End Observed_Limitations] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/ObserveChanges.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/ObserveChanges.ets new file mode 100644 index 0000000000000000000000000000000000000000..76bb5f5c189c43910c1e276cfc207d968f7af817 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/ObserveChanges.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Observe_Changes] +@ObservedV2 +class SonChang { + // The age attribute, tracked for changes to trigger UI updates + @Trace public age: number = 100; +} +class FatherChang { + public son: SonChang = new SonChang(); +} +@Entry +@ComponentV2 +struct ObserveChanges { + father: FatherChang = new FatherChang(); + + build() { + Column() { + // 当点击改变age时,Text组件会刷新 + Text(`${this.father.son.age}`) + .onClick(() => { + this.father.son.age++; + }); + } + } +} +// [End Observe_Changes] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/RealizeObservation.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/RealizeObservation.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba1f2b6f0c3aa41d52e22b2dcaf927de9351e075 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/RealizeObservation.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Realize_Observation] +@Observed +class FatherRea { + public son: SonRea; + + constructor(name: string, age: number) { + this.son = new SonRea(name, age); + }; +}; +@Observed +class SonRea { + public name: string; + public age: number; + + constructor(name: string, age: number) { + this.name = name; + this.age = age; + }; +}; +@Component +struct Child { + @ObjectLink son: SonRea; + + build() { + Row() { + Column() { + Text(`name: ${this.son.name} age: ${this.son.age}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.son.age++; + }); + } + .width('100%') + } + .height('100%') + } +} +@Entry +@Component +struct RealizeObservation { + @State father: FatherRea = new FatherRea('John', 8); + + build() { + Column() { + Child({son: this.father.son}); + } + } +} +// [End Realize_Observation] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/StaticAttribute.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/StaticAttribute.ets new file mode 100644 index 0000000000000000000000000000000000000000..53f8a775298a6c30bce18984327dc2bd6437a35c --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/overview/StaticAttribute.ets @@ -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. + */ +// [Start Static_Attribute] +@ObservedV2 +class Manager { + // Decorate the static property 'count' with @Trace to enable its changes to trigger UI updates + @Trace public static count: number = 1; +}; +@Entry +@ComponentV2 +struct StaticAttribute { + build() { + Column() { + // 当点击改变count时,Text组件会刷新 + Text(`${Manager.count}`) + .onClick(() => { + Manager.count++; + }); + } + } +} +// [End Static_Attribute] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/InheritanceMixture.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/InheritanceMixture.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a11393b5002174502540cfac36df08395bc12d8 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/InheritanceMixture.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Inheritance_Mixture] +// 以@State装饰器为例 +@ObservedV2 +class Job { + @Trace public jobName: string = 'Teacher'; +}; +@ObservedV2 +class InheritanceMixtureInfo { + @Trace public name: string = 'Tom'; + // Decorate the 'age' property with @Trace to enable its changes to trigger UI updates + @Trace public age: number = 25; + public job: Job = new Job(); +}; +class Message extends InheritanceMixtureInfo { + constructor() { + super(); + }; +}; +@Entry +// @Component 需使用@ComponentV2 +@ComponentV2 +struct InheritanceMixture { + // @State message: Message = new Message(); 无法混用,运行时报错 + @Local message: Message = new Message(); + + build() { + Column() { + Text(`name: ${this.message.name}`) + Text(`age: ${this.message.age}`) + Text(`jobName: ${this.message.job.jobName}`) + Button('change age') + .onClick(() => { + this.message.age++; + }); + Button('Change job') + .onClick(() => { + this.message.job.jobName = 'Doctor'; + }); + } + } +} +// [End Inheritance_Mixture] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UiRefreshCannotTriggered.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UiRefreshCannotTriggered.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d52e45e1d3af8375bd2d27fc7e9112947fbe6ff --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UiRefreshCannotTriggered.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start UiRefreshCannotTriggered] +@ObservedV2 +class TriggeredPerson { + // Public property to store the unique identifier + public id: number = 0; + // Property 'age' decorated with @Trace to trigger UI updates when its value changes + @Trace public age: number = 8; +}; +@Entry +@ComponentV2 +struct UiRefreshCannotTriggered { + person: TriggeredPerson = new TriggeredPerson(); + + build() { + Column() { + // age被@Trace装饰,用在UI中可以触发UI刷新 + Text(`${this.person.age}`) + .onClick(() => { + this.person.age++; // 点击会触发UI刷新 + }); + // id未被@Trace装饰,用在UI中不会触发UI刷新 + Text(`${this.person.id}`) // 当id变化时不会刷新 + .onClick(() => { + this.person.id++; // 点击不会触发UI刷新 + }); + } + } +} +// [End UiRefreshCannotTriggered] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UseMixture.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UseMixture.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ead37b4d385e9d4d3082497defbd8e7d6459bfd --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagerestrictions/UseMixture.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Use_Mixture] +// 以@State装饰器为例 +@ObservedV2 +class UseMixtureJob { + @Trace public jobName: string = 'Teacher'; +}; +@ObservedV2 +class UseMixtureInfo { + @Trace public name: string = 'Tom'; + // The 'age' property is decorated with @Trace, so its changes will trigger UI updates + @Trace public age: number = 25; + public job: UseMixtureJob = new UseMixtureJob(); +}; +@Entry +// @Component 需使用@ComponentV2 +@ComponentV2 +struct UseMixture { + // @State info: UseMixtureInfo = new UseMixtureInfo(); 无法混用,编译时报错 + @Local info: UseMixtureInfo = new UseMixtureInfo(); + + build() { + Column() { + Text(`name: ${this.info.name}`) + Text(`age: ${this.info.age}`) + Text(`jobName: ${this.info.job.jobName}`) + Button('change age') + .onClick(() => { + this.info.age++; + }); + Button('Change job') + .onClick(() => { + this.info.job.jobName = 'Doctor'; + }); + } + } +} +// [End Use_Mixture] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorateDate.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorateDate.ets new file mode 100644 index 0000000000000000000000000000000000000000..02b0284bfc4721c12cb904f4a0d3414bd92ec5dd --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorateDate.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Decorate_Date] +@ObservedV2 +class DateInfo { + @Trace public selectedDate: Date = new Date('2021-08-08'); +}; + +@Entry +@ComponentV2 +struct DateSample { + info: DateInfo = new DateInfo(); + + build() { + Column() { + Button('set selectedDate to 2023-07-08') + .margin(10) + .onClick(() => { + this.info.selectedDate = new Date('2023-07-08'); + }); + Button('increase the year by 1') + .margin(10) + .onClick(() => { + this.info.selectedDate.setFullYear(this.info.selectedDate.getFullYear() + 1); + }); + Button('increase the month by 1') + .margin(10) + .onClick(() => { + this.info.selectedDate.setMonth(this.info.selectedDate.getMonth() + 1); + }); + Button('increase the day by 1') + .margin(10) + .onClick(() => { + this.info.selectedDate.setDate(this.info.selectedDate.getDate() + 1); + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.info.selectedDate + }); + }.width('100%') + } +} +// [End Decorate_Date] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationFoundation.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationFoundation.ets new file mode 100644 index 0000000000000000000000000000000000000000..16fca7486ba18f803ecf0aef2395449a438caa06 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationFoundation.ets @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Decoration_Foundation] +// Variable to generate unique IDs for foundation-related instances +let foundationNextId: number = 0; + +@ObservedV2 +class Arr { + // Public property storing the instance's unique identifier + public id: number = 0; + @Trace public numberArr: number[] = []; + + constructor() { + this.id = foundationNextId++; + this.numberArr = [0, 1, 2]; + }; +}; + +@Entry +@ComponentV2 +struct DecorationFoundation { + arr: Arr = new Arr(); + + build() { + Column() { + Text(`length: ${this.arr.numberArr.length}`) + .fontSize(40) + Divider() + if (this.arr.numberArr.length >= 3) { + Text(`${this.arr.numberArr[0]}`) + .fontSize(40) + .onClick(() => { + this.arr.numberArr[0]++; + }); + Text(`${this.arr.numberArr[1]}`) + .fontSize(40) + .onClick(() => { + this.arr.numberArr[1]++; + }); + Text(`${this.arr.numberArr[2]}`) + .fontSize(40) + .onClick(() => { + this.arr.numberArr[2]++; + }); + } + + Divider() + + ForEach(this.arr.numberArr, (item: number, index: number) => { + Text(`${index} ${item}`) + .fontSize(40) + }); + + Button('push') + .onClick(() => { + this.arr.numberArr.push(50); + }); + + Button('pop') + .onClick(() => { + this.arr.numberArr.pop(); + }); + + Button('shift') + .onClick(() => { + this.arr.numberArr.shift(); + }); + + Button('splice') + .onClick(() => { + this.arr.numberArr.splice(1, 0, 60); + }); + + + Button('unshift') + .onClick(() => { + this.arr.numberArr.unshift(100); + }); + + Button('copywithin') + .onClick(() => { + this.arr.numberArr.copyWithin(0, 1, 2); + }); + + Button('fill') + .onClick(() => { + this.arr.numberArr.fill(0, 2, 4); + }); + + Button('reverse') + .onClick(() => { + this.arr.numberArr.reverse(); + }); + + Button('sort') + .onClick(() => { + this.arr.numberArr.sort(); + }); + } + } +} +// [End Decoration_Foundation] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationMap.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationMap.ets new file mode 100644 index 0000000000000000000000000000000000000000..77e7bd263333505cc0ba4cd306080f542c938c38 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationMap.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Decoration_Map] +@ObservedV2 +class MapInfo { + @Trace public memberMap: Map = new Map([[0, 'a'], [1, 'b'], [3, 'c']]); +}; + +@Entry +@ComponentV2 +struct MapSample { + info: MapInfo = new MapInfo(); + + build() { + Row() { + Column() { + ForEach(Array.from(this.info.memberMap.entries()), (item: [number, string]) => { + Text(`${item[0]}`) + .fontSize(30) + Text(`${item[1]}`) + .fontSize(30) + Divider() + }); + Button('init map') + .onClick(() => { + this.info.memberMap = new Map([[0, 'a'], [1, 'b'], [3, 'c']]); + }); + Button('set new one') + .onClick(() => { + this.info.memberMap.set(4, 'd'); + }); + Button('clear') + .onClick(() => { + this.info.memberMap.clear(); + }); + Button('set the key: 0') + .onClick(() => { + this.info.memberMap.set(0, 'aa'); + }); + Button('delete the first one') + .onClick(() => { + this.info.memberMap.delete(0); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End Decoration_Map] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationSet.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationSet.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd3455285d50c1dc4d6f7f8a22a8e4ccc2924e6f --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorationSet.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Decoration_Set] +@ObservedV2 +class SetInfo { + @Trace public memberSet: Set = new Set([0, 1, 2, 3, 4]); +}; + +@Entry +@ComponentV2 +struct SetSample { + info: SetInfo = new SetInfo(); + + build() { + Row() { + Column() { + ForEach(Array.from(this.info.memberSet.entries()), (item: [number, number]) => { + Text(`${item[0]}`) + .fontSize(30) + Divider() + }); + Button('init set') + .onClick(() => { + this.info.memberSet = new Set([0, 1, 2, 3, 4]); + }); + Button('set new one') + .onClick(() => { + this.info.memberSet.add(5); + }); + Button('clear') + .onClick(() => { + this.info.memberSet.clear(); + }); + Button('delete the first one') + .onClick(() => { + this.info.memberSet.delete(0); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End Decoration_Set] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorativeObject.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorativeObject.ets new file mode 100644 index 0000000000000000000000000000000000000000..003cfba984375d23ec92f34ccfe1c4a7f55ea50c --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/DecorativeObject.ets @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start Decorative_Object] +// Used to generate unique IDs for ObjectInfo instances +let nextId: number = 0; + +@ObservedV2 +class Person { + @Trace public age: number = 0; + + constructor(age: number) { + this.age = age; + }; +}; + +@ObservedV2 +class ObjectInfo { + // Public property to hold the unique identifier of the instance + public id: number = 0; + @Trace public personList: Person[] = []; + + constructor() { + this.id = nextId++; + this.personList = [new Person(0), new Person(1), new Person(2)]; + }; +}; + +@Entry +@ComponentV2 +struct DecorativeObject { + info: ObjectInfo = new ObjectInfo(); + + build() { + Column() { + Text(`length: ${this.info.personList.length}`) + .fontSize(40) + Divider() + if (this.info.personList.length >= 3) { + Text(`${this.info.personList[0].age}`) + .fontSize(40) + .onClick(() => { + this.info.personList[0].age++; + }); + + Text(`${this.info.personList[1].age}`) + .fontSize(40) + .onClick(() => { + this.info.personList[1].age++; + }); + + Text(`${this.info.personList[2].age}`) + .fontSize(40) + .onClick(() => { + this.info.personList[2].age++; + }); + } + + Divider() + + ForEach(this.info.personList, (item: Person, index: number) => { + Text(`${index} ${item.age}`) + .fontSize(40) + }); + } + } +} +// [End Decorative_Object] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/InheritanceClass.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/InheritanceClass.ets new file mode 100644 index 0000000000000000000000000000000000000000..42282ff7bc06fffafef0f8384f4e2d0b6a6dc106 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/InheritanceClass.ets @@ -0,0 +1,84 @@ +/* + * 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'; +const DOMAIN = 0x0001; +const TAG = 'arktsobservedv2andtrace'; +// [Start Inheritance_Class] +@ObservedV2 +class GrandFather { + // The 'age' property is decorated with @Trace, so changes to its value will trigger UI updates + @Trace public age: number = 0; + + constructor(age: number) { + this.age = age; + }; +}; +class Father extends GrandFather{ + constructor(father: number) { + super(father); + }; +}; +class Uncle extends GrandFather { + constructor(uncle: number) { + super(uncle); + }; +}; +class Son extends Father { + constructor(son: number) { + super(son); + }; +}; +class Cousin extends Uncle { + constructor(cousin: number) { + super(cousin); + }; +}; +@Entry +@ComponentV2 +struct InheritanceClass { + son: Son = new Son(0); + cousin: Cousin = new Cousin(0); + renderTimes: number = 0; + + isRender(id: number): number { + hilog.info(DOMAIN, TAG,`id: ${id} renderTimes: ${this.renderTimes}`); + this.renderTimes++; + return 40; + }; + + build() { + Row() { + Column() { + Text(`Son ${this.son.age}`) + .fontSize(this.isRender(1)) + .fontWeight(FontWeight.Bold) + Text(`Cousin ${this.cousin.age}`) + .fontSize(this.isRender(2)) + .fontWeight(FontWeight.Bold) + Button('change Son age') + .onClick(() => { + this.son.age++; + }); + Button('change Cousin age') + .onClick(() => { + this.cousin.age++; + }); + } + .width('100%') + } + .height('100%') + } +} +// [End Inheritance_Class] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/NestedClass.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/NestedClass.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9b5e2cb22ca996eadb430d5555e6d60b6b26340 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/ets/pages/usagescenarios/NestedClass.ets @@ -0,0 +1,66 @@ +/* + * 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'; +const DOMAIN = 0x0001; +const TAG = 'arktsobservedv2andtrace'; +// [Start Nested_Class] +@ObservedV2 +class Pencil { + @Trace public length: number = 21; // 当length变化时,会刷新关联的组件 +} +class Bag { + // Public property representing the width dimension + public width: number = 50; + // Public property representing the height dimension + public height: number = 60; + public pencil: Pencil = new Pencil(); +} +class NestedClassSon { + // Public property storing the age value + public age: number = 5; + public school: string = 'some'; + public bag: Bag = new Bag(); +} + +@Entry +@ComponentV2 +struct Page { + son: NestedClassSon = new NestedClassSon(); + // Variable to track the number of times the component has been rendered + renderTimes: number = 0; + isRender(id: number): number { + hilog.info(DOMAIN,TAG,`id: ${id} renderTimes: ${this.renderTimes}`); + this.renderTimes++; + return 40; + }; + + build() { + Column() { + Text('pencil length'+ this.son.bag.pencil.length) + .fontSize(this.isRender(1)) // UINode (1) + Button('change length') + .onClick(() => { + // 点击更改length值,UINode(1)会刷新 + this.son.bag.pencil.length += 100; + }); + Button('assign Son') + .onClick(() => { + // 由于变量son非状态变量,因此无法刷新UINode(1) + this.son = new NestedClassSon(); + }); + } + } +} +// [End Nested_Class] \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/module.json5 b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..476f4f508edb44dc9edfe115808545c33b284e0b --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/module.json5 @@ -0,0 +1,64 @@ +/* + * 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": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/color.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/float.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..a0a93dd91fd48f08f3a9532c76e9b26e68d4c034 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/string.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/background.png b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/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/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..f1993eb322dcdb008c7055c2cdaf7f0e326d5947 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,20 @@ +{ + "src": [ + "pages/Index", + "pages/overview/Limitations", + "pages/overview/RealizeObservation", + "pages/overview/ObserveChanges", + "pages/overview/InheritedChanges", + "pages/overview/StaticAttribute", + "pages/usagerestrictions/UiRefreshCannotTriggered", + "pages/usagerestrictions/UseMixture", + "pages/usagerestrictions/InheritanceMixture", + "pages/usagescenarios/NestedClass", + "pages/usagescenarios/InheritanceClass", + "pages/usagescenarios/DecorationFoundation", + "pages/usagescenarios/DecorativeObject", + "pages/usagescenarios/DecorationMap", + "pages/usagescenarios/DecorationSet", + "pages/usagescenarios/DecorateDate" + ] +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/dark/element/color.json b/ArkUIKit/arktsobservedv2andtrace/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/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/ArkUIKit/arktsobservedv2andtrace/entry/src/mock/mock-config.json5 b/ArkUIKit/arktsobservedv2andtrace/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * 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. + */ +{ +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/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/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/Index.test.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/Index.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0fcb5fb25c07243cee46526ac2aa9e6cb02300d2 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/Index.test.ets @@ -0,0 +1,400 @@ +/* + * 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'; +import { abilityDelegatorRegistry, Driver, ON, MatchPattern } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; +import hilog from '@ohos.hilog'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; +let driver: Driver; +const TAG = '[Sample_arktsobservedv2andtrace]'; +const DOMAIN = 0xF811; +const BUNDLE = 'arktsobservedv2andtrace_'; + +export default function IndexTest() { + describe('IndexTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + driver = Driver.create(); + await driver.delayMs(2000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + hilog.info(DOMAIN,TAG,BUNDLE + 'get top ability') + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + /** + * @tc.number arktsobservedv2andtrace_Limitations_001 + * @tc.name LimitationsPageTest + * @tc.desc 测试LimitationsPage是否显示正常 + */ + it('LimitationsPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'Limitations_001,begin'); + let targetElement = await driver.findComponent(ON.text('Limitations', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('name: John age: 8', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'Limitations_001,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_RealizeObservation_002 + * @tc.name RealizeObservationPageTest + * @tc.desc 测试RealizeObservationPage是否显示正常 + */ + it('RealizeObservationPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'RealizeObservation_002,begin'); + let targetElement = await driver.findComponent(ON.text('RealizeObservation', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('name: John age: 8', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'RealizeObservation_002,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_ObserveChanges_003 + * @tc.name ObserveChangesPageTest + * @tc.desc 测试ObserveChangesPage是否显示正常 + */ + it('ObserveChangesPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ObserveChanges_003,begin'); + let targetElement = await driver.findComponent(ON.text('ObserveChanges', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('100', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'ObserveChanges_003,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_InheritedChanges_004 + * @tc.name InheritedChangesPageTest + * @tc.desc 测试InheritedChangesPage是否显示正常 + */ + it('InheritedChangesPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritedChanges_004,begin'); + let targetElement = await driver.findComponent(ON.text('InheritedChanges', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('Tom', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritedChanges_004,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_StaticAttribute_005 + * @tc.name StaticAttributePageTest + * @tc.desc 测试StaticAttributePage是否显示正常 + */ + it('StaticAttributePageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'StaticAttribute_005,begin'); + let targetElement = await driver.findComponent(ON.text('StaticAttribute', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('1', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'StaticAttribute_005,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_UiRefreshCannotTriggered_006 + * @tc.name UiRefreshCannotTriggeredPageTest + * @tc.desc 测试UiRefreshCannotTriggeredPage是否显示正常 + */ + it('UiRefreshCannotTriggeredPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'UiRefreshCannotTriggered_006,begin'); + let targetElement = await driver.findComponent(ON.text('UiRefreshCannotTriggered', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('8', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('0', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'UiRefreshCannotTriggered_006,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_UseMixture_007 + * @tc.name UseMixturePageTest + * @tc.desc 测试UseMixturePage是否显示正常 + */ + it('UseMixturePageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'UseMixture_007,begin'); + let targetElement = await driver.findComponent(ON.text('UseMixture', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('change age', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('Change job', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'UseMixture_007,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_InheritanceMixture_008 + * @tc.name InheritanceMixturePageTest + * @tc.desc 测试InheritanceMixturePage是否显示正常 + */ + it('InheritanceMixturePageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritanceMixture_008,begin'); + let targetElement = await driver.findComponent(ON.text('InheritanceMixture', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('change age', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('Change job', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritanceMixture_008,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_NestedClass_009 + * @tc.name NestedClassPageTest + * @tc.desc 测试NestedClassPage是否显示正常 + */ + it('NestedClassPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'NestedClass_009,begin'); + let targetElement = await driver.findComponent(ON.text('NestedClass', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('change length', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('assign Son', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'NestedClass_009,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_InheritanceClass_010 + * @tc.name InheritanceClassPageTest + * @tc.desc 测试InheritanceClassPage是否显示正常 + */ + it('InheritanceClassPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritanceClass_010,begin'); + let targetElement = await driver.findComponent(ON.text('InheritanceClass', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('change Son age', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('change Cousin age', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'InheritanceClass_010,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_DecorationFoundation_011 + * @tc.name DecorationFoundationPageTest + * @tc.desc 测试DecorationFoundationPage是否显示正常 + */ + it('DecorationFoundationPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationFoundation_011,begin'); + let targetElement = await driver.findComponent(ON.text('DecorationFoundation', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + let targetElement1 = await driver.findComponent(ON.text('push', MatchPattern.CONTAINS)); + expect(targetElement1 === null).assertFalse(); + await targetElement1!.click(); + await driver.delayMs(1000); + let targetElement2 = await driver.findComponent(ON.text('pop', MatchPattern.CONTAINS)); + expect(targetElement2 === null).assertFalse(); + await targetElement2!.click(); + await driver.delayMs(1000); + let targetElement3 = await driver.findComponent(ON.text('shift', MatchPattern.CONTAINS)); + expect(targetElement3 === null).assertFalse(); + await targetElement3!.click(); + await driver.delayMs(1000); + let targetElement4 = await driver.findComponent(ON.text('splice', MatchPattern.CONTAINS)); + expect(targetElement4 === null).assertFalse(); + await targetElement4!.click(); + await driver.delayMs(1000); + let targetElement5 = await driver.findComponent(ON.text('unshift', MatchPattern.CONTAINS)); + expect(targetElement5 === null).assertFalse(); + await targetElement5!.click(); + await driver.delayMs(1000); + let targetElement6 = await driver.findComponent(ON.text('copywithin', MatchPattern.CONTAINS)); + expect(targetElement6 === null).assertFalse(); + await targetElement6!.click(); + await driver.delayMs(1000); + let targetElement7 = await driver.findComponent(ON.text('fill', MatchPattern.CONTAINS)); + expect(targetElement7 === null).assertFalse(); + await targetElement7!.click(); + await driver.delayMs(1000); + let targetElement8 = await driver.findComponent(ON.text('reverse', MatchPattern.CONTAINS)); + expect(targetElement8 === null).assertFalse(); + await targetElement8!.click(); + await driver.delayMs(1000); + let targetElement9 = await driver.findComponent(ON.text('sort', MatchPattern.CONTAINS)); + expect(targetElement9 === null).assertFalse(); + await targetElement9!.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationFoundation_011,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_DecorativeObject_012 + * @tc.name DecorativeObjectPageTest + * @tc.desc 测试DecorativeObjectPage是否显示正常 + */ + it('DecorativeObjectPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorativeObject_012,begin'); + let targetElement = await driver.findComponent(ON.text('DecorativeObject', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorativeObject_012,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_DecorationMap_013 + * @tc.name DecorationMapPageTest + * @tc.desc 测试DecorationMapPage是否显示正常 + */ + it('DecorationMapPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationMap_013,begin'); + let targetElement = await driver.findComponent(ON.text('DecorationMap', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationMap_013,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_DecorationSet_014 + * @tc.name DecorationSetPageTest + * @tc.desc 测试DecorationSetPage是否显示正常 + */ + it('DecorationSetPageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationSet_014,begin'); + let targetElement = await driver.findComponent(ON.text('DecorationSet', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorationSet_014,end'); + }); + + /** + * @tc.number arktsobservedv2andtrace_DecorateDate_015 + * @tc.name DecorateDatePageTest + * @tc.desc 测试DecorateDatePage是否显示正常 + */ + it('DecorateDatePageTest', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorateDate_015,begin'); + let targetElement = await driver.findComponent(ON.text('DecorateDate', MatchPattern.CONTAINS)); + expect(targetElement === null).assertFalse(); + await targetElement!.click(); + await driver.delayMs(2000); + await driver.pressBack(); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'DecorateDate_015,end'); + }); + 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('assertEqual', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test') + }) + }) +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..560cb94e9cfec921cd818985ac22034b2a3fd8cd --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,21 @@ +/* + * 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 IndexTest from './Index.test'; +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); + IndexTest() +} \ No newline at end of file diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/module.json5 b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..59667117c86b64ab9863f7b382c435ae4a3c32fa --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * 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": "entry_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ohosTest.md b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..2e7d5bb70a75641490cd9a3c32443fb8c798ff5c --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/ohosTest/ohosTest.md @@ -0,0 +1,18 @@ +| 测试功能 | 预置条件 | 输入 | 预期输出 | 测试结果 | +|----------------------------------------------------|--------|----------------------------------|-------------------|------| +| 首页加载测试 | 设备正常运行 | 验证基础元素渲染 | 检查列表组件 | Pass | +| 直接观测的局限性 | 设备正常运行 | 点击"LimitationsPage" | 跳转成功包含文本 | Pass | +| V1版本的解决方案是使用@ObjectLink装饰器与自定义组件来实现观测 | 设备正常运行 | 点击"RealizeObservationPage" | 跳转成功且包含文本 | Pass | +| 在嵌套类中使用@Trace装饰的属性具有被观测变化的能力。 | 设备正常运行 | 点击"ObserveChangesPage" | 跳转成功且页面包含文本 | Pass | +| 在继承类中使用@Trace装饰的属性具有被观测变化的能力。 | 设备正常运行 | 点击"InheritedChangesPage" | 跳转成功且页面包含文本 | Pass | +| 类中使用@Trace装饰的静态属性具有被观测变化的能力。 | 设备正常运行 | 点击"StaticAttributePage" | 跳转成功且页面包含文本 | Pass | +| 非@Trace装饰的成员属性用在UI上无法触发UI刷新。 | 设备正常运行 | 点击"UiRefreshCannotTriggeredPage" | 跳转成功且页面包含文本 | Pass | +| 使用@ObservedV2与@Trace装饰的类不能和@State等V1的装饰器混合使用,编译时报错 | 设备正常运行 | 点击"UseMixturePage" | 跳转成功且页面包含Button组件 | Pass | +| 继承自@ObservedV2的类无法和@State等V1的装饰器混用,运行时报错 | 设备正常运行 | 点击"InheritanceMixturePage" | 跳转成功且页面包含Button组件 | Pass | +| 嵌套类场景 | 设备正常运行 | 点击"NestedClassPage" | 跳转成功且页面包含Button组件 | Pass | +| 继承类场景 | 设备正常运行 | 点击"InheritanceClassPage" | 跳转成功且页面包含Button组件 | Pass | +| @Trace装饰基础类型的数组 | 设备正常运行 | 点击"DecorationFoundationPage" | 跳转成功且页面包含Button组件 | Pass | +| @Trace装饰对象数组 | 设备正常运行 | 点击"DecorativeObjectPage" | 跳转成功且页面包含文本 | Pass | +| @Trace装饰Map类型 | 设备正常运行 | 点击"DecorationMapPage" | 跳转成功且页面包含Button组件 | Pass | +| @Trace装饰Set类型 | 设备正常运行 | 点击"DecorationSetPage" | 跳转成功且页面包含Button组件 | Pass | +| @Trace装饰Date类型 | 设备正常运行 | 点击"DecorateDatePage" | 跳转成功且页面包含Button组件 | Pass | diff --git a/ArkUIKit/arktsobservedv2andtrace/entry/src/test/List.test.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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/ArkUIKit/arktsobservedv2andtrace/entry/src/test/LocalUnit.test.ets b/ArkUIKit/arktsobservedv2andtrace/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/entry/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/ArkUIKit/arktsobservedv2andtrace/hvigor/hvigor-config.json5 b/ArkUIKit/arktsobservedv2andtrace/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3b057578a1bb4d591ee53054e39ab0154fc2e43a --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * 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. + */ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "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*/ + } +} diff --git a/ArkUIKit/arktsobservedv2andtrace/hvigorfile.ts b/ArkUIKit/arktsobservedv2andtrace/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae9086af35844176c08f1be3772d081d95d267c6 --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/hvigorfile.ts @@ -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 { 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/ArkUIKit/arktsobservedv2andtrace/oh-package.json5 b/ArkUIKit/arktsobservedv2andtrace/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..837c0ff9f35a6bb9eea849fead7955c19bcdec8d --- /dev/null +++ b/ArkUIKit/arktsobservedv2andtrace/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.24", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkUIKit/arktsobservedv2andtrace/screenshots/img.png b/ArkUIKit/arktsobservedv2andtrace/screenshots/img.png new file mode 100644 index 0000000000000000000000000000000000000000..512e7691c6e0f00f5d6d79efe8af696b0e58bf2a Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/screenshots/img.png differ diff --git a/ArkUIKit/arktsobservedv2andtrace/screenshots/img_1.png b/ArkUIKit/arktsobservedv2andtrace/screenshots/img_1.png new file mode 100644 index 0000000000000000000000000000000000000000..a8a923ee54e18edf4d806e1968f2ec8708dcefbc Binary files /dev/null and b/ArkUIKit/arktsobservedv2andtrace/screenshots/img_1.png differ