diff --git a/ArkUIKit/VideoPlayer/AppScope/app.json5 b/ArkUIKit/VideoPlayer/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9c880ec351db4c1eb9653a8a22f3fba4c7305398 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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.samples.videoplayer", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/VideoPlayer/AppScope/resources/base/element/string.json b/ArkUIKit/VideoPlayer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c9714762a18d22e9926c25f32a89a5683f78cf2f --- /dev/null +++ b/ArkUIKit/VideoPlayer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Video" + } + ] +} diff --git a/ArkUIKit/VideoPlayer/AppScope/resources/base/media/background.png b/ArkUIKit/VideoPlayer/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/VideoPlayer/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/VideoPlayer/AppScope/resources/base/media/foreground.png b/ArkUIKit/VideoPlayer/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/ArkUIKit/VideoPlayer/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/VideoPlayer/AppScope/resources/base/media/layered_image.json b/ArkUIKit/VideoPlayer/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/README_zh.md b/ArkUIKit/VideoPlayer/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..d2125e2508ee321fecc55f5d807022beb8ac1301 --- /dev/null +++ b/ArkUIKit/VideoPlayer/README_zh.md @@ -0,0 +1,85 @@ +# ArkUI视频播放指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitcode.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [视频播放](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-common-components-video-player.md)。 + + +### 效果预览 +| 视频播放效果图 | +| ------------------------------------ | +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应页面,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +├── entryability +│   └── EntryAbility.ets +├── entrybackupability +│   └── EntryBackupAbility.ets +└── pages + ├── AttributeVideo.ets // 添加属性 + ├── CustomizedControl.ets // 自定义控制器 + ├── DataAbility.ets // 加载本地视频 + ├── EventCall.ets // 事件调用 + ├── Index.ets + ├── LocalVideo.ets // 加载本地视频 + ├── OnlineVideo.ets // 加载网络视频 + ├── Sandbox.ets // 加载沙箱路径视频 + └── VideoControl.ets // Video控制器使用 +entry/src/ohosTest/ +├── ets +│ └── test +│ ├── Ability.test.ets +│ ├── Index.test.ets // 测试用例代码 +│ └── List.test.ets +└── module.json5 +``` + +### 具体实现 + +1. Video组件支持加载本地视频和网络视频。使用资源访问符$rawfile()引用视频资源。支持file://路径前缀的字符串,用于读取应用沙箱路径内的资源,需要确保应用沙箱目录路径下的文件存在并且有可读权限。 + +2. Video组件回调事件主要包括播放开始、播放暂停、播放结束、播放失败、播放停止、视频准备和操作进度条等事件,除此之外,Video组件也支持通用事件的调用,如点击、触摸等事件的调用。 + +3. Video控制器主要用于控制视频的状态,包括播放、暂停、停止以及设置进度等 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.33,镜像版本号:OpenHarmony_6.0.0.33。 + +3.本示例需要使用DevEco Studio 6.0.0 Release (Build Version: 6.0.0.858, built on September 24, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUISample/VideoPlayer > .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/VideoPlayer/build-profile.json5 b/ArkUIKit/VideoPlayer/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e9fedd39eb045a9f445aa41df11e1c7c20714e8e --- /dev/null +++ b/ArkUIKit/VideoPlayer/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": { + "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/VideoPlayer/code-linter.json5 b/ArkUIKit/VideoPlayer/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed05653cca31b61d64cf6471529eaf50d4f70709 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/build-profile.json5 b/ArkUIKit/VideoPlayer/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6bf0d132e6f78049e712446c63f2633b2d1613d3 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/hvigorfile.ts b/ArkUIKit/VideoPlayer/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/obfuscation-rules.txt b/ArkUIKit/VideoPlayer/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/oh-package.json5 b/ArkUIKit/VideoPlayer/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/common/videoIcon.png b/ArkUIKit/VideoPlayer/entry/src/common/videoIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/common/videoIcon.png differ diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..62f53acbc95e5be7985f8fb1fe2db591cea260bd --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/ets/pages/AttributeVideo.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/AttributeVideo.ets new file mode 100644 index 0000000000000000000000000000000000000000..6008cb71c413f23add9f53c0295845b89183df60 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/AttributeVideo.ets @@ -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. + */ + +// [Start attribute_video] +// xxx.ets +// [StartExclude attribute_video] +@Entry +// [EndExclude attribute_video] +@Component +export struct attributeVideo { + private controller: VideoController = new VideoController(); + + build() { + Column() { + Video({ + controller: this.controller + }) + .muted(false) // 设置是否静音 + .controls(false) // 设置是否显示默认控制条 + .autoPlay(false) // 设置是否自动播放 + .loop(false) // 设置是否循环播放 + .objectFit(ImageFit.Contain) // 设置视频填充模式 + } + } +} +// [End attribute_video] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/CustomizedControl.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/CustomizedControl.ets new file mode 100644 index 0000000000000000000000000000000000000000..566d8c830330264785a40e91c9a95d14bf859d7b --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/CustomizedControl.ets @@ -0,0 +1,72 @@ +/* + * 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 customize_control] +// xxx.ets +@Entry +@Component +struct customizedControl { + @State videoSrc: Resource = $rawfile('videoTest.mp4'); + @State previewUri: string = 'common/videoIcon.png'; + @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X; + // 初始化当前时间为0 + @State currentTime: number = 0; + // 初始化持续时间为0 + @State durationTime: number = 0; + controller: VideoController = new VideoController(); + + build() { + Row() { + Column() { + Video({ + src: this.videoSrc, + previewUri: this.previewUri, + currentProgressRate: this.curRate, + controller: this.controller + }) + .controls(false) + .autoPlay(true) + .onPrepared((event) => { + if (event) { + this.durationTime = event.duration + } + }) + .onUpdate((event) => { + if (event) { + this.currentTime = event.time + } + }) + Row() { + Text(JSON.stringify(this.currentTime) + 's') + Slider({ + value: this.currentTime, + min: 0, + max: this.durationTime + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.controller.setCurrentTime(value); // 设置视频播放的进度跳转到value处 + }) + .width('90%') + Text(JSON.stringify(this.durationTime) + 's') + } + .opacity(0.8) + .width('100%') + } + .width('100%') + } + .height('40%') + } +} +// [End customize_control] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/DataAbility.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/DataAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7eb65aea8b02e536c933503b8d1fa8605b360c2 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/DataAbility.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 data_ability] +// xxx.ets +// [StartExclude data_ability] +@Entry +// [EndExclude data_ability] +@Component +export struct dataAbility { + private controller: VideoController = new VideoController(); + private previewUris: Resource = $r('app.media.preview'); + private videoSrc: string = 'dataability://device_id/com.domainname.dataability.videodata/video/10'; + + build() { + Column() { + Video({ + src: this.videoSrc, + previewUri: this.previewUris, + controller: this.controller + }) + } + } +} +// [End data_ability] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/EventCall.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/EventCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6a68b9ae6cd90641b394dfc9b1b73fb70781b60 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/EventCall.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 event_call] +// xxx.ets +@Entry +@Component +struct eventCall { + private controller: VideoController = new VideoController(); + private previewUris: Resource = $r('app.media.preview'); + private innerResource: Resource = $rawfile('videoTest.mp4'); + + build() { + Column() { + Video({ + src: this.innerResource, + previewUri: this.previewUris, + controller: this.controller + }) + .onUpdate((event) => { // 更新事件回调 + }) + .onPrepared((event) => { // 准备事件回调 + }) + .onError(() => { // 失败事件回调 + }) + .onStop(() => { // 停止事件回调 + }) + } + } +} +// [End event_call] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Index.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..57f3a6e955bb61fa8f788f6ffde914c942e30af6 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +interface Ary { + path:string, + name:string +} +@Entry +@Component +struct Index { + ary:Ary[]=[ + { + name:'AttributeVideo', + path:'pages/AttributeVideo' + }, + { + name:'CustomizedControl', + path:'pages/CustomizedControl' + }, + { + name:'DataAbility', + path:'pages/DataAbility' + }, + { + name:'EventCall', + path:'pages/EventCall' + }, + { + name:'LocalVideo', + path:'pages/LocalVideo' + }, + { + name:'OnlineVideo', + path:'pages/OnlineVideo' + }, + { + name:'Sandbox', + path:'pages/Sandbox' + }, + { + name:'VideoControl', + path:'pages/VideoControl' + }, + ] + build() { + Scroll() { + Column({ space: 10 }) { + ForEach(this.ary,(item:Ary)=>{ + Button(item.name) + .onClick(() => this.getUIContext().getRouter().pushUrl({ url: item.path })) + },(item:Ary)=>item.name) + } + .width('100%') + } + } +} diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/LocalVideo.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/LocalVideo.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6e19caecb03e85c304d93d12d010c437ed3af58 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/LocalVideo.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 local_video] +// xxx.ets +// [StartExclude local_video] +@Entry +// [EndExclude local_video] +@Component +export struct localVideo { + private controller: VideoController = new VideoController(); + private previewUris: Resource = $r('app.media.preview'); + private innerResource: Resource = $rawfile('videoTest.mp4'); + + build() { + Column() { + Video({ + src: this.innerResource, // 设置视频源 + previewUri: this.previewUris, // 设置预览图 + controller: this.controller //设置视频控制器,可以控制视频的播放状态 + }) + } + } +} +// [End local_video] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/OnlineVideo.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/OnlineVideo.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5b51e4b0a42fa6399bb77ff10e99288f93168e6 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/OnlineVideo.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 online_video] +// xxx.ets +// [StartExclude online_video] +@Entry +// [EndExclude online_video] +@Component +export struct onlineVideo { + private controller: VideoController = new VideoController(); + private previewUris: Resource = $r('app.media.preview'); + private videoSrc: string = 'xxx.mp4'; // 使用时请替换为实际视频加载网址 + + build() { + Column() { + Video({ + src: this.videoSrc, + previewUri: this.previewUris, + controller: this.controller + }) + } + } +} +// [End online_video] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Sandbox.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Sandbox.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ce5e3d61ceb1c08a6c508f3de47e51693b5ab12 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/Sandbox.ets @@ -0,0 +1,35 @@ +/* + * 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 sandbox] +// xxx.ets +// [StartExclude sandbox] +@Entry +// [EndExclude sandbox] +@Component +export struct sandbox { + private controller: VideoController = new VideoController(); + private videoSrc: string = 'file:///data/storage/el2/base/haps/entry/files/show.mp4'; + + build() { + Column() { + Video({ + src: this.videoSrc, + controller: this.controller + }) + } + } +} +// [End sandbox] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/VideoControl.ets b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/VideoControl.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c3ee90401a34dca38966a0bc51fcf76ed5f206d --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/ets/pages/VideoControl.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 video_guide] +// xxx.ets +@Entry +@Component +struct VideoGuide { + @State videoSrc: Resource = $rawfile('videoTest.mp4'); + @State previewUri: string = 'common/videoIcon.png'; + @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X; + + build() { + Row() { + Column() { + Video({ + src: this.videoSrc, + previewUri: this.previewUri, + currentProgressRate: this.curRate // 设置视频播放倍速 + }) + } + .width('100%') + } + .height('100%') + } +} +// [End video_guide] \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/module.json5 b/ArkUIKit/VideoPlayer/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cb355a9800296830aef540ce9a3f53769d502465 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/resources/base/element/color.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/resources/base/element/float.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/element/string.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c6ea8c83043a22dcb59bb86143bcddd7b3fd9761 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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": "videoplayer" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/background.png b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/resources/base/media/preview.png b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..852e089318b38d22b48baf87d51bf4d7e1a29cc7 Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/preview.png differ diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..4ce60ed47de9d4e185718e32abd24cc5ece5d2d1 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,13 @@ +{ + "src": [ + "pages/AttributeVideo", + "pages/CustomizedControl", + "pages/DataAbility", + "pages/EventCall", + "pages/Index", + "pages/LocalVideo", + "pages/OnlineVideo", + "pages/Sandbox", + "pages/VideoControl" + ] +} diff --git a/ArkUIKit/VideoPlayer/entry/src/main/resources/dark/element/color.json b/ArkUIKit/VideoPlayer/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/main/resources/rawfile/videoTest.mp4 b/ArkUIKit/VideoPlayer/entry/src/main/resources/rawfile/videoTest.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d00202110d4d7991e1142b5d7965c32c7538df94 Binary files /dev/null and b/ArkUIKit/VideoPlayer/entry/src/main/resources/rawfile/videoTest.mp4 differ diff --git a/ArkUIKit/VideoPlayer/entry/src/mock/mock-config.json5 b/ArkUIKit/VideoPlayer/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/ohosTest/ets/test/Index.test.ets b/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/Index.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d8826e97c0062288b0baacfffa432ff7b10147e --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/Index.test.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. + */ + +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +// 导入测试依赖kit +import { abilityDelegatorRegistry, Driver, ON, MatchPattern } from '@kit.TestKit'; +import hilog from '@ohos.hilog'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const TAG = '[Sample_VideoPlayer]'; +const DOMAIN = 0xF811; +const BUNDLE = 'VideoPlayer_'; +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +let want: Want; + +export default function IndexTest() { + describe('IndexTest', () => { + beforeAll(async () => { + want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + let driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + }) + + /** + * @tc.number VideoPlayerTest_001 + * @tc.name testVideoPlayer + * @tc.desc 测试视频播放是否显示正常 + */ + it('VideoPlayerTest_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'VideoPlayerTest_001 begin'); + let driver = Driver.create(); + let button = await driver.findComponent(ON.text('AttributeVideo', MatchPattern.CONTAINS)); + await button.click(); + await driver.pressBack(); + let button1 = await driver.findComponent(ON.text('CustomizedControl', MatchPattern.CONTAINS)); + await button1.click(); + await driver.pressBack(); + let button2 = await driver.findComponent(ON.text('DataAbility', MatchPattern.CONTAINS)); + await button2.click(); + await driver.pressBack(); + let button3 = await driver.findComponent(ON.text('EventCall', MatchPattern.CONTAINS)); + await button3.click(); + await driver.pressBack(); + let button4 = await driver.findComponent(ON.text('LocalVideo', MatchPattern.CONTAINS)); + await button4.click(); + await driver.pressBack(); + let button5 = await driver.findComponent(ON.text('OnlineVideo', MatchPattern.CONTAINS)); + await button5.click(); + await driver.pressBack(); + let button6 = await driver.findComponent(ON.text('Sandbox', MatchPattern.CONTAINS)); + await button6.click(); + await driver.pressBack(); + let button7 = await driver.findComponent(ON.text('VideoControl', MatchPattern.CONTAINS)); + await button7.click(); + hilog.info(DOMAIN, TAG, BUNDLE + 'VideoPlayerTest_001 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1951e50c73703b8b1fe39390c5287b68a1bf394 --- /dev/null +++ b/ArkUIKit/VideoPlayer/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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'; +import IndexTest from './Index.test'; + +export default function testsuite() { + abilityTest(); + IndexTest(); +} \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/entry/src/ohosTest/module.json5 b/ArkUIKit/VideoPlayer/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..84d30586d591412f4252801cc483bbc6d8554104 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/test/List.test.ets b/ArkUIKit/VideoPlayer/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/entry/src/test/LocalUnit.test.ets b/ArkUIKit/VideoPlayer/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/hvigor/hvigor-config.json5 b/ArkUIKit/VideoPlayer/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b8fea3f097bd68b0bc4d87de986d2cb7732c1d9b --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/hvigorfile.ts b/ArkUIKit/VideoPlayer/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3340f07e45ddc5dcadbb87012668555def2e6e0 --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/local.properties b/ArkUIKit/VideoPlayer/local.properties new file mode 100644 index 0000000000000000000000000000000000000000..3a0275d64a9dfd155a6fad9fd4874bcde2c1cff8 --- /dev/null +++ b/ArkUIKit/VideoPlayer/local.properties @@ -0,0 +1,8 @@ +# This file is automatically generated by DevEco Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file should *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# For customization when using a Version Control System, please read the header note. +sdk.dir=C:/Users/lenovo/AppData/Local/OpenHarmony/Sdk \ No newline at end of file diff --git a/ArkUIKit/VideoPlayer/oh-package.json5 b/ArkUIKit/VideoPlayer/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..69cb43cba3addcee1840403c67405134a2a9102c --- /dev/null +++ b/ArkUIKit/VideoPlayer/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/VideoPlayer/ohosTest.md b/ArkUIKit/VideoPlayer/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..15c4d326f0cd9dcccd988de9d0940e1372337f91 --- /dev/null +++ b/ArkUIKit/VideoPlayer/ohosTest.md @@ -0,0 +1,7 @@ +# VideoPlayer 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- |---------------------------------------|----------| :------- | -------- | +| VideoPlayer示例代码验证 | 设备正常运行 | 进入首页,查看视频播放情况 | 视频播放成功 | 是 | Pass | diff --git a/ArkUIKit/VideoPlayer/screenshots/device/image1.png b/ArkUIKit/VideoPlayer/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..0069508c881d55d93eb0be2a83ac77d4515c3a3b Binary files /dev/null and b/ArkUIKit/VideoPlayer/screenshots/device/image1.png differ diff --git a/ArkUIKit/VisionEffect/.gitignore b/ArkUIKit/VisionEffect/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkUIKit/VisionEffect/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/AppScope/app.json5 b/ArkUIKit/VisionEffect/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9924f317ee3a649bf56499f4ce8e35719ecab181 --- /dev/null +++ b/ArkUIKit/VisionEffect/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.visionEffect", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/VisionEffect/AppScope/resources/base/element/string.json b/ArkUIKit/VisionEffect/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..42c7546de5d951e8d23adbe2f47bd87ff07d7adf --- /dev/null +++ b/ArkUIKit/VisionEffect/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "VisionEffect" + } + ] +} diff --git a/ArkUIKit/VisionEffect/AppScope/resources/base/media/background.png b/ArkUIKit/VisionEffect/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/VisionEffect/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/VisionEffect/AppScope/resources/base/media/foreground.png b/ArkUIKit/VisionEffect/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/VisionEffect/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/VisionEffect/AppScope/resources/base/media/layered_image.json b/ArkUIKit/VisionEffect/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/README_zh.md b/ArkUIKit/VisionEffect/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6430883789b0ff341dbaba95e6dc417acac7592c --- /dev/null +++ b/ArkUIKit/VisionEffect/README_zh.md @@ -0,0 +1,185 @@ +# ArkUI使用视效组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [图形变换](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-transformation.md)。 +2. [透明度设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-opacity.md)。 +3. [形状裁剪](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-sharp-clipping.md)。 +4. [图像效果](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-image-effect.md) +5. [背景设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-background.md) +6. [组件内容模糊](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-blur-style.md) +7. [前景色设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-color.md) +8. [点击回弹效果](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-click-effect.md) +9. [特效绘制合并](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-use-effect.md) +10. [组件内容填充方式](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-renderfit.md) +11. [外描边设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-outline.md) +12. [运动模糊](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-motionBlur.md) +13. [颜色渐变](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-gradient-color.md) +14. [前景属性设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-effect.md) +15. [视效设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-filter-effect.md) + + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---background // 背景设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| |---clickEffect // 点击回弹效果 +| | |---template1 +| | | |---Index.ets +| |---clip // 形状裁剪 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---foregroundBlurStyle // 组件内容模糊 +| | |---template1 +| | | |---Index.ets +| |---foregroundColor // 前景色设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---foregroundEffect // 前景属性设置 +| | |---template1 +| | | |---Index.ets +| |---imageEffect // 图像效果 +| | |---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 +| |---linearGradient // 颜色渐变 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---motionBlur // 运动模糊 +| | |---template1 +| | | |---Index.ets +| |---opacity // 透明度设置 +| | |---template1 +| | | |---Index.ets +| |---outline // 外描边设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---renderFit // 组件内容填充方式 +| | |---template1 +| | | |---Index.ets +| |---transform // 图形变换 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---useEffect // 特效绘制合并 +| | |---template1 +| | | |---Index.ets +| |---visualEffect // 视效设置 +| | |---template1 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---Background.test.ets // 背景设置示例代码测试代码 +| | |---ClickEffect.test.ets // 点击回弹效果示例代码测试代码 +| | |---Clip.test.ets // 形状裁剪示例代码测试代码 +| | |---ForegroundBlurStyle.test.ets // 组件内容模糊示例代码测试代码 +| | |---ForegroundColor.test.ets // 前景色设置示例代码测试代码 +| | |---ForegroundEffect.test.ets // 前景属性设置示例代码测试代码 +| | |---ImageEffect.test.ets // 图像效果示例代码测试代码 +| | |---LinearGradient.test.ets // 颜色渐变示例代码测试代码 +| | |---MotionBlur.test.ets // 运动模糊示例代码测试代码 +| | |---Opacity.test.ets // 透明度设置示例代码测试代码 +| | |---OutLine.test.ets // 外描边设置示例代码测试代码 +| | |---RenderFit.test.ets // 组件内容填充方式示例代码测试代码 +| | |---Transform.test.ets // 图形变换示例代码测试代码 +| | |---UseEffect.test.ets // 特效绘制合并示例代码测试代码 +| | |---VisualEffect.test.ets // 视效设置示例代码测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API18版本SDK,版本号:5.1.0.56,镜像版本号:OpenHarmony_5.1.0.56。 + +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/VisionEffect > .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/VisionEffect/build-profile.json5 b/ArkUIKit/VisionEffect/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3ca5a93fb814017ac4c398aacbdf17b1d8b0a237 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/code-linter.json5 b/ArkUIKit/VisionEffect/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/.gitignore b/ArkUIKit/VisionEffect/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/build-profile.json5 b/ArkUIKit/VisionEffect/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/hvigorfile.ts b/ArkUIKit/VisionEffect/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/obfuscation-rules.txt b/ArkUIKit/VisionEffect/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/oh-package.json5 b/ArkUIKit/VisionEffect/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/ets/pages/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0009564a340d13c6dbd9c8e4a895302929769b70 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,258 @@ +/* + * 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 VisionEffectIndex { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: "transform", + label: $r('app.string.transform'), + children: [ + { name: 'template1/Index', label: $r('app.string.example_one_transform') }, + { name: 'template2/Index', label: $r('app.string.example_two_transform') }, + { name: 'template3/Index', label: $r('app.string.example_three_transform') }, + ] + },{ + name: "opacity", + label: $r('app.string.opacity'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_opacity') }, + ] + }, { + name: "clip", + label: $r('app.string.clip'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_clip') }, + { name: 'template2/Index', label: $r('app.string.example_two_clip') }, + ] + }, { + name: "imageEffect", + label: $r('app.string.imageEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_imageEffect') }, + { name: 'template2/Index', label: $r('app.string.example_two_imageEffect') }, + { name: 'template3/Index', label: $r('app.string.example_three_imageEffect') }, + { name: 'template4/Index', label: $r('app.string.example_four_imageEffect') }, + { name: 'template5/Index', label: $r('app.string.example_five_imageEffect') }, + { name: 'template6/Index', label: $r('app.string.example_six_imageEffect') }, + { name: 'template7/Index', label: $r('app.string.example_seven_imageEffect') }, + { name: 'template8/Index', label: $r('app.string.example_eight_imageEffect') }, + { name: 'template9/Index', label: $r('app.string.example_nine_imageEffect') }, + { name: 'template10/Index', label: $r('app.string.example_ten_imageEffect') }, + ] + }, { + name: "background", + label: $r('app.string.background'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_background') }, + { name: 'template2/Index', label: $r('app.string.example_two_background') }, + { name: 'template3/Index', label: $r('app.string.example_three_background') }, + { name: 'template4/Index', label: $r('app.string.example_four_background') }, + { name: 'template5/Index', label: $r('app.string.example_five_background') }, + { name: 'template6/Index', label: $r('app.string.example_six_background') }, + { name: 'template7/Index', label: $r('app.string.example_seven_background') }, + ] + }, { + name: "foregroundBlurStyle", + label: $r('app.string.foregroundBlurStyle'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundBlurStyle') }, + ] + }, { + name: "foregroundColor", + label: $r('app.string.foregroundColor'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundColor') }, + { name: 'template2/Index', label: $r('app.string.example_two_foregroundColor') }, + { name: 'template3/Index', label: $r('app.string.example_three_foregroundColor') }, + ] + }, { + name: "clickEffect", + label: $r('app.string.clickEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_clickEffect') }, + ] + }, { + name: "useEffect", + label: $r('app.string.useEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_useEffect') }, + ] + }, { + name: "renderFit", + label: $r('app.string.renderFit'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_renderFit') }, + ] + }, { + name: "outline", + label: $r('app.string.outline'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_outline') }, + { name: 'template2/Index', label: $r('app.string.example_two_outline') }, + ] + }, { + name: "motionBlur", + label: $r('app.string.motionBlur'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_motionBlur') }, + ] + }, { + name: "linearGradient", + label: $r('app.string.linearGradient'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_linearGradient') }, + { name: 'template2/Index', label: $r('app.string.example_two_linearGradient') }, + { name: 'template3/Index', label: $r('app.string.example_three_linearGradient') }, + ] + }, { + name: "foregroundEffect", + label: $r('app.string.foregroundEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundEffect') }, + ] + }, { + name: "visualEffect", + label: $r('app.string.visualEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_visualEffect') }, + ] + } + ]; + @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("VisionEffectIndex") + 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/VisionEffect/entry/src/main/ets/pages/background/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4734a1586138c3f51a292c5edb306c6d06b9e362 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template1/Index.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. + */ +@Entry +@Component +struct BackgroundExample { + + build() { + Column({ space: 5 }) { + Text('background color').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row().width('90%').height(50).backgroundColor(0xE5E5E5).border({ width: 1 }) + + Text('background image repeat along X').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .backgroundImage($r('app.media.bg'), ImageRepeat.X) + .backgroundImageSize({ width: '250px', height: '140px' }) + .width('90%') + .height(70) + .border({ width: 1 }) + + Text('background image repeat along Y').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .backgroundImage($r('app.media.bg'), ImageRepeat.Y) + .backgroundImageSize({ width: '500px', height: '120px' }) + .width('90%') + .height(100) + .border({ width: 1 }) + + Text('background image size').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%').height(150) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: 1000, height: 500 }) + .border({ width: 1 }) + + Text('background fill the box(Cover)').fontSize(9).width('90%').fontColor(0xCCCCCC) + // 不保证图片完整的情况下占满盒子 + Row() + .width(200) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize(ImageSize.Cover) + .border({ width: 1 }) + + Text('background fill the box(Contain)').fontSize(9).width('90%').fontColor(0xCCCCCC) + // 保证图片完整的情况下放到最大 + Row() + .width(200) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize(ImageSize.Contain) + .border({ width: 1 }) + + Text('background image position').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: 1000, height: 560 }) + .backgroundImagePosition({ x: -500, y: -300 }) + .border({ width: 1 }) + } + .width('100%').height('100%').padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c408a685db10436863c46c24bc36122b42f7d87c --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets @@ -0,0 +1,33 @@ +/* + * 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 BackgroundBlurStyleDemo { + build() { + Column() { + Row() { + Text("Thin Material") + } + .width('50%') + .height('50%') + .backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 }) + .position({ x: '15%', y: '30%' }) + } + .height('100%') + .width('100%') + .backgroundImage($r('app.media.bg')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9528455392b22b511873da717b38a94e342c03b --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets @@ -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. + */ +@Entry +@Component +struct BackgroundExample3 { + @Builder renderBackground() { + Column() { + Progress({value : 50}) + } + } + + build() { + Column() { + Text("content") + .width(100) + .height(40) + .fontColor("#FFF") + .position({x:50, y:80}) + .textAlign(TextAlign.Center) + .backgroundColor(Color.Green) + } + .width(200).height(200) + .background(this.renderBackground) + .backgroundColor(Color.Gray) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template4/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0468499b4d3ef24b8124146406dc017b94e4597c --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template4/Index.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. + */ +@Entry +@Component +struct BackgroundBrightnessDemo { + build() { + Column() { + Row() { + Text("BackgroundBrightness") + } + .width(200) + .height(100) + .position({ x: 100, y: 100 }) + .backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT}) + .backgroundBrightness({rate:0.5,lightUpDegree:0.5}) // 背景提亮效果 + } + .width('100%') + .height('100%') + .backgroundImage($r('app.media.image')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac5c34baee8d84777b82e93e1569c7a005dd283d --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets @@ -0,0 +1,45 @@ +/* + * 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 BlurEffectsExample { + build() { + Column({ space: 10 }) { + // 对字体进行模糊 + Text('font blur').fontSize(15).fontColor(0xCCCCCC).width('90%') + Flex({ alignItems: ItemAlign.Center }) { + Text('original text').margin(10) + Text('blur text') + .blur(5).margin(10) + Text('blur text') + .blur(10, undefined).margin(10) // 内容模糊半径为5,禁用系统自适应优化策略。 + Text('blur text') + .blur(15).margin(10) + }.width('90%').height(40) + .backgroundColor(0xF9CF93) + + + // 对背景进行模糊 + Text('backdropBlur').fontSize(15).fontColor(0xCCCCCC).width('90%') + Text() + .width('90%') + .height(40) + .fontSize(16) + .backdropBlur(3) + .backgroundImage($r('app.media.image')) + .backgroundImageSize({ width: 1200, height: 160 }) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template6/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed5b3300890fa1ca9458d3539489c2f0ea7d461a --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template6/Index.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. + */ +@Entry +@Component +struct BackGround6 { + @State shColor: Color = Color.White; + @State sizeDate: number = 20; + @State rVal: number = 255; + @State gVal: number = 255; + @State bVal: number = 255; + @State aVal: number = 0.1; + @State rad: number = 40; + @State satVal: number = 0.8; + @State briVal: number = 1.5; + build() { + Stack() { + Image($r('app.media.image')) + Column() { + Column({ space: 0 }) { + Column() { + Text('11') + .fontSize(144) + .fontWeight(FontWeight.Bold) + .fontColor('rgba(255,255,255,1)') + .fontFamily('HarmonyOS-Sans-Digit') + .maxLines(1) + .lineHeight(120 * 1.25) + .height(120 * 1.25) + .letterSpacing(4 * 1.25) + Text('42') + .fontSize(144) + .fontWeight(FontWeight.Bold) + .fontColor('rgba(255,255,255,1)') + .fontFamily('HarmonyOS-Sans-Digit') + .maxLines(1) + .lineHeight(120 * 1.25) + .height(120 * 1.25) + .letterSpacing(4 * 1.25) + .shadow({ + color: 'rgba(0,0,0,0)', + radius: 20, + offsetX: 0, + offsetY: 0 + }) + Row() { + Text($r('app.string.October_16th')) + .fontSize(this.sizeDate) + .height(22) + .fontWeight('medium') + .fontColor('rgba(255,255,255,1)') + Text($r('app.string.Monday')) + .fontSize(this.sizeDate) + .height(22) + .fontWeight('medium') + .fontColor('rgba(255,255,255,1)') + } + } + .blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN) + .pixelRound({ + start: PixelRoundCalcPolicy.FORCE_FLOOR , + top: PixelRoundCalcPolicy.FORCE_FLOOR , + end: PixelRoundCalcPolicy.FORCE_CEIL, + bottom: PixelRoundCalcPolicy.FORCE_CEIL + }) + } + .blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN) + .backgroundEffect({ + radius: this.rad, + saturation: this.satVal, + brightness: this.briVal, + color: this.getVolumeDialogWindowColor() + }) + .justifyContent(FlexAlign.Center) + .pixelRound({ + start: PixelRoundCalcPolicy.FORCE_FLOOR , + top: PixelRoundCalcPolicy.FORCE_FLOOR , + end: PixelRoundCalcPolicy.FORCE_CEIL, + bottom: PixelRoundCalcPolicy.FORCE_CEIL + }) + } + } + } + getVolumeDialogWindowColor(): ResourceColor | string { + return `rgba(${this.rVal.toFixed(0)}, ${this.gVal.toFixed(0)}, ${this.bVal.toFixed(0)}, ${this.aVal.toFixed(0)})`; + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template7/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e62f9cfaaf8b9f52cd128c350cd93ab9e9571b10 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/background/template7/Index.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. + */ +@Entry +@Component +struct BackGroundBlur { + private imageSize: number = 150; + + build() { + Column({ space: 5 }) { + // backgroundBlurStyle通过枚举值的方式设置模糊参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backgroundBlurStyle(BlurStyle.Thin) + } + + // backgroundEffect 可以自定义设置 模糊半径,亮度,饱和度等参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backgroundEffect({ radius: 20, brightness: 0.6, saturation: 15 }) + } + + // backdropBlur 只能设置模糊半径和灰阶参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backdropBlur(20, { grayscale: [30, 50] }) + } + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e65dd2d3b498ed34bbef705bfd406204694085bf --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets @@ -0,0 +1,80 @@ +/* + * 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 ToggleExample { + build() { + Column({ space: 10 }) { + Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Switch, isOn: false }) + .clickEffect({level:ClickEffectLevel.LIGHT}) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Switch, isOn: true }) + .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5}) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + + Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Checkbox, isOn: false }) + .clickEffect({level:ClickEffectLevel.MIDDLE}) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Checkbox, isOn: true }) + .clickEffect({level:ClickEffectLevel.MIDDLE, scale: 0.5}) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + + Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Button, isOn: false }) { + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .clickEffect({level:ClickEffectLevel.HEAVY}) + .selectedColor('rgba(0,125,255,0.20)') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Button, isOn: true }) { + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .clickEffect({level:ClickEffectLevel.HEAVY, scale: 0.5}) + .selectedColor('rgba(0,125,255,0.20)') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + }.width('100%').padding(24) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a1d54c4ca931ec1f2833f10ea18d6b49e96e2ba --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.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 { CircleShape, RectShape } from '@kit.ArkUI'; + +@Entry +@Component +struct ClipAndMaskExample { + build() { + Column({ space: 15 }) { + Text('clip').fontSize(12).width('75%').fontColor('#DCDCDC') + Row() { + Image($r('app.media.testImg')).width('500px').height('280px') + } + .clip(true) // 如这里不设置clip为true,则Row组件的圆角不会限制其中的Image组件,Image组件的四个角会超出Row + .borderRadius(20) + + // 用一个280px直径的圆对图片进行裁剪 + Image($r('app.media.testImg')) + .clipShape(new CircleShape({ width: '280px', height: '280px' })) + .width('500px').height('280px') + + Text('mask').fontSize(12).width('75%').fontColor('#DCDCDC') + // 给图片添加了一个500px*280px的方形遮罩 + Image($r('app.media.testImg')) + .maskShape(new RectShape({ width: '500px', height: '280px' }).fill(Color.Gray)) + .width('500px').height('280px') + + // 给图片添加了一个280px*280px的圆形遮罩 + Image($r('app.media.testImg')) + .maskShape(new CircleShape({ width: '280px', height: '280px' }).fill(Color.Gray)) + .width('500px').height('280px') + } + .width('100%') + .margin({ top: 15 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cfc4e66efb34bd8355664c3af839cfe3bf6d4f7e --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets @@ -0,0 +1,74 @@ +/* + * 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 ProgressMaskExample { + @State progressFlag1: boolean = true; + @State color: Color = 0x01006CDE; + @State value: number = 10.0; + @State enableBreathingAnimation: boolean = false; + @State progress: ProgressMask = new ProgressMask(10.0, 100.0, Color.Gray); + + build() { + Column({ space: 15 }) { + Text('progress mask').fontSize(12).width('75%').fontColor('#DCDCDC') + // 给图片添加了一个280px*280px的进度遮罩 + Image($r('app.media.testImg')) + .width('500px').height('280px') + .mask(this.progress) + .animation({ + duration: 2000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 0, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal // 动画模式 + }) // 对Button组件的宽高属性进行动画配置 + + // 更新进度遮罩的进度值 + Button('updateProgress') + .onClick((event?: ClickEvent) => { + this.value += 10; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + + // 更新进度遮罩的颜色 + Button('updateColor') + .onClick((event?: ClickEvent) => { + if (this.progressFlag1) { + this.progress.updateColor(0x9fff0000); + } else { + this.progress.updateColor(0x9f0000ff); + } + this.progressFlag1 = !this.progressFlag1 + }).width(200).height(50).margin(20) + + // 开关呼吸光晕动画 + Button('enableBreathingAnimation:' + this.enableBreathingAnimation) + .onClick((event?: ClickEvent) => { + this.enableBreathingAnimation = !this.enableBreathingAnimation; + this.progress.enableBreathingAnimation(this.enableBreathingAnimation); + }).width(200).height(50).margin(20) + + // 恢复进度遮罩 + Button('click reset!') + .onClick((event?: ClickEvent) => { + this.value = 0; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + } + .width('100%') + .margin({ top: 15 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/common/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..02c5c6b987280c6731d3e40af7c56c416176a3af --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..df17604a668859bed453c09ceca3488b2cf01a33 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.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. + */ +@Entry +@Component +struct ForegroundBlurStyleDemo { + build() { + Column() { + Text('Thin Material').fontSize(30).fontColor(0xCCCCCC) + Image($r('app.media.bg')) + .width(300) + .height(350) + .foregroundBlurStyle(BlurStyle.Thin, + { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..df1a63222cb31fcbefe89ae607ade7f80180086b --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets @@ -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. + */ +@Entry +@Component +struct ForegroundColorExample { + build() { + Column({ space: 100 }) { + // 绘制一个直径为150的圆,默认填充色为黑色 + Circle({ width: 150, height: 200 }) + // 绘制一个直径为150的圆, + Circle({ width: 150, height: 200 }).foregroundColor(Color.Red) + }.width('100%').backgroundColor(Color.Blue) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..14ff92a2cf34b54c180f74dc29ad57c2c8cefc19 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets @@ -0,0 +1,28 @@ +/* + * 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 ColoringStrategyExample { + build() { + Column({ space: 100 }) { + // 绘制一个直径为150的圆,默认填充色为黑色 + Circle({ width: 150, height: 200 }) + // 绘制一个直径为150的圆,设置前景色为组件背景色的反色 + Circle({ width: 150, height: 200 }) + .backgroundColor(Color.Black) + .foregroundColor(ColoringStrategy.INVERT) + }.width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bc2885229020008cd68e3b3086b07e3e1808a54 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.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. + */ +@Entry +@Component +struct foregroundColorInherit { + build() { + Column() { + Button('设置前景色为橘色').fontSize(20).foregroundColor(Color.Orange).backgroundColor(Color.Gray) + Divider() + Button('未设置前景色继承自父组件').fontSize(20).backgroundColor(Color.Gray) + }.foregroundColor(Color.Red) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2fae7b9c27a85791a763a5ba922d0b39b21c0d2 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets @@ -0,0 +1,29 @@ +/* + * 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 ForegroundEffectExample { + build() { + Row() { + Image($r('app.media.icon')) + .width(100) + .height(100) + .foregroundEffect({ radius: 20 }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..543c1b789a6a6b8bb756464cc68051ad30b3b6b9 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets @@ -0,0 +1,83 @@ +/* + * 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 ImageEffectsExample { + build() { + Column({ space: 5 }) { + // 添加阴影效果,图片效果不变 + Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')) + .width('90%') + .height(30) + .shadow({ + radius: 10, + color: Color.Green, + offsetX: 20, + offsetY: 20 + }) + + // 添加内部阴影效果 + Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')) + .width('90%') + .height(30) + .shadow({ + radius: 5, + color: Color.Green, + offsetX: 20, + offsetY: 20, + fill: true + }).opacity(0.5) + + // 灰度效果0~1,越接近1,灰度越明显 + Text('grayscale').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).grayscale(0.3) + Image($r('app.media.image')).width('90%').height(30).grayscale(0.8) + + // 高光效果,1为正常图片,<1变暗,>1亮度增大 + Text('brightness').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).brightness(1.2) + + // 饱和度,原图为1 + Text('saturate').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).saturate(2.0) + Image($r('app.media.image')).width('90%').height(30).saturate(0.7) + + // 对比度,1为原图,>1值越大越清晰,<1值越小越模糊 + Text('contrast').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).contrast(2.0) + Image($r('app.media.image')).width('90%').height(30).contrast(0.8) + + // 图像反转比例 + Text('invert').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).invert(0.2) + Image($r('app.media.image')).width('90%').height(30).invert(0.8) + + // 叠色添加 + Text('colorBlend').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Green) + Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Blue) + + // 深褐色 + Text('sepia').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).sepia(0.8) + + // 色相旋转 + Text('hueRotate').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).hueRotate(90) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52c5efdbc93eadbd7c16b14ba15c41ba626497c2 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.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. + */ +@Entry +@Component +struct ImageEffectsExample10 { + build() { + Column() { + Stack() { + Image($r('app.media.testImage')).width('100%').height('100%') + Column() + .width(150) + .height(10) + .systemBarEffect() + .border({ radius: 5 }) + .margin({ bottom: 80 }) + }.alignContent(Alignment.Center) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a12fde422d88cf2c06a6beecd9d8e56e9953725d --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets @@ -0,0 +1,32 @@ +/* + * 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 ImageExample1 { + private_resource1: Resource = $r('app.media.testlinearGradientBlurOrigin'); + @State image_src: Resource = this.private_resource1; + + build() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Row({ space: 5 }) { + Image(this.image_src) + .linearGradientBlur(60, + { fractionStops: [[0, 0], [0, 0.33], [1, 0.66], [1, 1]], direction: GradientDirection.Bottom }) + } + } + } + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f0a70c403a3f6955bc3df7b0e98b9383b31133b --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets @@ -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. + */ +@Component +struct Component1 { + @Prop renderGroupValue: boolean; + + build() { + Row() { + Row() { + Row() + .backgroundColor(Color.Black) + .width(100) + .height(100) + .opacity(1) + } + .backgroundColor(Color.White) + .width(150) + .height(150) + .justifyContent(FlexAlign.Center) + .opacity(0.6) + .renderGroup(this.renderGroupValue) + } + .backgroundColor(Color.Black) + .width(200) + .height(200) + .justifyContent(FlexAlign.Center) + .opacity(1) + } +} + +@Entry +@Component +struct RenderGroupExample { + build() { + Column() { + Component1({ renderGroupValue: true }) + .margin(20) + Component1({ renderGroupValue: false }) + .margin(20) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3177a411a76b47d386478aef32659084b637593f --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets @@ -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. + */ +@Entry +@Component +struct ImageEffectsExample4 { + build() { + Column() { + Text("blendMode") + .fontSize(20) + .fontWeight(FontWeight.Bold) + .fontColor('#ffff0101') + Row() { + Circle() + .width(200) + .height(200) + .fill(Color.Green) + .position({ x: 50, y: 50 }) + Circle() + .width(200) + .height(200) + .fill(Color.Blue) + .position({ x: 150, y: 50 }) + } + .blendMode(BlendMode.OVERLAY, BlendApplyType.OFFSCREEN) + .alignItems(VerticalAlign.Center) + .height(300) + .width('100%') + } + .height('100%') + .width('100%') + .backgroundImage($r('app.media.image')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a67847230b97529c878eca559526208d5d4ebcf --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets @@ -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. + */ +@Entry +@Component +struct ImageEffect5 { + build() { + Stack() { + Column() + Stack() { + Image($r('app.media.r')).width('100%') + Column() { + Column().width('100%').height(30).invert({ + low: 0, + high: 1, + threshold: 0.5, + thresholdRange: 0.2 + }) + Column().width('100%').height(30).invert({ + low: 0.2, + high: 0.5, + threshold: 0.3, + thresholdRange: 0.2 + }) + } + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1e2936d707d1b91b769a678f47a4be60f211cfc --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.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 UseShadowBatchingExample { + build() { + Column() { + Column({ space: 10 }) { + Stack() { + + } + .width('90%') + .height(50) + .margin({ top: 5 }) + .backgroundColor(0xFFE4C4) + .shadow({ + radius: 120, + color: Color.Green, + offsetX: 0, + offsetY: 0 + }) + .align(Alignment.TopStart) + .shadow({ + radius: 120, + color: Color.Green, + offsetX: 0, + offsetY: 0 + }) + + Stack() { + + } + .width('90%') + .height(50) + .margin({ top: 5 }) + .backgroundColor(0xFFE4C4) + .align(Alignment.TopStart) + .shadow({ + radius: 120, + color: Color.Red, + offsetX: 0, + offsetY: 0 + }) + .width('90%') + .backgroundColor(Color.White) + + Column() { + Text() + .fontWeight(FontWeight.Bold) + .fontSize(20) + .fontColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .width(150) + .height(150) + .borderRadius(10) + .backgroundColor(0xf56c6c) + .shadow({ + radius: 300, + color: Color.Yellow, + offsetX: 0, + offsetY: 0 + }) + + Column() { + Text() + .fontWeight(FontWeight.Bold) + .fontSize(20) + .fontColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .width(150) + .height(150) + .backgroundColor(0x67C23A) + .borderRadius(10) + .translate({ y: -50 }) + .shadow({ + radius: 220, + color: Color.Blue, + offsetX: 0, + offsetY: 0 + }) + } + .useShadowBatching(true) + } + .width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ee5f04bd6852ea779c631edfa02e9f0fadfc762 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets @@ -0,0 +1,35 @@ +/* + * 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 SphericalEffectExample { + build() { + Stack() { + TextInput({ placeholder: $r('app.string.placeholder') }) + .width('50%') + .height(35) + .type(InputType.Number) + .enterKeyType(EnterKeyType.Done) + .caretColor(Color.Red) + .placeholderColor(Color.Blue) + .placeholderFont({ + size: 20, + style: FontStyle.Italic, + weight: FontWeight.Bold + }) + .sphericalEffect(0.5) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e39d9f697d4bf6bc33b649f91f1a58cc7c7e8b54 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets @@ -0,0 +1,29 @@ +/* + * 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 LightUpExample { + build() { + Stack() { + Text('This is the text content with letterSpacing 0.') + .letterSpacing(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('50%') + .lightUpEffect(0.6) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..be953e632a2d32a8cea28cd16a2ab1153cbec3e4 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets @@ -0,0 +1,35 @@ +/* + * 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 PixelStretchExample { + build() { + Stack() { + Text('This is the text content with letterSpacing 0.') + .letterSpacing(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .clip(false) + .width('50%') + .pixelStretchEffect({ + top: 10, + left: 10, + right: 10, + bottom: 10 + }) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5fe2f7e82b1489d0a8cd6c6fec0d50b0a91d2d20 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets @@ -0,0 +1,41 @@ +/* + * 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 ColorGradientExample { + build() { + Column({ space: 5 }) { + Text('linearGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%') + .height(50) + .linearGradient({ + angle: 90, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + Text('linearGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%') + .height(50) + .linearGradient({ + direction: GradientDirection.Left, // 渐变方向 + repeating: true, // 渐变颜色是否重复 + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c16b0e03fdf6c863eab0d4bc45099dc4d36d006 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.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. + */ +@Entry +@Component +struct ColorGradientExample2 { + build() { + Column({ space: 5 }) { + Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .sweepGradient({ + center: [50, 50], + start: 0, + end: 359, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + + Text('sweepGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .sweepGradient({ + center: [50, 50], + start: 0, + end: 359, + rotation: 45, // 旋转角度 + repeating: true, // 渐变颜色是否重复 + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbe57acfdd30a6f79e915e4ad141c9d9e5d8ca68 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.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. + */ +@Entry +@Component +struct ColorGradientExample3 { + build() { + Column({ space: 5 }) { + Text('radialGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .radialGradient({ + center: [50, 50], + radius: 60, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + Text('radialGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .radialGradient({ + center: [50, 50], + radius: 60, + repeating: true, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddf7faebcf5fe0a948d2918d6bef476c4cc35866 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets @@ -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. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct motionBlurTest { + @State widthSize: number = 400; + @State heightSize: number = 320; + @State flag: boolean = true; + @State radius: number = 0; + @State x: number = 0; + @State y: number = 0; + + build() { + Column() { + Column() { + Image($r('app.media.testImg')) + .width(this.widthSize) + .height(this.heightSize) + .onClick(() => { + this.radius = 5; + this.x = 0.5; + this.y = 0.5; + if (this.flag) { + this.widthSize = 100; + this.heightSize = 80; + } else { + this.widthSize = 400; + this.heightSize = 320; + } + this.flag = !this.flag; + }) + .animation({ + duration: 2000, + curve: curves.springCurve(10, 1, 228, 30), + onFinish: () => { + this.radius = 0; + } + }) + .motionBlur({ radius: this.radius, anchor: { x: this.x, y: this.y } }) + } + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..08ae8f6efa8f497135b7c08377f76c8bee309631 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.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. + */ +@Entry +@Component +struct OpacityExample { + build() { + Column({ space: 5 }) { + Text('opacity(1)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(1).backgroundColor(0xAFEEEE) + Text('opacity(0.7)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.7).backgroundColor(0xAFEEEE) + Text('opacity(0.4)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.4).backgroundColor(0xAFEEEE) + Text('opacity(0.1)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.1).backgroundColor(0xAFEEEE) + Text('opacity(0)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0).backgroundColor(0xAFEEEE) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..baf0d3fa2fa36fbd3cb504a9767de7fb528c9d5b --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.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. + */ +@Entry +@Component +struct OutlineExample { + build() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + // 线段 + Text('DASHED') + .backgroundColor(Color.Pink) + .outlineStyle(OutlineStyle.DASHED).outlineWidth(5).outlineColor(0xAFEEEE).outlineRadius(10) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + // 点线 + Text('DOTTED') + .backgroundColor(Color.Pink) + .outline({ width: 5, color: 0x317AF7, radius: 10, style: OutlineStyle.DOTTED }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + }.width('100%').height(150) + + Text('.outline') + .backgroundColor(Color.Pink) + .fontSize(50) + .width(300) + .height(300) + .outline({ + width: { left: 3, right: 6, top: 10, bottom: 15 }, + color: { left: '#e3bbbb', right: Color.Blue, top: Color.Red, bottom: Color.Green }, + radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 }, + style: { + left: OutlineStyle.DOTTED, + right: OutlineStyle.DOTTED, + top: OutlineStyle.SOLID, + bottom: OutlineStyle.DASHED + } + }).textAlign(TextAlign.Center) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d66ffe5be2e8926b17495a36b8450faf6845bebd --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets @@ -0,0 +1,52 @@ +/* + * 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 OutlineExample2 { + build() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + // 线段 + Text('DASHED') + .backgroundColor(Color.Pink) + .outlineStyle(OutlineStyle.DASHED).outlineWidth(5).outlineColor(0xAFEEEE).outlineRadius(10) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + // 点线 + Text('DOTTED') + .backgroundColor(Color.Pink) + .outline({ width: 5, color: 0x317AF7, radius: 10, style: OutlineStyle.DOTTED }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + }.width('100%').height(150) + + Text('.outline') + .backgroundColor(Color.Pink) + .fontSize(50) + .width(300) + .height(300) + .outline({ + width: { left: 3, right: 6, top: 10, bottom: 15 }, + color: { start: '#e3bbbb', end: Color.Blue, top: Color.Red, bottom: Color.Green }, + radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 }, + style: { + left: OutlineStyle.DOTTED, + right: OutlineStyle.DOTTED, + top: OutlineStyle.SOLID, + bottom: OutlineStyle.DASHED + } + }).textAlign(TextAlign.Center) + } + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..462ea9c2154a546a6de1aa40dc194223c426ea2e --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.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 RenderFitExample { + @State width1: number = 100; + @State height1: number = 30; + flag: boolean = true; + + build() { + Column() { + Text("Hello") + .width(this.width1) + .height(this.height1) + .borderWidth(1) + .textAlign(TextAlign.Start) + .renderFit(RenderFit.LEFT)// 设置LEFT的renderFit,动画过程中,动画的终态内容与组件保持左对齐 + .margin(20) + + Text("Hello") + .width(this.width1) + .height(this.height1) + .textAlign(TextAlign.Center) + .borderWidth(1) + .renderFit(RenderFit.CENTER)// 设置CENTER的renderFit,动画过程中,动画的终态内容与组件保持中心对齐 + .margin(20) + + Button("animate") + .onClick(() => { + this.getUIContext()?.animateTo({ curve: Curve.Ease }, () => { + if (this.flag) { + this.width1 = 150; + this.height1 = 50; + } else { + this.width1 = 100; + this.height1 = 30; + } + this.flag = !this.flag; + }) + }) + }.width('100%').height('100%').alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce0425413b306dcb3f223d4a21af27bdb5a25a34 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.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 { matrix4 } from '@kit.ArkUI'; + +@Entry +@Component +struct TransformExample { + build() { + Column() { + Text('rotate').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .rotate({ + x: 0, + y: 0, + z: 1, + centerX: '50%', + centerY: '50%', + angle: 300 + })// 组件以矢量(0,0,1)为旋转轴,绕中心点顺时针旋转300度 + .width(100).height(100).backgroundColor(0xAFEEEE) + + Text('translate').width('90%').fontColor(0xCCCCCC).padding(10).fontSize(14) + Row() + .translate({ x: 100, y: 10 })// x轴方向平移100,y轴方向平移10 + .width(100) + .height(100) + .backgroundColor(0xAFEEEE) + .margin({ bottom: 10 }) + + Text('scale').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .scale({ x: 2, y: 0.5 })// 高度缩小一倍,宽度放大一倍,z轴在2D下无效果 + .width(100).height(100).backgroundColor(0xAFEEEE) + + Text('Matrix4').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .width(100).height(100).backgroundColor(0xAFEEEE) + .transform(matrix4.identity().translate({ x: 50, y: 50 }).scale({ x: 1.5, y: 1 }).rotate({ + x: 0, + y: 0, + z: 1, + angle: 60 + })) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c95c3279180516809bae9f60848140b128770cd --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.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. + */ +@Entry +@Component +struct TransFormExample2 { + @State prep: number = 10; + + build() { + Row() { + Column() { + Stack() + .width(100) + .height(100) + .backgroundColor(Color.Red) + .rotate({ y: 1, angle: 45, perspective: this.prep }) + Button('change prep') + .margin({ top: 100 }) + .onClick(() => { + this.getUIContext()?.animateTo({ + duration: 2000, + curve: Curve.EaseIn, + iterations: 1, + playMode: PlayMode.Normal, + onFinish: () => { + console.info('play end'); + } + }, () => { + this.prep = 500 // 组件视距从10变换到500 + }) + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd3ebbfa6ff98dbd8442001282171e42b60b3c59 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.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. + */ +import { matrix4 } from '@kit.ArkUI'; + +@Entry +@Component +struct MatrixExample { + build() { + Column({ space: 100 }) { + Text('Hello1') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + + Text('Hello2') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .rotate({ + // 绕(100vp,60vp)的锚点旋转90度,rotate或scale的centerX、centerY为组件锚点 + z: 1, + angle: 90, + centerX: 100, + centerY: 60 + }) + + Text('Hello3') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .transform(matrix4.identity() + .rotate({ + // 组件锚点(centerX,centerY)默认为(50%,50%),即锚点在(50vp,30vp) + // transform的rotate指定(centerX,centerY)为(50vp,30vp),相对于在组件本身锚点基础上再额外偏移(50vp,30vp) + // 此次变换相当于绕(100vp,60vp)旋转,和"Hello2"实现同样的旋转效果 + z: 1, + angle: 90, + centerX: this.getUIContext().vp2px(50), + centerY: this.getUIContext().vp2px(30) + })) + + Text('Hello4') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .scale({ + // 当设置x或y时,centerX和centerY才能生效 + // 设置组件锚点为(100vp,60vp) + x: 1, + y: 1, + centerX: 100, + centerY: 60 + })// transform的rotate不指定centerX、centerY,此次旋转的中心相对于组件本身锚点没有额外偏移 + // 该组件通过scale设置的锚点,绕(100vp,60vp)进行旋转,和"Hello2"实现同样的旋转效果 + .transform(matrix4.identity().rotate({ z: 1, angle: 90 })) + }.width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..89b75f28bc2c860e257783b50ddd253c7efd021a --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets @@ -0,0 +1,71 @@ +/* + * 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 UseEffectExample { + @State isUse: boolean = true; + + build() { + Stack() { + Image($r("app.media.mountain")) + .autoResize(true) + EffectComponent() { + Column({ space: 20 }) { + Column() { + } + .position({ x: 0, y: 0 }) + .width(150) + .height(800) + .useEffect(this.isUse, EffectType.WINDOW_EFFECT) + + Column() { + } + .position({ x: 200, y: 20 }) + .width(150) + .height(300) + .useEffect(this.isUse, EffectType.DEFAULT) + + Column() { + } + .position({ x: 400, y: 20 }) + .width(150) + .height(300) + .useEffect(this.isUse) + } + .width('100%') + .height('100%') + } + .backgroundBlurStyle(BlurStyle.Thin) + + Column() { + } + .position({ x: 600, y: 0 }) + .width(150) + .height(800) + .useEffect(this.isUse, EffectType.WINDOW_EFFECT) + + Row() { + Button('useEffect') + .margin(30) + .onClick(() => { + this.isUse = !this.isUse; + }) + } + .position({ x: 300, y: 450 }) + } + .backgroundColor(Color.Black) + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..50e5ab0251c8a331da9f25e46c5fedd42a0edce6 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets @@ -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. + */ +import { uiEffect } from '@kit.ArkGraphics2D'; + +@Entry +@Component +struct FilterEffectExample { + @State filterTest1: uiEffect.Filter = uiEffect.createFilter().blur(10); + @State filterTest2: uiEffect.Filter = uiEffect.createFilter().blur(10); + @State filterTest3: uiEffect.Filter = uiEffect.createFilter().blur(10); + + build() { + Column({ space: 15 }) { + + Text('foregroundFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('前景滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .foregroundFilter(this.filterTest1) // 通过 foregroundFilter 设置模糊效果 + + Text('backgroundFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('背景滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .backgroundFilter(this.filterTest2) // 通过 backgroundFilter 设置模糊效果 + + Text('compositingFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('合成滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .compositingFilter(this.filterTest3) // 通过 compositingFilter 设置模糊效果 + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/module.json5 b/ArkUIKit/VisionEffect/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..00d847b7bfd514973fbade9f670e96253df4a7be --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/element/color.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/element/float.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/element/string.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..47f4e9fdb22b0b93b85595f69e294438c6d8952b --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/resources/base/element/string.json @@ -0,0 +1,256 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "VisionEffect" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, + { + "name": "please_click_button", + "value": "请点击按钮" + }, + { + "name": "transform", + "value": "图形变换" + }, + { + "name": "example_one_transform", + "value": "示例1(为组件添加图形变换效果)" + }, + { + "name": "example_two_transform", + "value": "示例2(设置旋转视距)" + }, + { + "name": "example_three_transform", + "value": "示例3(按中心点旋转)" + }, + { + "name": "opacity", + "value": "透明度设置" + }, + { + "name": "example_one_opacity", + "value": "示例1" + }, + { + "name": "example_one_clip", + "value": "示例1(使用不同裁剪属性)" + }, + { + "name": "example_two_clip", + "value": "示例2(裁剪属性动画)" + }, + { + "name": "clip", + "value": "形状裁剪" + }, + { + "name": "imageEffect", + "value": "图像效果" + }, + { + "name": "background", + "value": "背景设置" + }, + { + "name": "foregroundBlurStyle", + "value": "组件内容模糊" + }, + { + "name": "foregroundColor", + "value": "前景色设置" + }, + { + "name": "clickEffect", + "value": "点击回弹效果" + }, + { + "name": "useEffect", + "value": "特效绘制合并" + }, + { + "name": "renderFit", + "value": "组件内容填充方式" + }, + { + "name": "outline", + "value": "外描边设置" + }, + { + "name": "motionBlur", + "value": "运动模糊" + }, + { + "name": "linearGradient", + "value": "颜色渐变" + }, + { + "name": "foregroundEffect", + "value": "前景属性设置" + }, + { + "name": "visualEffect", + "value": "视效设置" + }, + { + "name": "example_one_imageEffect", + "value": "示例1(设置图片不同属性效果)'" + }, + { + "name": "example_two_imageEffect", + "value": "示例2(设置组件线性渐变模糊效果)" + }, + { + "name": "example_three_imageEffect", + "value": "示例3(设置离屏渲染效果)" + }, + { + "name": "example_four_imageEffect", + "value": "示例4(当前组件内容与下方画布内容混合)" + }, + { + "name": "example_five_imageEffect", + "value": "示例5(前景智能取反色)" + }, + { + "name": "example_six_imageEffect", + "value": "示例6(设置同层阴影不重叠效果)" + }, + { + "name": "example_seven_imageEffect", + "value": "示例7(设置组件图像球面效果)" + }, + { + "name": "example_eight_imageEffect", + "value": "示例8(设置组件图像渐亮效果)" + }, + { + "name": "example_nine_imageEffect", + "value": "示例9(设置组件图像边缘像素扩展效果)" + }, + { + "name": "example_ten_imageEffect", + "value": "示例10(系统导航条智能反色)" + }, + { + "name": "example_one_background", + "value": "示例1(设置背景基础样式)'" + }, + { + "name": "example_two_background", + "value": "示例2(设置背景模糊样式)" + }, + { + "name": "example_three_background", + "value": "示例3(设置组件背景)" + }, + { + "name": "example_four_background", + "value": "示例4(设置组件背景提亮效果)" + }, + { + "name": "example_five_background", + "value": "示例5(设置模糊属性)" + }, + { + "name": "example_six_background", + "value": "示例6(设置文字异形模糊效果)" + }, + { + "name": "example_seven_background", + "value": "示例7(模糊效果对比)" + }, + { + "name": "example_one_foregroundBlurStyle", + "value": "示例1" + }, + { + "name": "example_one_foregroundColor", + "value": "示例1(使用前景色设置)'" + }, + { + "name": "example_two_foregroundColor", + "value": "示例2(设置前景色为组件背景色反色)" + }, + { + "name": "example_three_foregroundColor", + "value": "示例3(前置景色未继承父组件)" + }, + { + "name": "example_one_clickEffect", + "value": "示例1'" + }, + { + "name": "example_one_useEffect", + "value": "示例1'" + }, + { + "name": "example_one_renderFit", + "value": "示例1'" + }, + { + "name": "example_one_outline", + "value": "示例1(使用外描边属性)'" + }, + { + "name": "example_two_outline", + "value": "示例2(使用LocalizedEdgeColors类型)" + }, + { + "name": "example_one_motionBlur", + "value": "示例1'" + }, + { + "name": "example_one_linearGradient", + "value": "示例1(颜色从右向左线性渐变)" + }, + { + "name": "example_two_linearGradient", + "value": "示例2(颜色按旋转角度渐变)'" + }, + { + "name": "example_three_linearGradient", + "value": "示例3(颜色按径向渐变)" + }, + { + "name": "example_one_foregroundEffect", + "value": "示例1'" + }, + { + "name": "example_one_visualEffect", + "value": "示例1'" + }, + { + "name": "October_16th", + "value": "10月16日'" + }, + { + "name": "Monday", + "value": "星期一'" + }, + { + "name": "placeholder", + "value": "请输入变化范围百分比([0%,100%])'" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/app_icon.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/app_icon.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/background.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/bg.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/bg.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/book.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/book.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/drawer.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/drawer.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/forest.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/forest.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/heart.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/heart.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_public_highlights.svg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/media/icon.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/icon.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/icon_2.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/icon_2.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image_1.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/image_1.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/img_1.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/media/mountain.jpg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/r.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/r.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sky.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sky.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sun.jpg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/sun.jpg differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/test.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/test.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImage.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImg.jpg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image2.png b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/tree.JPG b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/ArkUIKit/VisionEffect/entry/src/main/resources/base/media/tree.JPG differ diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/VisionEffect/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..848733fbd37aa508501d724aaec6f794e418ffd5 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,43 @@ +{ + "src": [ + "pages/Index", + "pages/transform/template1/Index", + "pages/transform/template2/Index", + "pages/transform/template3/Index", + "pages/opacity/template1/Index", + "pages/clip/template1/Index", + "pages/clip/template2/Index", + "pages/imageEffect/template1/Index", + "pages/imageEffect/template2/Index", + "pages/imageEffect/template3/Index", + "pages/imageEffect/template4/Index", + "pages/imageEffect/template5/Index", + "pages/imageEffect/template6/Index", + "pages/imageEffect/template7/Index", + "pages/imageEffect/template8/Index", + "pages/imageEffect/template9/Index", + "pages/imageEffect/template10/Index", + "pages/background/template1/Index", + "pages/background/template2/Index", + "pages/background/template3/Index", + "pages/background/template4/Index", + "pages/background/template5/Index", + "pages/background/template6/Index", + "pages/background/template7/Index", + "pages/foregroundBlurStyle/template1/Index", + "pages/foregroundColor/template1/Index", + "pages/foregroundColor/template2/Index", + "pages/foregroundColor/template3/Index", + "pages/clickEffect/template1/Index", + "pages/useEffect/template1/Index", + "pages/renderFit/template1/Index", + "pages/outline/template1/Index", + "pages/outline/template2/Index", + "pages/motionBlur/template1/Index", + "pages/linearGradient/template1/Index", + "pages/linearGradient/template2/Index", + "pages/linearGradient/template3/Index", + "pages/foregroundEffect/template1/Index", + "pages/visualEffect/template1/Index" + ] +} diff --git a/ArkUIKit/VisionEffect/entry/src/main/resources/dark/element/color.json b/ArkUIKit/VisionEffect/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/mock/mock-config.json5 b/ArkUIKit/VisionEffect/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f7cdedbde009a69923d11e79b251d52ee3eaa92 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.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 { 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. + }) + /* + * @tc.number: VisionEffect_assertContain + * @tc.name: Test ability + * @tc.desc: Test ability + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + 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); + hilog.info(0x0000, 'testTag', '%{public}s', 'it end'); + }) + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b94e5e1c60390087c2e5f8746643f9c63a12df7c --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets @@ -0,0 +1,165 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function BackgroundTest() { + describe('VisionEffect_BackgroundTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.background')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_001 + * @tc.name: example_one_background + * @tc.desc: example_one_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_002 + * @tc.name: example_two_background + * @tc.desc: example_two_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_003 + * @tc.name: example_three_background + * @tc.desc: example_three_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_003_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_004 + * @tc.name: example_four_background + * @tc.desc: example_four_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_four_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_004_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_005 + * @tc.name: example_five_background + * @tc.desc: example_five_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_five_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_005_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_006 + * @tc.name: example_six_background + * @tc.desc: example_six_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_six_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_006_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_007 + * @tc.name: example_seven_background + * @tc.desc: example_seven_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_seven_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_007_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2b43c5bc710e5628e028583cf31d9297f119a77 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets @@ -0,0 +1,90 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ClickEffectTest() { + describe('VisionEffect_ClickEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.clickEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ClickEffectTest_001 + * @tc.name: example_one_clickEffect + * @tc.desc: example_one_clickEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClickEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClickEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_clickEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + + let Toggles = await driver.findComponents(ON.type('Toggle')); + await Toggles[0].click(); + await driver.delayMs(1000); + + await Toggles[1].click(); + await driver.delayMs(1000); + + await Toggles[2].click(); + await driver.delayMs(1000); + + await Toggles[3].click(); + await driver.delayMs(1000); + + let aimComponents = await driver.findComponents(ON.text('status button')); + await aimComponents[0].click(); + await driver.delayMs(1000); + + await aimComponents[1].click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ClickEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..544677206c2d1ca3091a2d47952dc9134dd121f7 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets @@ -0,0 +1,106 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ClipTest() { + describe('VisionEffect_ClipTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ClipTest_001 + * @tc.name: example_one_clip + * @tc.desc: example_one_clip + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClipTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ClipTest_002 + * @tc.name: example_two_clip + * @tc.desc: example_two_clip + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClipTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('updateProgress')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + + aimComponent = await driver.findComponent(ON.text('click reset!')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('updateColor')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('updateProgress')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..150f45e25607f683e9c530d25e5d1f561409e4a1 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundBlurStyleTest() { + describe('VisionEffect_ForegroundBlurStyleTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundBlurStyle')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundBlurStyleTest_001 + * @tc.name: example_one_foregroundBlurStyle + * @tc.desc: example_one_foregroundBlurStyle + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundBlurStyleTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundBlurStyleTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundBlurStyle')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundBlurStyleTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bf224c4bd6b64b1bf73ac5d7055fd6335f23f42 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundColorTest() { + describe('VisionEffect_ForegroundColorTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_001 + * @tc.name: example_one_foregroundColor + * @tc.desc: example_one_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_002 + * @tc.name: example_two_foregroundColor + * @tc.desc: example_two_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_003 + * @tc.name: example_three_foregroundColor + * @tc.desc: example_three_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb5ea0bd469c7beb236cdcdcce9b34123c8277eb --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundEffectTest() { + describe('VisionEffect_ForegroundEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundEffectTest_001 + * @tc.name: example_one_foregroundEffect + * @tc.desc: example_one_foregroundEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f96dad946ca9e0e7a73dfad6847aa02dc6d61ae8 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets @@ -0,0 +1,214 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ImageEffectTest() { + describe('VisionEffect_ImageEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_001 + * @tc.name: example_one_imageEffect + * @tc.desc: example_one_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_002 + * @tc.name: example_two_imageEffect + * @tc.desc: example_two_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_003 + * @tc.name: example_three_imageEffect + * @tc.desc: example_three_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_003_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_004 + * @tc.name: example_four_imageEffect + * @tc.desc: example_four_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_four_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_004_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_005 + * @tc.name: example_five_imageEffect + * @tc.desc: example_five_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_five_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_005_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_006 + * @tc.name: example_six_imageEffect + * @tc.desc: example_six_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_six_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_006_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_007 + * @tc.name: example_seven_imageEffect + * @tc.desc: example_seven_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_seven_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_007_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_008 + * @tc.name: example_eight_imageEffect + * @tc.desc: example_eight_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_008', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_008_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_eight_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_008_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_009 + * @tc.name: example_nine_imageEffect + * @tc.desc: example_nine_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_009', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_009_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_nine_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_009_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_010 + * @tc.name: example_ten_imageEffect + * @tc.desc: example_ten_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_010', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_010_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_ten_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_010_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9167606aace450a1cdbf4e59c7cb1c6f20f18cdd --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function LinearGradientTest() { + describe('VisionEffect_LinearGradientTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_001 + * @tc.name: example_one_linearGradient + * @tc.desc: example_one_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_002 + * @tc.name: example_two_linearGradient + * @tc.desc: example_two_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_003 + * @tc.name: example_three_linearGradient + * @tc.desc: example_three_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..318bbc28c73fb4d174eb1720cc76c84e11882532 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/List.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 { TransformTest } from './Transform.test'; +import { OpacityTest } from './Opacity.test'; +import { ClipTest } from './Clip.test'; +import { ImageEffectTest } from './ImageEffect.test'; +import { BackgroundTest } from './Background.test'; +import { ForegroundBlurStyleTest } from './ForegroundBlurStyle.test'; +import { ForegroundColorTest } from './ForegroundColor.test'; +import { ClickEffectTest } from './ClickEffect.test'; +import { UseEffectTest } from './UseEffect.test'; +import { OutLineTest } from './OutLine.test'; +import { RenderFitTest } from './RenderFit.test'; +import { MotionBlurTest } from './MotionBlur.test'; +import { LinearGradientTest } from './LinearGradient.test'; +import { ForegroundEffectTest } from './ForegroundEffect.test'; +import { VisualEffectTest } from './VisualEffect.test' + + +export default function testsuite() { + TransformTest(); + OpacityTest(); + ClipTest(); + ImageEffectTest(); + BackgroundTest(); + ForegroundBlurStyleTest(); + ForegroundColorTest(); + ClickEffectTest(); + UseEffectTest(); + RenderFitTest(); + OutLineTest(); + MotionBlurTest(); + LinearGradientTest(); + ForegroundEffectTest(); + VisualEffectTest(); +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..19e739f5794bbb785e63e030e26ed6c12aee20fe --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function MotionBlurTest() { + describe('VisionEffect_MotionBlurTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.motionBlur')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_MotionBlurTest_001 + * @tc.name: example_one_motionBlur + * @tc.desc: example_one_motionBlur + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'MotionBlurTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_MotionBlurTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_motionBlur')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Image')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Image')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_MotionBlurTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..897bf55df22e64fe4d39fb2357d5607eaf753c2f --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function OpacityTest() { + describe('VisionEffect_OpacityTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.opacity')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_OpacityTest_001 + * @tc.name: example_one_opacity + * @tc.desc: example_one_opacity + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpacityTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OpacityTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_opacity')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OpacityTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c18d7e3f8cd9c4796900bdba5644fbaaab99539 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets @@ -0,0 +1,86 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function OutLineTest() { + describe('VisionEffect_OutLineTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_OutLineTest_001 + * @tc.name: example_one_outline + * @tc.desc: example_one_outline + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OutLineTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_OutLineTest_002 + * @tc.name: example_two_outline + * @tc.desc: example_two_outline + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OutLineTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..50bdc69d39dad7a9944c58d41529403f0e9ada35 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets @@ -0,0 +1,74 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function RenderFitTest() { + describe('VisionEffect_RenderFitTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.renderFit')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_RenderFitTest_001 + * @tc.name: example_one_renderFit + * @tc.desc: example_one_renderFit + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'RenderFitTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_RenderFitTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_renderFit')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('animate')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_RenderFitTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f12681f8738e7effb2afea3494e8eec3b8fa280 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets @@ -0,0 +1,106 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function TransformTest() { + describe('VisionEffect_TransformTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_TransformTest_001 + * @tc.name: example_one_transform + * @tc.desc: example_one_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_TransformTest_002 + * @tc.name: example_two_transform + * @tc.desc: example_two_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change prep')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_TransformTest_003 + * @tc.name: example_three_transform + * @tc.desc: example_three_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b835508bd4b75f9437da79ce863bfa9773e8bb57 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets @@ -0,0 +1,74 @@ +/* + * 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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function UseEffectTest() { + describe('VisionEffect_UseEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.useEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_UseEffectTest_001 + * @tc.name: example_one_useEffect + * @tc.desc: example_one_useEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UseEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_UseEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_useEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('useEffect')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_UseEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.ets b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..beed8c5f11bd0afb5621048fd3b5a99175c37ea7 --- /dev/null +++ b/ArkUIKit/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.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. + */ +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 = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function VisualEffectTest() { + describe('VisionEffect_VisualEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.visualEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_VisualEffectTest_001 + * @tc.name: example_one_visualEffect + * @tc.desc: example_one_visualEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'VisualEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_VisualEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_visualEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_VisualEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/ArkUIKit/VisionEffect/entry/src/ohosTest/module.json5 b/ArkUIKit/VisionEffect/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..59667117c86b64ab9863f7b382c435ae4a3c32fa --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/test/List.test.ets b/ArkUIKit/VisionEffect/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/entry/src/test/LocalUnit.test.ets b/ArkUIKit/VisionEffect/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/hvigor/hvigor-config.json5 b/ArkUIKit/VisionEffect/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d435603637cbbfe92ac9865537a0c1051810bb1 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/hvigorfile.ts b/ArkUIKit/VisionEffect/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/oh-package.json5 b/ArkUIKit/VisionEffect/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..38abfd099681aeb547cf83a4966111dd5f4f6d13 --- /dev/null +++ b/ArkUIKit/VisionEffect/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/VisionEffect/ohosTest.md b/ArkUIKit/VisionEffect/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..9c090d5c0dca5f9949c78f5a2da22450c84a955e --- /dev/null +++ b/ArkUIKit/VisionEffect/ohosTest.md @@ -0,0 +1,21 @@ +# VisualEffect 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 背景设置示例代码验证 | 设备正常运行 | 切换背景颜色 | 背景颜色效果符合预期 | 是 | Pass | +| 点击回弹效果示例代码验证 | 设备正常运行 | 切换回弹效果 | 回弹效果符合预期 | 是 | Pass | +| 形状裁剪示例代码验证 | 设备正常运行 | 查看各个组件的裁剪效果 | 各个组件的裁剪效果正常 | 是 | Pass | +| 组件内容模糊示例代码验证 | 设备正常运行 | 查看各个组件的模糊效果 | 模糊效果正常,页面布局正常 | 是 | Pass | +| 前景色设置示例代码验证 | 设备正常运行 | 切换前景色 | 前景色正常,页面布局正常 | 是 | Pass | +| 前景属性设置示例代码验证 | 设备正常运行 | 切换前景属性 | 视效效果符合预期 | 是 | Pass | +| 图像效果示例代码验证 | 设备正常运行 | 切换页面,查看各种图像效果 | 图像效果符合预期 | 是 | Pass | +| 颜色渐变示例代码验证 | 设备正常运行 | 查看各个组件的渐变效果 | 渐变效果符合预期 | 是 | Pass | +| 运动模糊示例代码验证 | 设备正常运行 | 点击控件触发视效 | 运动模糊效果符合预期 | 是 | Pass | +| 透明度设置示例代码验证 | 设备正常运行 | 查看各个控件的透明度效果 | 透明度效果从上至下由深到浅 | 是 | Pass | +| 外描边设置示例代码验证 | 设备正常运行 | 查看各个控件的外描边效果 | 外描边效果符合预期 | 是 | Pass | +| 组件内容填充方式示例代码验证 | 设备正常运行 | 点击animate按钮 | 动画效果正常,视效效果正常,页面布局正常 | 是 | Pass | +| 图形变换示例代码验证 | 设备正常运行 | 查看各个示例页面中的组件 | 图形变换效果正常,页面布局正常 | 是 | Pass | +| 特效绘制合并示例代码验证 | 设备正常运行 | 点击useEffect按钮 | 特效绘制合并效果正常,页面布局正常 | 是 | Pass | +| 视效设置示例代码验证 | 设备正常运行 | 点击各种视觉效果 | 视效效果正常,页面布局正常 | 是 | Pass | diff --git a/ArkUIKit/VisionEffect/screenshots/device/image1.png b/ArkUIKit/VisionEffect/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..c169671c94477334f99ca19063dd351cde63861f Binary files /dev/null and b/ArkUIKit/VisionEffect/screenshots/device/image1.png differ