diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/oh-package-lock.json5 b/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/oh-package-lock.json5 deleted file mode 100644 index 5c8c8d64769f4712bca04df64e51eb46442cbc59..0000000000000000000000000000000000000000 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/oh-package-lock.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - "meta": { - "stableOrder": true - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" - }, - "packages": { - "libentry.so@src/main/cpp/types/libentry": { - "name": "libentry.so", - "version": "1.0.0", - "resolved": "src/main/cpp/types/libentry", - "registryType": "local" - } - } -} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/oh-package-lock.json5 b/ArkUIKit/CapiSample/NativeType/native_type_sample/oh-package-lock.json5 deleted file mode 100644 index 7fcf818273347b97063c0c0a151bb14770ca1c79..0000000000000000000000000000000000000000 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/oh-package-lock.json5 +++ /dev/null @@ -1,27 +0,0 @@ -{ - "meta": { - "stableOrder": true - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", - "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" - }, - "packages": { - "@ohos/hamock@1.0.0": { - "name": "@ohos/hamock", - "version": "1.0.0", - "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", - "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", - "registryType": "ohpm" - }, - "@ohos/hypium@1.0.21": { - "name": "@ohos/hypium", - "version": "1.0.21", - "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", - "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", - "registryType": "ohpm" - } - } -} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/.gitignore b/ArkUIKit/NativeNodeBaseSample/.gitignore similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/.gitignore rename to ArkUIKit/NativeNodeBaseSample/.gitignore diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/app.json5 b/ArkUIKit/NativeNodeBaseSample/AppScope/app.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/app.json5 rename to ArkUIKit/NativeNodeBaseSample/AppScope/app.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/element/string.json b/ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/element/string.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/element/string.json rename to ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/element/string.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/background.png b/ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/background.png similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/background.png rename to ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/background.png diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/foreground.png b/ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/foreground.png similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/foreground.png rename to ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/foreground.png diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/layered_image.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/media/layered_image.json rename to ArkUIKit/NativeNodeBaseSample/AppScope/resources/base/media/layered_image.json diff --git a/ArkUIKit/NativeNodeBaseSample/README.md b/ArkUIKit/NativeNodeBaseSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c6eb7de062cafd181f74d28b11e9b62b65f89260 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/README.md @@ -0,0 +1,74 @@ +# Native_node_Sample + +## 介绍 + +本示例展示了如何创建文本、输入框、文本域等组件,配置其样式、属性与事件,还含 UI 任务、反色设置等功能,构建文本页面。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 首页面会出现对应text选择框,点击选择框进入text界面; + + +## 工程目录 + +``` +StyledStringNDK +entry/src/main/ets/ +└── pages + ├── Index.ets (获取导航页面) + └── page_text.ets (文本界面) +entry/src/main/ +├── cpp +│ ├── types +│ │ └── libentry +│ │ └── Index.d.ts (函数对应的js映射) +│ ├── CMakeLists.txt (CMake脚本) +| ├── manager.cpp +| ├── manager.h +│ ├── napi_init.cpp +| ├── baseUtils.cpp +| ├── baseUtils.h +| ├── TextMaker.cpp +│ └── TextMaker.h +└── resources + ├── base + │ ├── element + │ │ ├── color.json + │ │ ├── float.json + │ │ └── string.json + │ └── media +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.36; + +3. 本示例已支持使DevEco Studio 5.1.1 Release (构建版本:5.1.1.840,构建 2025年9月20日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUISample/native_node_sample > .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/NativeNodeBaseSample/build-profile.json5 b/ArkUIKit/NativeNodeBaseSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fad9fdc848d85ebfa0e390c9abcc29c0f78e2d3a --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/build-profile.json5 @@ -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. + */ + +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ], + "signingConfigs": [ + { + "name": "default", + "material": { + "certpath": "C:/Users/mengbin/.ohos/config/openharmony/default_native_node_sample_chM8J6e_8dDNvGCBjfAkjWpumQsw6Odr2vOZoY9aYsQ=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B93DC0C18E4E80E972908BD6DDAD1A7A23708F713AE4EAC9F4A8150864E9BF213DAE8CCD1EAE461", + "profile": "C:/Users/mengbin/.ohos/config/openharmony/default_native_node_sample_chM8J6e_8dDNvGCBjfAkjWpumQsw6Odr2vOZoY9aYsQ=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:/Users/mengbin/.ohos/config/openharmony/default_native_node_sample_chM8J6e_8dDNvGCBjfAkjWpumQsw6Odr2vOZoY9aYsQ=.p12", + "storePassword": "0000001B14C8C965757EEB795058C932CF032B4275280291C134D1B8C12CA7DAF6B9EE19C0061639ADE130" + } + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/code-linter.json5 b/ArkUIKit/NativeNodeBaseSample/code-linter.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/code-linter.json5 rename to ArkUIKit/NativeNodeBaseSample/code-linter.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/.gitignore b/ArkUIKit/NativeNodeBaseSample/entry/.gitignore similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/.gitignore rename to ArkUIKit/NativeNodeBaseSample/entry/.gitignore diff --git a/ArkUIKit/NativeNodeBaseSample/entry/build-profile.json5 b/ArkUIKit/NativeNodeBaseSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..400a41af2decdde064672c31400f59b3ef2c75ef --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "armeabi-v7a","arm64-v8a", "x86_64" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/hvigorfile.ts b/ArkUIKit/NativeNodeBaseSample/entry/hvigorfile.ts similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/hvigorfile.ts rename to ArkUIKit/NativeNodeBaseSample/entry/hvigorfile.ts diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/obfuscation-rules.txt b/ArkUIKit/NativeNodeBaseSample/entry/obfuscation-rules.txt similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/obfuscation-rules.txt rename to ArkUIKit/NativeNodeBaseSample/entry/obfuscation-rules.txt diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/oh-package.json5 b/ArkUIKit/NativeNodeBaseSample/entry/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/oh-package.json5 rename to ArkUIKit/NativeNodeBaseSample/entry/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt similarity index 78% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/CMakeLists.txt rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt index a2f3bdcb29dd9ed2fea458250592b24ef10bfc14..3b5c8ddf0f5699133ae1f086fecb5203dc2662d8 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/CMakeLists.txt +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt @@ -7,7 +7,7 @@ set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${NATIVERENDER_ROOT_PATH} ${NATIVERENDER_ROOT_PATH}/include) -add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp) +add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp TextMaker.cpp) find_library(hilog-lib hilog_ndk.z) @@ -16,4 +16,5 @@ find_library(libace-lib ace_ndk.z) find_library(libnapi-lib ace_napi.z) -target_link_libraries(entry PUBLIC ${hilog-lib} ${libace-lib} ${libnapi-lib}) \ No newline at end of file +target_link_libraries(entry PUBLIC ${hilog-lib} ${libace-lib} ${libnapi-lib}) +target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..39734a5e31ed79ce63f6eb013173972c5f20e813 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.cpp @@ -0,0 +1,1206 @@ +/* + * 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. + */ + +#include "TextMaker.h" +#include "baseUtils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "manager" +#define LOG_INFO(...) OH_LOG_Print(LOG_APP, LOG_INFO, 0xD001400, LOG_TAG, __VA_ARGS__) + +#define VALUE_0 0 +#define VALUE_1 1 +#define VALUE_2 2 +#define VALUE_3 3 +#define VALUE_4 4 +#define VALUE_5 5 +#define VALUE_8 8 +#define VALUE_10 10 +#define VALUE_11 11 +#define VALUE_20 20 +#define VALUE_28 28 +#define VALUE_30 30 +#define VALUE_50 50 +#define VALUE_100 100 +#define VALUE_300 300 +#define VALUE_380 380 +#define VALUE_400 400 +#define EVENT_SPAN_LONG_PRESS 1 +#define EVENT_TEXT_INPUT_CHANGE 2 +#define EVENT_TEXT_INPUT_SUBMIT 3 +#define EVENT_TEXT_INPUT_CUT 4 +#define EVENT_TEXT_INPUT_PASTE 5 +#define EVENT_TEXT_INPUT_SELECTION_CHANGE 6 +#define EVENT_TEXT_INPUT_EDIT_CHANGE 7 +#define EVENT_TEXT_INPUT_CONTENT_SIZE_CHANGE 8 +#define EVENT_TEXT_INPUT_FILTER_ERROR 9 +#define EVENT_TEXT_INPUT_CONTENT_SCROLL 10 +#define EVENT_TEXT_INPUT_WILL_INSERT 11 +#define EVENT_TEXT_INPUT_DID_INSERT 12 +#define EVENT_TEXT_INPUT_WILL_DELETE 13 +#define EVENT_TEXT_INPUT_DID_DELETE 14 +#define EVENT_TEXT_INPUT_CHANGE_PREVIEW 15 +#define EVENT_TEXT_INPUT_WILL_CHANGE 16 +#define EVENT_TEXT_AREA_CHANGE 17 +#define EVENT_TEXT_AREA_PASTE 18 +#define EVENT_TEXT_AREA_SELECTION_CHANGE 19 +#define EVENT_TEXT_AREA_CONTENT_SCROLL 20 +#define EVENT_TEXT_AREA_EDIT_CHANGE 21 +#define EVENT_TEXT_AREA_SUBMIT 22 +#define EVENT_TEXT_AREA_CONTENT_SIZE_CHANGE 23 +#define EVENT_TEXT_AREA_DID_INSERT 24 +#define EVENT_TEXT_AREA_DID_DELETE 25 +#define EVENT_TEXT_AREA_CHANGE_PREVIEW 26 +#define EVENT_TEXT_AREA_FILTER_ERROR 27 +#define EVENT_TEXT_AREA_WILL_INSERT 28 +#define EVENT_TEXT_AREA_WILL_DELETE 29 +#define EVENT_TEXT_AREA_WILL_CHANGE 30 +#define EVENT_TEXT_DETECT_RESULT_UPDATE 31 + +// 处理Span事件 +static void HandleSpanEvent(int32_t eventId) +{ + if (eventId == EVENT_SPAN_LONG_PRESS) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "spanOnLongPress回调函数被执行"); + } +} + +// 处理TextInput事件(1) +static void HandleTextInputEvent1(int32_t eventId) +{ + switch (eventId) { + case EVENT_TEXT_INPUT_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnChange回调函数被执行"); + break; + case EVENT_TEXT_INPUT_SUBMIT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnSubmit回调函数被执行"); + break; + case EVENT_TEXT_INPUT_CUT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnCut回调函数被执行"); + break; + case EVENT_TEXT_INPUT_PASTE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnPaste回调函数被执行"); + break; + case EVENT_TEXT_INPUT_SELECTION_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnSelectionChange回调函数被执行"); + break; + case EVENT_TEXT_INPUT_EDIT_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnEditChange回调函数被执行"); + break; + case EVENT_TEXT_INPUT_CONTENT_SIZE_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnContentSizeChange回调函数被执行"); + break; + default: + break; + } +} + +// 处理TextInput事件(2) +static void HandleTextInputEvent2(int32_t eventId) +{ + switch (eventId) { + case EVENT_TEXT_INPUT_FILTER_ERROR: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnInputFiterError回调函数被执行"); + break; + case EVENT_TEXT_INPUT_CONTENT_SCROLL: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnontentScroll回调函数被执行"); + break; + case EVENT_TEXT_INPUT_WILL_INSERT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnWillInsert回调函数被执行"); + break; + case EVENT_TEXT_INPUT_DID_INSERT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnDidInsert回调函数被执行"); + break; + case EVENT_TEXT_INPUT_WILL_DELETE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnWillDelete回调函数被执行"); + break; + case EVENT_TEXT_INPUT_DID_DELETE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnDidDelete回调函数被执行"); + break; + case EVENT_TEXT_INPUT_CHANGE_PREVIEW: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnChangeWithPreviewText回调函数被执行"); + break; + case EVENT_TEXT_INPUT_WILL_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textInputOnWillChange回调函数被执行"); + break; + default: + break; + } +} + +// 处理TextArea事件(1) +static void HandleTextAreaEvent1(int32_t eventId) +{ + switch (eventId) { + case EVENT_TEXT_AREA_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnChange回调函数被执行"); + break; + case EVENT_TEXT_AREA_PASTE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnPaste回调函数被执行"); + break; + case EVENT_TEXT_AREA_SELECTION_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnTextSelectionChange回调函数被执行"); + break; + case EVENT_TEXT_AREA_CONTENT_SCROLL: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnContentScroll回调函数被执行"); + break; + case EVENT_TEXT_AREA_EDIT_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnEditChange回调函数被执行"); + break; + case EVENT_TEXT_AREA_SUBMIT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnSubmit回调函数被执行"); + break; + case EVENT_TEXT_AREA_CONTENT_SIZE_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnContentSizeChange回调函数被执行"); + break; + default: + break; + } +} + +// 处理TextArea事件(2) +static void HandleTextAreaEvent2(int32_t eventId) +{ + switch (eventId) { + case EVENT_TEXT_AREA_DID_INSERT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnDidInsert回调函数被执行"); + break; + case EVENT_TEXT_AREA_DID_DELETE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnDidDelete回调函数被执行"); + break; + case EVENT_TEXT_AREA_CHANGE_PREVIEW: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnChangeWithPreviewText回调函数被执行"); + break; + case EVENT_TEXT_AREA_FILTER_ERROR: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnInputFilterError回调函数被执行"); + break; + case EVENT_TEXT_AREA_WILL_INSERT: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnWillInsert回调函数被执行"); + break; + case EVENT_TEXT_AREA_WILL_DELETE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnWillDelete回调函数被执行"); + break; + case EVENT_TEXT_AREA_WILL_CHANGE: + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textAreaOnWillChange回调函数被执行"); + break; + default: + break; + } +} + +// 处理其他事件 +static void HandleOtherEvent(int32_t eventId) +{ + if (eventId == EVENT_TEXT_DETECT_RESULT_UPDATE) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textOnDetectResultUpdate回调函数被执行"); + } +} + +// 主事件处理函数 +static void OnEventReceive(ArkUI_NodeEvent *event) +{ + if (event == nullptr) { + return; + } + // 处理字符串异步事件 + ArkUI_StringAsyncEvent *asyncEvent = OH_ArkUI_NodeEvent_GetStringAsyncEvent(event); + if (asyncEvent != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "text组件事件数据获取成功"); + } + // 处理文本变化事件 + ArkUI_TextChangeEvent *textChangeEvent = OH_ArkUI_NodeEvent_GetTextChangeEvent(event); + if (asyncEvent != nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "textChange组件事件数据获取成功"); + } + // 处理字符串值 + char *eventStr = nullptr; + int32_t strSize = VALUE_0; + int32_t ret = OH_ArkUI_NodeEvent_GetStringValue(event, VALUE_0, &eventStr, &strSize); + if (ret == ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "text组件事件数据获取成功"); + } + // 分发事件处理 + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + HandleSpanEvent(eventId); + HandleTextInputEvent1(eventId); + HandleTextInputEvent2(eventId); + HandleTextAreaEvent1(eventId); + HandleTextAreaEvent2(eventId); + HandleOtherEvent(eventId); +} + +void setText1(ArkUI_NodeHandle &text) +{ + ArkUI_NumberValue textWidth[] = {{.f32 = VALUE_380}}; + ArkUI_AttributeItem textWidthItem = {.value = textWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_WIDTH, &textWidthItem); + ArkUI_NumberValue textHeight[] = {{.f32 = VALUE_100}}; + ArkUI_AttributeItem textHeightItem = {.value = textHeight, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_HEIGHT, &textHeightItem); + if (text != nullptr) { + // span仅作为text的子组件形式展示 + ArkUI_NodeHandle span = Manager::nodeAPI_->createNode(ARKUI_NODE_SPAN); + const char *spanContent = "This is a span"; + ArkUI_AttributeItem spanContentItem = {.string = spanContent}; + Manager::nodeAPI_->setAttribute(span, NODE_SPAN_CONTENT, &spanContentItem); + if (span != nullptr) { + // 设置Span背景样式 + ArkUI_NumberValue spanBackground[] = { + {.u32 = 0xFFFF0000}, // 背景颜色 + {.f32 = 5.0f}, // 左上角半径 + {.f32 = 5.0f}, // 右上角半径 + {.f32 = 5.0f}, // 左下角半径 + {.f32 = 5.0f} // 右下角半径 + }; + ArkUI_AttributeItem spanBackgroundItem = {.value = spanBackground, .size = VALUE_5}; + Manager::nodeAPI_->setAttribute(span, NODE_SPAN_TEXT_BACKGROUND_STYLE, &spanBackgroundItem); + + // 文本基线的偏移量属性 + ArkUI_NumberValue baselineOffsetVal = {.f32 = VALUE_10}; + ArkUI_AttributeItem baselineOffsetItem = {&baselineOffsetVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_SPAN_BASELINE_OFFSET, &baselineOffsetItem); + // 长按span组件,触发回调 + Manager::nodeAPI_->registerNodeEvent(span, NODE_TEXT_SPAN_ON_LONG_PRESS, EVENT_SPAN_LONG_PRESS, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + } + Manager::nodeAPI_->addChild(text, span); + } +} + +static void setTextInput1Base(ArkUI_NodeHandle &textInput1) +{ + // 控制单行文本输入框编辑态属性 + ArkUI_NumberValue inputEditing = {.i32 = true}; + ArkUI_AttributeItem inputEditingItem = {&inputEditing, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_EDITING, &inputEditingItem); + // 单行文本设置文本选中并高亮的区域 + ArkUI_NumberValue inputTextSelection[] = {{.i32 = VALUE_0}, {.i32 = VALUE_10}}; + ArkUI_AttributeItem inputTextSelectionItem = {inputTextSelection, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT_SELECTION, &inputTextSelectionItem); + // 设置是否启用自动填充 + ArkUI_NumberValue enableAutoFill = {.i32 = false}; + ArkUI_AttributeItem enableAutoFillItem = {&enableAutoFill, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_ENABLE_AUTO_FILL, &enableAutoFillItem); + // 设置是否启用自动填充动效 + ArkUI_NumberValue enableFillAnimation = {.i32 = false}; + ArkUI_AttributeItem enableFillAnimationItem = {&enableFillAnimation, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_ENABLE_FILL_ANIMATION, &enableFillAnimationItem); + // 自动填充类型(密码保险箱支持) + ArkUI_NumberValue inputContentType = {.i32 = ARKUI_TEXTINPUT_CONTENT_TYPE_PASSWORD}; + ArkUI_AttributeItem inputContentTypeItem = {&inputContentType, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_CONTENT_TYPE, &inputContentTypeItem); + // 定义生成密码规则 + const char *passwordRulesVal = "这是密码规则"; + ArkUI_AttributeItem passwordRulesItem = {.string = passwordRulesVal}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_PASSWORD_RULES, &passwordRulesItem); + // 设置初始状态,是否全选文本 + ArkUI_NumberValue inputSelectAll = {.i32 = false}; + ArkUI_AttributeItem inputSelectAllItem = {&inputSelectAll, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_SELECT_ALL, &inputSelectAllItem); +} + +// 设置TextInput1的基础属性(提示文本、光标、字体、输入模式等) +static void SetTextInput1BaseAttrs(ArkUI_NodeHandle &textInput1) +{ + // 默认提示文本内容 + const char *inputPlaceHolederVal = "please info password"; + ArkUI_AttributeItem placeHolederItem = {.string = inputPlaceHolederVal}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_PLACEHOLDER, &placeHolederItem); + // 光标颜色属性 + ArkUI_NumberValue caretColor = {.u32 = 0xFFFF0000}; + ArkUI_AttributeItem caretColorItem = {&caretColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_CARET_COLOR, &caretColorItem); + // 光标风格属性,光标宽度 + ArkUI_NumberValue caretStyle = {.f32 = VALUE_2}; + ArkUI_AttributeItem caretStyleItem = {&caretStyle, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_CARET_STYLE, &caretStyleItem); + // 无输入时默认字体颜色属性 + ArkUI_NumberValue placeholderColor = {.u32 = 0xFFFF0000}; + ArkUI_AttributeItem placeholderColorItem = {&placeholderColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_PLACEHOLDER_COLOR, &placeholderColorItem); + // 无输入时默认字体配置(斜体,字体大小 20) + ArkUI_NumberValue placeholderFont[] = {{.f32 = VALUE_20}, {.i32 = ARKUI_FONT_STYLE_ITALIC}}; + ArkUI_AttributeItem placeholderFontItem = {placeholderFont, VALUE_2}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_PLACEHOLDER_FONT, &placeholderFontItem); + // 聚焦是否绑定输入法 + ArkUI_NumberValue enableKeyboard = {.i32 = false}; + ArkUI_AttributeItem enableKeyboardItem = {&enableKeyboard, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &enableKeyboardItem); + // 输入框类型属性(密码输入模式) + ArkUI_NumberValue inputTyple = {.i32 = ARKUI_TEXTINPUT_TYPE_PASSWORD}; + ArkUI_AttributeItem inputTypleItem = {&inputTyple, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_TYPE, &inputTypleItem); + // 密码输入模式是否显示末尾图标属性 + ArkUI_NumberValue showPasswordIcon = {.i32 = false}; + ArkUI_AttributeItem showPasswordIconItem = {&showPasswordIcon, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_SHOW_PASSWORD_ICON, &showPasswordIconItem); + // 输入框文本被选中时的背景色 + ArkUI_NumberValue selectedBackgroundColor = {.u32 = 0xFFFFFF00}; + ArkUI_AttributeItem selectedBackgroundColorItem = {&selectedBackgroundColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput1, NODE_TEXT_INPUT_SELECTED_BACKGROUND_COLOR, + &selectedBackgroundColorItem); + setTextInput1Base(textInput1); +} + +// 注册 TextInput1 的所有事件 +static void RegisterTextInput1Events(ArkUI_NodeHandle &textInput1) +{ + // TextInput 输入内容发生变化时触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_CHANGE, EVENT_TEXT_INPUT_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // TextInput 按下输入法回车键触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_SUBMIT, EVENT_TEXT_INPUT_SUBMIT, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 长按弹出剪贴板后点击剪切触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_CUT, EVENT_TEXT_INPUT_CUT, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 长按弹出剪贴板后点击粘贴触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_PASTE, EVENT_TEXT_INPUT_PASTE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 文本选择变化触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_TEXT_SELECTION_CHANGE, + EVENT_TEXT_INPUT_SELECTION_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 输入状态变化触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_EDIT_CHANGE, EVENT_TEXT_INPUT_EDIT_CHANGE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 文本内容滚动触发 + Manager::nodeAPI_->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_CONTENT_SCROLL, EVENT_TEXT_INPUT_CONTENT_SCROLL, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +void setTextInput1(ArkUI_NodeHandle &textInput1) +{ + SetTextInput1BaseAttrs(textInput1); + RegisterTextInput1Events(textInput1); +} + +static void setTextInputVal(ArkUI_NodeHandle &textInput2) +{ + // 设置输入框风格,(内联只支持输入框类型设置为normal) + ArkUI_NumberValue textInputStyle = {.i32 = ARKUI_TEXTINPUT_STYLE_INLINE}; + ArkUI_AttributeItem textInputStyleItem = {&textInputStyle, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_STYLE, &textInputStyleItem); + + // 单行文本输入框的默认文本内容属性 + ArkUI_AttributeItem textInputText = {.string = "this is textinput 2"}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_TEXT, &textInputText); + + // 设置长按、双击输入框或者右键输入框时,是否不弹出文本选择菜单(true是隐藏,false是显示,默认值是false) + ArkUI_NumberValue selelctionMenuHidden = {.i32 = true}; + ArkUI_AttributeItem selelctionMenuHiddenItem = {&selelctionMenuHidden, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_SELECTION_MENU_HIDDEN, &selelctionMenuHiddenItem); + + // 回车键类型 + ArkUI_NumberValue enterKeyType = {.i32 = ARKUI_ENTER_KEY_TYPE_SEND}; + ArkUI_AttributeItem enterKeyTypeItem = {&enterKeyType, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_ENTER_KEY_TYPE, &enterKeyTypeItem); + + // 是否弹出键盘(默认true,false将不弹出键盘) + ArkUI_NumberValue showKeyboardOnFocus = {.i32 = true}; + ArkUI_AttributeItem showKeyboardOnFocusItem = {&showKeyboardOnFocus, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &showKeyboardOnFocusItem); + + // 调整textInput组件之间的字符间距 + ArkUI_NumberValue inputLetterSpacing = {.f32 = VALUE_10}; + ArkUI_AttributeItem inputLetterSpacingItem = {&inputLetterSpacing, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_LETTER_SPACING, &inputLetterSpacingItem); + + // 是否开启输入预上屏 + ArkUI_NumberValue enablePreviewText = {.i32 = false}; + ArkUI_AttributeItem enablePreviewTextItem = {&enablePreviewText, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_ENABLE_PREVIEW_TEXT, &enablePreviewTextItem); + + // 设置文本将行间距平分至行的顶部与底部 + ArkUI_NumberValue inputHalfLeading = {.i32 = true}; + ArkUI_AttributeItem inputHalfLeadingItem = {&inputHalfLeading, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_HALF_LEADING, &inputHalfLeadingItem); + + // 设置输入框拉起的键盘样式 + ArkUI_NumberValue keyboardAppenrance = {.i32 = ARKUI_KEYBOARD_APPEARANCE_DARK_IMMERSIVE}; + ArkUI_AttributeItem keyboardAppenranceItem = {&keyboardAppenrance, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_KEYBOARD_APPEARANCE, &keyboardAppenranceItem); + + // 设置输入框文本的高度(设置为undefined时,文本的高度设置为5) + ArkUI_NumberValue inputLineHeight = {.i32 = VALUE_30}; + ArkUI_AttributeItem inputLineHeightItem = {&inputLineHeight, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_LINE_HEIGHT, &inputLineHeightItem); +} + +void setTextInput2(ArkUI_NodeHandle &textInput2) +{ + setTextInputVal(textInput2); + // 获取已编辑文本内容区域相对组件的位置和大小 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", + "NODE_TEXT_INPUT_CARET_OFFSET:%{public}f、%{public}f、%{public}f、%{public}f", + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_RECT)->value[VALUE_0].f32, + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_RECT)->value[VALUE_1].f32, + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_RECT)->value[VALUE_2].f32, + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_RECT)->value[VALUE_3].f32); + + // 获取已编辑内容的行数 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", "NODE_TEXT_INPUT_CONTENT_LINE_COUNT:%{public}d、%{public}d", + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_LINE_COUNT)->value[VALUE_0].i32, + Manager::nodeAPI_->getAttribute(textInput2, NODE_TEXT_INPUT_CONTENT_LINE_COUNT)->value[VALUE_1].i32); + + // TextInput输入内容发生变化时触发该事件 + Manager::nodeAPI_->registerNodeEvent(textInput2, NODE_TEXT_INPUT_ON_CONTENT_SIZE_CHANGE, + EVENT_TEXT_INPUT_CONTENT_SIZE_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在输入完成时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput2, NODE_TEXT_INPUT_ON_DID_INSERT, EVENT_TEXT_INPUT_DID_INSERT, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在删除完成时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput2, NODE_TEXT_INPUT_ON_DID_DELETE, EVENT_TEXT_INPUT_DID_DELETE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义TextInput组件在内容改变时(包含预上屏内容),触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput2, NODE_TEXT_INPUT_ON_CHANGE_WITH_PREVIEW_TEXT, + EVENT_TEXT_INPUT_CHANGE_PREVIEW, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在删除完成时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput2, NODE_TEXT_INPUT_ON_WILL_CHANGE, EVENT_TEXT_INPUT_WILL_CHANGE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +void setTextInput3(ArkUI_NodeHandle &textInput3) +{ + // 输入框下划线 + ArkUI_NumberValue showUnderLine = {.i32 = true}; + ArkUI_AttributeItem showUnderLineItem = {&showUnderLine, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_SHOW_UNDERLINE, &showUnderLineItem); + + // 设置输入框最大文本数属性 + ArkUI_NumberValue maxLength = {.i32 = VALUE_10}; + ArkUI_AttributeItem maxLengthItem = {&maxLength, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_MAX_LENGTH, &maxLengthItem); + + // 单行文本右侧清除按钮样式 + ArkUI_NumberValue cancelButton[] = {{.i32 = ARKUI_CANCELBUTTON_STYLE_CONSTANT}}; + ArkUI_AttributeItem cancelButtonItem = {cancelButton, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_CANCEL_BUTTON, &cancelButtonItem); + + // 开启下划线时,配置下划线的颜色 + ArkUI_NumberValue underlineColor[] = { + {.u32 = 0xFFFF0000}, {.u32 = 0xFFFF1493}, {.u32 = 0xFFFFB7C5}, {.u32 = 0xFFFFE4E1}}; + ArkUI_AttributeItem underlineColorItem = {underlineColor, VALUE_4}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_UNDERLINE_COLOR, &underlineColorItem); + + // 通过正则表达式设置输入,支持字符串匹配,例如粘贴 + ArkUI_AttributeItem filterItem = {.string = "a"}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_INPUT_FILTER, &filterItem); + // 设置自定义键盘 + ArkUI_NumberValue inputCustomKeyBoard = {.i32 = false}; + ArkUI_AttributeItem inputCustomKeyBoardItem = {&inputCustomKeyBoard, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &inputCustomKeyBoardItem); + + // 断行规则:CJK任意断行(ARKUI_WORD_BREAK_NORMAL) + ArkUI_NumberValue wordBreakVal = {.i32 = ARKUI_WORD_BREAK_NORMAL}; + ArkUI_AttributeItem wordBreakItem = {&wordBreakVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_WORD_BREAK, &wordBreakItem); + + // 设置输入框在submit状态下,触发回车键是否失焦 + ArkUI_NumberValue blurOrSubmit = {.i32 = false}; + ArkUI_AttributeItem blurOrSubmitItem = {&blurOrSubmit, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_BLUR_ON_SUBMIT, &blurOrSubmitItem); + + // 定义在将要输入时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput3, NODE_TEXT_INPUT_ON_WILL_INSERT, EVENT_TEXT_INPUT_WILL_INSERT, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在将要删除时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textInput3, NODE_TEXT_INPUT_ON_WILL_DELETE, EVENT_TEXT_INPUT_WILL_DELETE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 设置光标所在位置 + ArkUI_NumberValue textInputCaretOffset = {.i32 = VALUE_5}; + ArkUI_AttributeItem textInputCaretOffsetItem = {&textInputCaretOffset, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput3, NODE_TEXT_INPUT_CARET_OFFSET, &textInputCaretOffsetItem); + + // 获取已编辑内容的行数 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", "NODE_TEXT_AREA_CONTENT_LINE_COUNT:%{public}d", + Manager::nodeAPI_->getAttribute(textInput3, NODE_TEXT_INPUT_CONTENT_LINE_COUNT)->value[VALUE_0].i32); + + // 设置NODE_TEXT_INPUT_INPUT_FILTER,正则匹配失败时触发。触发该事件的条件:正则匹配失败时 + Manager::nodeAPI_->registerNodeEvent(textInput3, NODE_TEXT_INPUT_ON_INPUT_FILTER_ERROR, + EVENT_TEXT_INPUT_FILTER_ERROR, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +static void setTextArea1Val(ArkUI_NodeHandle &textArea1) +{ + // 多行文本输入框的默认提示文本内容属性 + const char *textAreaPlaceholder = "this is textArea1"; + ArkUI_AttributeItem textAreaPlaceholderItem = {.string = textAreaPlaceholder}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_PLACEHOLDER, &textAreaPlaceholderItem); + + // 输入框支持的最大文本数属性 + ArkUI_NumberValue textAreaMaxLength = {.i32 = VALUE_11}; + ArkUI_AttributeItem textAreaMaxLengthItem = {&textAreaMaxLength, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_MAX_LENGTH, &textAreaMaxLengthItem); + + // 无输入时默认提示文本的颜色属性 + ArkUI_NumberValue textAreaPlaceholederColor = {.u32 = 0xFFFFC0CB}; + ArkUI_AttributeItem textAreaPlaceholederColorItem = {&textAreaPlaceholederColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_PLACEHOLDER_COLOR, &textAreaPlaceholederColorItem); + + // 光标颜色属性 + ArkUI_NumberValue textAreaCaretColor = {.u32 = 0xFFFFE4E1}; + ArkUI_AttributeItem textAreaCaretColorItem = {&textAreaCaretColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_CARET_COLOR, &textAreaCaretColorItem); + + // 控制多行文本输入框编辑态属性 + ArkUI_NumberValue textAreaEditing = {.i32 = true}; + ArkUI_AttributeItem textAreaEditingItem = {&textAreaEditing, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_EDITING, &textAreaEditingItem); + + // 输入框的类型属性 + ArkUI_NumberValue textAreaType = {.i32 = ARKUI_TEXTAREA_TYPE_NUMBER}; + ArkUI_AttributeItem textAreaTypeItem = {&textAreaType, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_TYPE, &textAreaTypeItem); + + // 设置输入的字符数超过阈值时是否显示计数器,超出阈值高亮边框 + ArkUI_NumberValue textAreaShowCounter[] = {{.i32 = true}, {.f32 = VALUE_100}, {.i32 = true}}; + ArkUI_AttributeItem textAreaShowCounterItem = {textAreaShowCounter, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_SHOW_COUNTER, &textAreaShowCounterItem); + + // 设置长按、双击输入框或者右键输入框时,是否不弹出文本选择菜单 + ArkUI_NumberValue textAreaSelectionMenuHidden = {.i32 = true}; + ArkUI_AttributeItem textAreaSelectionMenuHiddenItem = {&textAreaSelectionMenuHidden, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_SELECTION_MENU_HIDDEN, &textAreaSelectionMenuHiddenItem); + + // 设置文本选中底板颜色 + ArkUI_NumberValue textAreaSelectedBackgroundColor = {.u32 = 0xFFFF0000}; + ArkUI_AttributeItem textAreaSelectedBackgroundColorItem = {&textAreaSelectedBackgroundColor, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_SELECTED_BACKGROUND_COLOR, + &textAreaSelectedBackgroundColorItem); + + // 回车键类型 + ArkUI_NumberValue enterKeyType = {.i32 = ARKUI_ENTER_KEY_TYPE_SEND}; + ArkUI_AttributeItem enterKeyTypeItem = {&enterKeyType, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_ENTER_KEY_TYPE, &enterKeyTypeItem); + + // 是否弹出键盘(默认true,false将不弹出键盘) + ArkUI_NumberValue showKeyboardOnFocus = {.i32 = true}; + ArkUI_AttributeItem showKeyboardOnFocusItem = {&showKeyboardOnFocus, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &showKeyboardOnFocusItem); + + // 设置文本将行间距平分至行的顶部与底部 + ArkUI_NumberValue areaHalfLeading = {.i32 = true}; + ArkUI_AttributeItem areaHalfLeadingItem = {&areaHalfLeading, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_HALF_LEADING, &areaHalfLeadingItem); + + // 设置节点的最小行数 + ArkUI_NumberValue textAreaMinLines = {.i32 = VALUE_1}; + ArkUI_AttributeItem textAreaMinLinesItem = {&textAreaMinLines, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_MIN_LINES, &textAreaMinLinesItem); +} + +void setTextArea1(ArkUI_NodeHandle &textArea1) +{ + setTextArea1Val(textArea1); + // 设置输入框文本的高度 + ArkUI_NumberValue textAreaLineHeight = {.i32 = VALUE_30}; + ArkUI_AttributeItem textAreaLineHeightItem = {&textAreaLineHeight, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_LINE_HEIGHT, &textAreaLineHeightItem); + + // 组件在获焦状态下,调用该接口设置文本选择区域并高亮显示,且只有在selectionStart小于selectionEnd时,文字才会被选取、高亮显示。 + ArkUI_NumberValue textAreaSelection[] = {{.i32 = VALUE_2}, {.i32 = VALUE_8}}; + ArkUI_AttributeItem textAreaSelectionItem = {textAreaSelection, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_TEXT_SELECTION, &textAreaSelectionItem); + + // 设置是否启用自动填充 + ArkUI_NumberValue textAreaEnableAutoFill = {.i32 = false}; + ArkUI_AttributeItem textAreaEnableAutoFillItem = {&textAreaEnableAutoFill, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_ENABLE_AUTO_FILL, &textAreaEnableAutoFillItem); + + // NODE_TEXT_AREA_CONTENT_TYPE + ArkUI_NumberValue textAreaContentType = {.i32 = ARKUI_TEXTINPUT_CONTENT_TYPE_USER_NAME}; + ArkUI_AttributeItem textAreaContentTypeItem = {&textAreaContentType, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea1, NODE_TEXT_AREA_CONTENT_TYPE, &textAreaContentTypeItem); + + // 获取光标所在位置信息 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", "NODE_TEXT_AREA_CARET_OFFSET:%{public}d", + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET)->value[VALUE_0].i32); + + // 获取已编辑文本内容区域相对组件的位置和大小 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", + "NODE_TEXT_AREA_CARET_OFFSET:%{public}f、%{public}f、%{public}f、%{public}f", + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_RECT)->value[VALUE_0].f32, + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_RECT)->value[VALUE_1].f32, + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_RECT)->value[VALUE_2].f32, + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_RECT)->value[VALUE_3].f32); + + // 获取已编辑内容的行数 + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", "NODE_TEXT_AREA_CONTENT_LINE_COUNT:%{public}d、%{public}d", + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_LINE_COUNT)->value[VALUE_0].i32, + Manager::nodeAPI_->getAttribute(textArea1, NODE_TEXT_AREA_CONTENT_LINE_COUNT)->value[VALUE_1].i32); + + // 输入内容发生变化时,触发该回调 + Manager::nodeAPI_->registerNodeEvent(textArea1, NODE_TEXT_AREA_ON_CHANGE, EVENT_TEXT_AREA_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +void setTextArea2(ArkUI_NodeHandle &textArea2) +{ + // 多行文本输入框的默认提示文本内容属性 + const char *textAreaText = "这里是默认文本内容"; + ArkUI_AttributeItem textAreaTextItem = {.string = textAreaText}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_PLACEHOLDER, &textAreaTextItem); + + // 设置输入框文本的行间距 + ArkUI_NumberValue textAreaLineSpacing = {.i32 = VALUE_10}; + ArkUI_AttributeItem textAreaLineSpacingItem = {&textAreaLineSpacing, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_LINE_SPACING, &textAreaLineSpacingItem); + + // 设置TextArea组件是否开启输入预上屏 + ArkUI_NumberValue enablePrevireText = {.i32 = ARKUI_ENTER_KEY_TYPE_SEND}; + ArkUI_AttributeItem enablePrevireTextItem = {&enablePrevireText, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_ENABLE_PREVIEW_TEXT, &enablePrevireTextItem); + + // 设置输入框拉起的键盘样式 + ArkUI_NumberValue keyboardAppenrance = {.i32 = ARKUI_KEYBOARD_APPEARANCE_DARK_IMMERSIVE}; + ArkUI_AttributeItem keyboardAppenranceItem = {&keyboardAppenrance, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_KEYBOARD_APPEARANCE, &keyboardAppenranceItem); + + // 设置输入框文本的行间距 + ArkUI_NumberValue textAreaLetterSpacing = {.i32 = VALUE_10}; + ArkUI_AttributeItem textAreaLetterSpacingItem = {&textAreaLetterSpacing, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_LETTER_SPACING, &textAreaLetterSpacingItem); + + // 设置输入框内联模式编辑态时文本可显示的最大行数 + ArkUI_NumberValue textAreaMaxLines = {.i32 = VALUE_8}; + ArkUI_AttributeItem textAreaMaxLinesItem = {&textAreaMaxLines, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_MAX_LINES, &textAreaMaxLinesItem); + + // 设置输入框在submit状态下,触发回车键是否失焦 + ArkUI_NumberValue blurOrSubmit = {.i32 = false}; + ArkUI_AttributeItem blurOrSubmitItem = {&blurOrSubmit, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_BLUR_ON_SUBMIT, &blurOrSubmitItem); + + // 通过正则表达式设置输入,支持字符串匹配,例如粘贴 + ArkUI_AttributeItem filterItem = {.string = "a"}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_INPUT_FILTER, &filterItem); + + // 设置TextArea通过点击以外的方式获焦时,是否绑定输入法 + ArkUI_NumberValue keyboardOnFocus = {.i32 = false}; + ArkUI_AttributeItem keyboardOnFocusItem = {&keyboardOnFocus, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea2, NODE_TEXT_AREA_ENABLE_KEYBOARD_ON_FOCUS, &keyboardOnFocusItem); + + // 设置NODE_TEXT_AREA_INPUT_FILTER,正则匹配失败时触发。触发该事件的条件:正则匹配失败时 + Manager::nodeAPI_->registerNodeEvent(textArea2, NODE_TEXT_AREA_ON_INPUT_FILTER_ERROR, EVENT_TEXT_AREA_FILTER_ERROR, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在将要输入时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea2, NODE_TEXT_AREA_ON_WILL_INSERT, EVENT_TEXT_AREA_WILL_INSERT, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义在将要删除时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea2, NODE_TEXT_AREA_ON_WILL_DELETE, EVENT_TEXT_AREA_WILL_DELETE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + + // 定义TextArea组件在内容将要改变时(包含预上屏内容),触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea2, NODE_TEXT_AREA_ON_WILL_CHANGE, EVENT_TEXT_AREA_WILL_CHANGE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +static void onFontStyleChange(ArkUI_SystemFontStyleEvent *event, void *userData) +{ + float fontSizeScale = OH_ArkUI_SystemFontStyleEvent_GetFontSizeScale(event); + float fontWeightScale = OH_ArkUI_SystemFontStyleEvent_GetFontWeightScale(event); + ArkUI_NodeHandle textNode = static_cast(userData); +} + +void setText2(ArkUI_NodeHandle &text2) +{ + const char *textContent = "this is text 2 this is text 2 this is text 2!!!! "; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(text2, NODE_TEXT_CONTENT, &contentItem); + // 设置文本样式 + ArkUI_NumberValue fontSize[] = {{.f32 = VALUE_28}}; + ArkUI_AttributeItem fontSizeItem = {.value = fontSize, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_FONT_SIZE, &fontSizeItem); + ArkUI_NumberValue fontColor = {.u32 = 0xFFFF0000}; + ArkUI_AttributeItem fontColorItem = {.value = &fontColor, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_FONT_COLOR, &fontColorItem); + + // 字体样式:斜体样式(ARKUI_FONT_STYLE_ITALIC) + ArkUI_NumberValue fontStyleVal = {.i32 = ARKUI_FONT_STYLE_ITALIC}; + ArkUI_AttributeItem fontStyleItem = {&fontStyleVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_FONT_STYLE, &fontStyleItem); + + // 文本字符间距 + ArkUI_NumberValue letterSpaceVal = {.f32 = VALUE_10}; + ArkUI_AttributeItem letterSpaceItem = {&letterSpaceVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_TEXT_LETTER_SPACING, &letterSpaceItem); + // 文本最大行数 + ArkUI_NumberValue maxLinesVal = {.i32 = VALUE_1}; + ArkUI_AttributeItem maxLinesItem = {&maxLinesVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_TEXT_LETTER_SPACING, &maxLinesItem); + + // 最小显示字号 + ArkUI_NumberValue minFontSizeVal = {.i32 = ARKUI_COPY_OPTIONS_NONE}; + ArkUI_AttributeItem minFontSizeItem = {&minFontSizeVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_TEXT_COPY_OPTION, &minFontSizeItem); + + // 文本溢出:跑马灯(ARKUI_TEXT_OVERFLOW_MARQUEE) + ArkUI_NumberValue overflowVal = {.i32 = ARKUI_TEXT_OVERFLOW_MARQUEE}; + ArkUI_AttributeItem overflowItem = {&overflowVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text2, NODE_TEXT_OVERFLOW, &overflowItem); + + int32_t ret = OH_ArkUI_RegisterSystemFontStyleChangeEvent(text2, text2, &onFontStyleChange); + if (ret == ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "字体变更回调"); + } +} + +void setText3(ArkUI_NodeHandle &text3) +{ + const char *textContent = + "this is text 3 this is text 3 this is text 3!!!!this is text 3 this is text 3 this is text 3!!!! "; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_CONTENT, &contentItem); + + // 自适应高度:MaxLines优先(ARKUI_TEXT_HEIGHT_ADAPTIVE_POLICY_MAX_LINES_FIRST) + ArkUI_NumberValue adaptPolicyVal = {.i32 = ARKUI_TEXT_HEIGHT_ADAPTIVE_POLICY_MAX_LINES_FIRST}; + ArkUI_AttributeItem adaptPolicyItem = {&adaptPolicyVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_HEIGHT_ADAPTIVE_POLICY, &adaptPolicyItem); + + // 水平对齐:首部对齐(ARKUI_TEXT_ALIGNMENT_START) + ArkUI_NumberValue hAlignVal = {.i32 = ARKUI_TEXT_ALIGNMENT_START}; + ArkUI_AttributeItem hAlignItem = {&hAlignVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_ALIGN, &hAlignItem); + + // 首行缩进 + ArkUI_NumberValue indentVal = {.f32 = VALUE_30}; + ArkUI_AttributeItem indentItem = {&indentVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_INDENT, &indentItem); + + // 省略位置:行首省略(ARKUI_ELLIPSIS_MODE_START) + ArkUI_NumberValue ellipsisVal = {.i32 = ARKUI_ELLIPSIS_MODE_START}; + ArkUI_AttributeItem ellipsisItem = {&ellipsisVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_ELLIPSIS_MODE, &ellipsisItem); + + // 复制粘贴:不支持复制(ARKUI_COPY_OPTIONS_NONE / ARKUI_TEXT_COPY_OPTIONS_NONE) + ArkUI_NumberValue copyOptVal = {.i32 = ARKUI_COPY_OPTIONS_NONE}; + ArkUI_AttributeItem copyOptItem = {©OptVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_COPY_OPTION, ©OptItem); + + // 断行规则:CJK任意断行(ARKUI_WORD_BREAK_NORMAL) + ArkUI_NumberValue wordBreakVal = {.i32 = ARKUI_WORD_BREAK_NORMAL}; + ArkUI_AttributeItem wordBreakItem = {&wordBreakVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_WORD_BREAK, &wordBreakItem); + + // 文本行间距 + ArkUI_NumberValue lineSpaceVal = {.f32 = VALUE_10}; + ArkUI_AttributeItem lineSpaceItem = {&lineSpaceVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_LINE_SPACING, &lineSpaceItem); + // 设置文本装饰 + ArkUI_NumberValue textDecoration[] = { + {.i32 = ARKUI_TEXT_DECORATION_TYPE_UNDERLINE}, {.u32 = 0xFFFF0000}, {.i32 = ARKUI_TEXT_DECORATION_STYLE_SOLID}}; + ArkUI_AttributeItem textDecorationItem = {.value = textDecoration, .size = VALUE_3}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_DECORATION, &textDecorationItem); + + // 设置text样式 + ArkUI_NumberValue textFont[] = { + {.f32 = VALUE_5}, {.i32 = ARKUI_FONT_WEIGHT_W600}, {.i32 = ARKUI_FONT_STYLE_NORMAL}}; + ArkUI_AttributeItem textFontItem = {textFont, VALUE_3}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_WORD_BREAK, &textFontItem); + // 文本大小写属性 + ArkUI_NumberValue textCase = {.i32 = ARKUI_TEXT_CASE_UPPER}; + ArkUI_AttributeItem textCaseItem = {&textCase, VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_CASE, &textCaseItem); + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Manager", "NODE_TEXT_LINE_COUNT :%{public}d", + Manager::nodeAPI_->getAttribute(text3, NODE_TEXT_LINE_COUNT)->value[VALUE_0].i32); + // 设置文本识别 + ArkUI_NumberValue enableDataDetector = {.i32 = true}; + ArkUI_AttributeItem enableDataDetectorItem = {.value = &enableDataDetector, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_ENABLE_DATA_DETECTOR, &enableDataDetectorItem); + ArkUI_NumberValue detectorConfig = {.i32 = ARKUI_TEXT_DATA_DETECTOR_TYPE_PHONE_NUMBER}; + ArkUI_AttributeItem detectorConfigItem = {.value = &detectorConfig, .size = VALUE_2}; + Manager::nodeAPI_->setAttribute(text3, NODE_TEXT_ENABLE_DATA_DETECTOR_CONFIG, &detectorConfigItem); + // 文本设置TextDataDetectorConfig且识别成功时,触发onDetectResultUpdate回调 + Manager::nodeAPI_->registerNodeEvent(text3, NODE_TEXT_ON_DETECT_RESULT_UPDATE, EVENT_TEXT_DETECT_RESULT_UPDATE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); +} + +void setText4(ArkUI_NodeHandle &text4) +{ + const char *textContent = "这里是第四个文本"; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(text4, NODE_TEXT_CONTENT, &contentItem); + + // 设置文本行高 + ArkUI_NumberValue lineHeight = {.f32 = VALUE_50}; + ArkUI_AttributeItem lineHeightItem = {&lineHeight, VALUE_1}; + Manager::nodeAPI_->setAttribute(text4, NODE_TEXT_LINE_HEIGHT, &lineHeightItem); + + // 文本基线的偏移量属性 + ArkUI_NumberValue baselineOffset = {.f32 = VALUE_50}; + ArkUI_AttributeItem baselineOffsetItem = {&baselineOffset, VALUE_1}; + Manager::nodeAPI_->setAttribute(text4, NODE_TEXT_BASELINE_OFFSET, &baselineOffsetItem); + + // 文字阴影效果属性 + ArkUI_NumberValue textShadow[] = { + {.f32 = VALUE_5}, {.i32 = ARKUI_SHADOW_TYPE_BLUR}, {.u32 = 0xFFFF0000}, {.f32 = VALUE_5}, {.f32 = VALUE_5}}; + ArkUI_AttributeItem textShadowItem = {textShadow, VALUE_5}; + Manager::nodeAPI_->setAttribute(text4, NODE_TEXT_TEXT_SHADOW, &textShadowItem); + + // Text最大显示字号 + ArkUI_NumberValue maxFontSize = {.f32 = VALUE_10}; + ArkUI_AttributeItem maxFontSizeItem = {&maxFontSize, VALUE_1}; + Manager::nodeAPI_->setAttribute(text4, NODE_TEXT_MAX_FONT_SIZE, &maxFontSizeItem); + + // 设置NODE_FONT_FEATURE + ArkUI_AttributeItem fontFeatureItem = {.string = "ss01"}; + Manager::nodeAPI_->setAttribute(text4, NODE_FONT_FEATURE, &fontFeatureItem); + + // Text最大显示字号ARKUI_FONT_WEIGHT_W500 + ArkUI_NumberValue fontWeight = {.i32 = ARKUI_FONT_WEIGHT_W500}; + ArkUI_AttributeItem fontWeightItem = {&fontWeight, VALUE_1}; + Manager::nodeAPI_->setAttribute(text4, NODE_IMMUTABLE_FONT_WEIGHT, &fontWeightItem); + ArkUI_AttributeItem fontfamily = {.string = "字体"}; + Manager::nodeAPI_->setAttribute(text4, NODE_FONT_FAMILY, &fontfamily); +} + +void setText5(ArkUI_NodeHandle &text5) +{ + const char *textContent = "this is text 5"; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(text5, NODE_TEXT_CONTENT, &contentItem); + // 渐变 + ArkUI_NumberValue linearGradient[] = {{.f32 = ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM}, + {.i32 = ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM}, + {.i32 = VALUE_0}}; + ArkUI_AttributeItem linearGradientItem = {linearGradient, VALUE_3}; + Manager::nodeAPI_->setAttribute(text5, NODE_TEXT_LINEAR_GRADIENT, &linearGradientItem); + ArkUI_NumberValue radialGradient[] = {{.f32 = ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM}, + {.i32 = ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM}, + {.i32 = VALUE_0}}; + ArkUI_AttributeItem radialGradientItem = {radialGradient, VALUE_3}; + Manager::nodeAPI_->setAttribute(text5, NODE_TEXT_RADIAL_GRADIENT, &radialGradientItem); +} + +void setTextArea3(ArkUI_NodeHandle &textArea3) +{ + // 多行文本输入框的默认提示文本内容属性 + const char *textAreaText = "触发回调测试"; + ArkUI_AttributeItem textAreaTextItem = {.string = textAreaText}; + Manager::nodeAPI_->setAttribute(textArea3, NODE_TEXT_AREA_PLACEHOLDER, &textAreaTextItem); + // 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发该回调 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_PASTE, EVENT_TEXT_AREA_PASTE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 文本选择的位置发生变化时,触发该回调 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_TEXT_SELECTION_CHANGE, + EVENT_TEXT_AREA_SELECTION_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 文本内容滚动时,触发该回调。触发该事件的条件:文本内容滚动时 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_CONTENT_SCROLL, EVENT_TEXT_AREA_CONTENT_SCROLL, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 输入状态变化时,触发该回调 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_EDIT_CHANGE, EVENT_TEXT_AREA_EDIT_CHANGE, + nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // TextArea按下输入法回车键触发该事件 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_SUBMIT, EVENT_TEXT_AREA_SUBMIT, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // TextArea输入内容发生变化时触发该事件 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_CONTENT_SIZE_CHANGE, + EVENT_TEXT_AREA_CONTENT_SIZE_CHANGE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 定义在输入完成时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_DID_INSERT, EVENT_TEXT_AREA_DID_INSERT, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 定义在删除完成时,触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_DID_DELETE, EVENT_TEXT_AREA_DID_DELETE, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 定义TextArea组件在内容改变时(包含预上屏内容),触发回调的枚举值 + Manager::nodeAPI_->registerNodeEvent(textArea3, NODE_TEXT_AREA_ON_CHANGE_WITH_PREVIEW_TEXT, + EVENT_TEXT_AREA_CHANGE_PREVIEW, nullptr); + Manager::nodeAPI_->registerNodeEventReceiver(&OnEventReceive); + // 设置支持滚动时节点的最大行数 + ArkUI_NumberValue maxLinesWithScroll = {.i32 = VALUE_10}; + ArkUI_AttributeItem maxLinesWithScrollItem = {&maxLinesWithScroll, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea3, NODE_TEXT_AREA_MAX_LINES_WITH_SCROLL, &maxLinesWithScrollItem); +} + +void setAccessibility(ArkUI_NodeHandle &accessibilityText) +{ + ArkUI_AccessibilityValue *accessibilityLabelVal = OH_ArkUI_AccessibilityValue_Create(); + OH_ArkUI_AccessibilityValue_SetText(accessibilityLabelVal, "这里设置了一段无障碍文本"); + const char *a11yItemVal = OH_ArkUI_AccessibilityValue_GetText(accessibilityLabelVal); + ArkUI_AttributeItem a11yItem = {.string = a11yItemVal}; + Manager::nodeAPI_->setAttribute(accessibilityText, NODE_TEXT_CONTENT, &a11yItem); +} + +void setCustom(ArkUI_NodeHandle &customSpan) +{ + Manager::nodeAPI_->registerNodeCustomEvent(customSpan, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, VALUE_1, nullptr); + Manager::nodeAPI_->registerNodeCustomEvent(customSpan, ARKUI_NODE_CUSTOM_EVENT_ON_DRAW, VALUE_1, nullptr); + Manager::nodeAPI_->registerNodeCustomEventReceiver([](ArkUI_NodeCustomEvent *event) { + auto eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "EventID:%{public}d", eventId); + if (eventId == VALUE_0) { + ArkUI_CustomSpanMeasureInfo *measureInfo = OH_ArkUI_CustomSpanMeasureInfo_Create(); + OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo(event, measureInfo); + OH_ArkUI_CustomSpanMeasureInfo_Dispose(measureInfo); + ArkUI_CustomSpanMetrics *customSpanMetrics = OH_ArkUI_CustomSpanMetrics_Create(); + OH_ArkUI_CustomSpanMetrics_SetHeight(customSpanMetrics, 120.0f); + OH_ArkUI_CustomSpanMetrics_SetWidth(customSpanMetrics, 80.0f); + OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics(event, customSpanMetrics); + OH_ArkUI_CustomSpanMetrics_Dispose(customSpanMetrics); + } + if (eventId == VALUE_1) { + auto *layoutConstraint = OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(event); + auto *drawContext = OH_ArkUI_NodeCustomEvent_GetDrawContextInDraw(event); + auto *drawingHandle = reinterpret_cast(OH_ArkUI_DrawContext_GetCanvas(drawContext)); + auto size = OH_ArkUI_DrawContext_GetSize(drawContext); + ArkUI_CustomSpanDrawInfo *customSpanDrawInfo = OH_ArkUI_CustomSpanDrawInfo_Create(); + OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo(event, customSpanDrawInfo); + float optionsX = OH_ArkUI_CustomSpanDrawInfo_GetXOffset(customSpanDrawInfo); + float optionsLineTop = OH_ArkUI_CustomSpanDrawInfo_GetLineTop(customSpanDrawInfo); + float optionsLineBottom = OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(customSpanDrawInfo); + float optionsBaseLine = OH_ArkUI_CustomSpanDrawInfo_GetBaseline(customSpanDrawInfo); + OH_ArkUI_CustomSpanDrawInfo_Dispose(customSpanDrawInfo); + } + }); +} + +void setText6(ArkUI_NodeHandle &text6) +{ + // ImageSpan + ArkUI_NodeHandle imageSpan = Manager::nodeAPI_->createNode(ARKUI_NODE_IMAGE_SPAN); + ArkUI_AttributeItem spanUrl = {.string = "/resources/base/media/background.png"}; + ArkUI_NumberValue widthVal[VALUE_1]{}; + widthVal[VALUE_0].f32 = 100.f; + ArkUI_AttributeItem width = {.value = widthVal, .size = VALUE_1}; + ArkUI_NumberValue heightVal[VALUE_1]{}; + heightVal[VALUE_0].f32 = 100.f; + ArkUI_AttributeItem height = {.value = heightVal, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_WIDTH, &width); + Manager::nodeAPI_->setAttribute(imageSpan, NODE_HEIGHT, &height); + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_SRC, &spanUrl); + // 设置 NODE_IMAGE_SPAN_VERTICAL_ALIGNMENT + ArkUI_NumberValue verticalAlignment = {.i32 = ARKUI_IMAGE_SPAN_ALIGNMENT_BOTTOM}; + ArkUI_AttributeItem verticalAlignmentItem = {&verticalAlignment, VALUE_1}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_VERTICAL_ALIGNMENT, &verticalAlignmentItem); + // imageSpan组件占位图地址属性 + ArkUI_AttributeItem spanAlt = {.string = "/resources/base/media/startIcon.png"}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_ALT, &spanAlt); + // 设置imageSpan组件的基线偏移量属性 + ArkUI_NumberValue baselineOffset = {.f32 = VALUE_10}; + ArkUI_AttributeItem baselineOffsetItem = {&baselineOffset, VALUE_1}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_BASELINE_OFFSET, &baselineOffsetItem); + Manager::nodeAPI_->addChild(text6, imageSpan); +} + +void setText7(ArkUI_NodeHandle &text7) +{ + ArkUI_NodeHandle text = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue textWidth[] = {{.f32 = VALUE_300}}; + ArkUI_AttributeItem textWidthItem = {.value = textWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_WIDTH, &textWidthItem); + ArkUI_NumberValue textHeight[] = {{.f32 = VALUE_30}}; + ArkUI_AttributeItem textHeightItem = {.value = textHeight, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_HEIGHT, &textHeightItem); + ArkUI_NumberValue borderWidth[] = {{.f32 = VALUE_1}}; + ArkUI_AttributeItem borderWidthItem = {.value = borderWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(text, NODE_BORDER_WIDTH, &borderWidthItem); + // OH_Drawing_开头的API是字体引擎提供的,typographyStyle表示段落样式。 + OH_Drawing_TypographyStyle *typographyStyle = OH_Drawing_CreateTypographyStyle(); + OH_Drawing_SetTypographyTextAlign(typographyStyle, OH_Drawing_TextAlign::TEXT_ALIGN_CENTER); + OH_Drawing_SetTypographyTextMaxLines(typographyStyle, VALUE_10); + // 创建 ArkUI_StyledString。 + ArkUI_StyledString *styledString = OH_ArkUI_StyledString_Create(typographyStyle, OH_Drawing_CreateFontCollection()); + // 创建文本样式,设置字体和颜色。 + OH_Drawing_TextStyle *textStyle = OH_Drawing_CreateTextStyle(); + OH_Drawing_SetTextStyleFontSize(textStyle, VALUE_28); + OH_Drawing_SetTextStyleColor(textStyle, OH_Drawing_ColorSetArgb(0xFF, 0x70, 0x70, 0x70)); + // 文本样式的设置顺序push -> add -> pop. + OH_ArkUI_StyledString_PushTextStyle(styledString, textStyle); + OH_ArkUI_StyledString_AddText(styledString, "Hello"); + OH_ArkUI_StyledString_PopTextStyle(styledString); + // 添加占位,此区域内不会绘制文字,可以在此位置挂载Image组件实现图文混排。 + OH_Drawing_PlaceholderSpan placeHolder{.width = VALUE_20, .height = VALUE_20}; + OH_ArkUI_StyledString_AddPlaceholder(styledString, &placeHolder); + // 设置不同样式的文字 + OH_Drawing_TextStyle *worldTextStyle = OH_Drawing_CreateTextStyle(); + OH_Drawing_SetTextStyleFontSize(worldTextStyle, VALUE_28); + OH_Drawing_SetTextStyleColor(worldTextStyle, OH_Drawing_ColorSetArgb(0xFF, 0x27, 0x87, 0xD9)); + OH_ArkUI_StyledString_PushTextStyle(styledString, worldTextStyle); + OH_ArkUI_StyledString_AddText(styledString, "World!"); + OH_ArkUI_StyledString_PopTextStyle(styledString); + // 依赖StyledString对象创建字体引擎的Typography,此时它已经包含了设置的文本及其样式。 + OH_Drawing_Typography *typography = OH_ArkUI_StyledString_CreateTypography(styledString); + // 字体引擎布局方法,需传入一个宽度,此宽度需与Text组件宽度匹配。 + // 布局宽度 = Text组件宽度 - (左padding + 右padding) + OH_Drawing_TypographyLayout(typography, VALUE_300); + ArkUI_AttributeItem styledStringItem = {.object = styledString}; + // 布局完成后,通过NODE_TEXT_CONTENT_WITH_STYLED_STRING设置给Text组件。 + Manager::nodeAPI_->setAttribute(text, NODE_TEXT_CONTENT_WITH_STYLED_STRING, &styledStringItem); + OH_ArkUI_StyledString_Destroy(styledString); + Manager::nodeAPI_->addChild(text7, text); +} + +static void MyTaskCallback(void *userData) +{ + if (!userData) { + return; + } + // 将在这里完成自定义数据的处理。。。 + //进入text页面会打印信息 + ArkUI_NodeHandle textNode = static_cast(userData); + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "修改数据成功"); +} + +void RunTaskInUIContext(ArkUI_NodeHandle targetNode) +{ + if (!targetNode || !Manager::nodeAPI_) { + return; + } + ArkUI_ContextHandle uiCtx = OH_ArkUI_GetContextByNode(targetNode); + int32_t ret = OH_ArkUI_RunTaskInScope(uiCtx, targetNode, MyTaskCallback); +} + +static uint32_t MyInvertColor(uint32_t color) +{ + // color是0xARGB格式,比如0xFFFF0000(红)→ 反色0xFF00FFFF(青) + uint32_t alpha = (color & 0xFF000000); // 保留透明度 + uint32_t rgb = color & 0x00FFFFFF; // 提取RGB部分 + return alpha | (~rgb & 0x00FFFFFF); // RGB反色,保留透明度 +} + +void SetComponentForceDark(ArkUI_NodeHandle &text5) +{ + //进入text页面会打印信息 + ArkUI_ContextHandle uiCtx = OH_ArkUI_GetContextByNode(text5); + // 直接调用接口:上下文+开启反色+所有组件生效+自定义算法 + int32_t ret = OH_ArkUI_SetForceDarkConfig(uiCtx, // UI上下文 + true, // 开启反色 + ARKUI_NODE_UNDEFINED, // 所有组件生效 + MyInvertColor); + if (ret == ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "反色设置成功"); + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "反色设置失败"); + } +} + +void measuredInfo(ArkUI_NodeHandle &component) +{ + // 设置组件宽高 + //进入text页面会打印信息 + int32_t setMeasured = Manager::nodeAPI_->setMeasuredSize(component, VALUE_100, VALUE_100); + if (setMeasured == ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "manager", "设置尺寸成功"); + } + // 创建约束尺寸 + ArkUI_LayoutConstraint *Constraint = OH_ArkUI_LayoutConstraint_Create(); + // 设置最大高度 + OH_ArkUI_LayoutConstraint_SetMaxHeight(Constraint, VALUE_100); + // 获取组件宽高 + ArkUI_IntSize getMeasured = Manager::nodeAPI_->getMeasuredSize(component); +} + +void setUIVal(ArkUI_NodeHandle &textContainer) +{ + ArkUI_NodeHandle text1 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle text2 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle text3 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle text4 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle text5 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle textInput1 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_INPUT); + ArkUI_NodeHandle textInput2 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_INPUT); + ArkUI_NodeHandle textInput3 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_INPUT); + ArkUI_NodeHandle textArea1 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_AREA); + ArkUI_NodeHandle textArea2 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_AREA); + ArkUI_NodeHandle textArea3 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_AREA); + ArkUI_NodeHandle accessibilityLabel = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle customSpan = Manager::nodeAPI_->createNode(ARKUI_NODE_CUSTOM_SPAN); + ArkUI_NodeHandle text6 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle text7 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + measuredInfo(text4); + setText1(text1); + setText2(text2); + setText3(text3); + setText4(text4); + setText5(text5); + setText6(text6); + setTextInput1(textInput1); + setTextInput2(textInput2); + setTextInput3(textInput3); + setTextArea1(textArea1); + setTextArea2(textArea2); + setTextArea3(textArea3); + setAccessibility(accessibilityLabel); + setText7(text7); + RunTaskInUIContext(text5); + SetComponentForceDark(text5); + Manager::nodeAPI_->addChild(textContainer, text1); + Manager::nodeAPI_->addChild(textContainer, text2); + Manager::nodeAPI_->addChild(textContainer, text3); + Manager::nodeAPI_->addChild(textContainer, text4); + Manager::nodeAPI_->addChild(textContainer, text5); + Manager::nodeAPI_->addChild(textContainer, textInput1); + Manager::nodeAPI_->addChild(textContainer, textInput2); + Manager::nodeAPI_->addChild(textContainer, textInput3); + Manager::nodeAPI_->addChild(textContainer, textArea1); + Manager::nodeAPI_->addChild(textContainer, textArea2); + Manager::nodeAPI_->addChild(textContainer, textArea3); + Manager::nodeAPI_->addChild(textContainer, accessibilityLabel); + Manager::nodeAPI_->addChild(textContainer, customSpan); + Manager::nodeAPI_->addChild(textContainer, text6); + Manager::nodeAPI_->addChild(textContainer, text7); +} + +ArkUI_NodeHandle TextMaker::createTextPage() +{ + ArkUI_NodeHandle scroll = Manager::nodeAPI_->createNode(ARKUI_NODE_SCROLL); + ArkUI_NodeHandle textContainer = Manager::nodeAPI_->createNode(ARKUI_NODE_COLUMN); + ArkUI_NumberValue colWidth[] = {{.f32 = VALUE_400}}; + ArkUI_AttributeItem widthItem = {.value = colWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(textContainer, NODE_WIDTH, &widthItem); + setUIVal(textContainer); + Manager::nodeAPI_->addChild(scroll, textContainer); + return scroll; +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.h b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.h new file mode 100644 index 0000000000000000000000000000000000000000..d6e24e3a9e7ec0ba9f3a1e1996b7a56dc8900330 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/TextMaker.h @@ -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. + */ + +#ifndef NATIVE_TYPE_SAMPLE_SWIPERMAKER_H +#define NATIVE_TYPE_SAMPLE_SWIPERMAKER_H + +#include "manager.h" + +class TextMaker { +public: + TextMaker(){}; + ~TextMaker(){}; + static ArkUI_NodeHandle createTextPage(); +}; + +#endif // NATIVE_TYPE_SAMPLE_SWIPERMAKER_H diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/baseUtils.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/baseUtils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ad12a5b4d5d7886ba8fe5847a0c5d9f464df53dd --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/baseUtils.cpp @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#include "baseUtils.h" +#include "TextMaker.h" + +namespace ConstIde { + const uint32_t NUMBER_0 = 0; + const uint32_t NUMBER_1 = 1; + const uint32_t NUMBER_2 = 2; + const uint32_t MARGIN_NUMBER_30 = 30; +} + +void BaseUtils::SetNodeMargin(ArkUI_NodeHandle &node, float margin) +{ + ArkUI_NumberValue value[ConstIde::NUMBER_1]; + ArkUI_AttributeItem item = {.value = value, .size = ConstIde::NUMBER_1}; + value[ConstIde::NUMBER_0].f32 = margin; + Manager::nodeAPI_->setAttribute(node, NODE_MARGIN, &item); +} + +void BaseUtils::SetNodeBackGroundColor(ArkUI_NodeHandle &node, uint32_t color) +{ + ArkUI_NumberValue value[ConstIde::NUMBER_1]; + ArkUI_AttributeItem item = {.value = value, .size = ConstIde::NUMBER_1}; + value[ConstIde::NUMBER_0].u32 = color; + Manager::nodeAPI_->setAttribute(node, NODE_BACKGROUND_COLOR, &item); +} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/baseUtils.h b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/baseUtils.h similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/baseUtils.h rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/baseUtils.h diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp similarity index 92% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.cpp rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp index 775734b3752f42861581e1210fb4f1e8976132ac..b7abd35af44175f36ae9d118a42a2ea60a28e889 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.cpp +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp @@ -14,7 +14,7 @@ */ #include "manager.h" -#include "SwiperMaker.h" +#include "TextMaker.h" #include "baseUtils.h" #include "napi/native_api.h" #include @@ -34,7 +34,7 @@ Manager Manager::manager_; ArkUI_NativeNodeAPI_1 *Manager::nodeAPI_ = reinterpret_cast( OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1")); -napi_value Manager::CreateNativeSwiperNode(napi_env env, napi_callback_info info) +napi_value Manager::CreateNativeTextNode(napi_env env, napi_callback_info info) { OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN"); if ((env == nullptr) || (info == nullptr)) { @@ -54,7 +54,7 @@ napi_value Manager::CreateNativeSwiperNode(napi_env env, napi_callback_info info OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after"); if (nodeAPI_ != nullptr) { if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) { - ArkUI_NodeHandle testNode = SwiperMaker::createSwiperPage(); + ArkUI_NodeHandle testNode = TextMaker::createTextPage(); OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode); } } diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h new file mode 100644 index 0000000000000000000000000000000000000000..f152ab2f7635037242e09c0b04698afaf753cd64 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef NATIVE_NODE_NAPI_SAMPLE_MANAGER_H +#define NATIVE_NODE_NAPI_SAMPLE_MANAGER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +const unsigned int LOG_PRINT_DOMAIN = 0xFF00; +class Manager { +public: + static ArkUI_NativeNodeAPI_1 *nodeAPI_; + ~Manager(){}; + + static napi_value CreateNativeTextNode(napi_env env, napi_callback_info info); + +private: + static Manager manager_; +}; + +#endif // NATIVE_NODE_NAPI_SAMPLE_MANAGER_H diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bd65cea63df750743845f40fa26d85b24bb7bfac --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp @@ -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. + */ + +#include "manager.h" +#include + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Init", "Init begins"); + if ((env == nullptr) || (exports == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Init", "env or exports is null"); + return nullptr; + } + + napi_property_descriptor desc[] = { + {"createNativeTextNode", nullptr, Manager::CreateNativeTextNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + // 参考新增其他createNative方法和Maker类 + }; + + if (napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Init", "napi_define_properties failed"); + return nullptr; + } + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts similarity index 90% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/types/libentry/Index.d.ts rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts index d130e9cb39490a5523dfb36214b9f467d837b00f..e45a977acdf016624d888997fbace93e42a123c6 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts @@ -13,4 +13,4 @@ * limitations under the License. */ -export const createNativeSwiperNode: (content: Object) =>void; \ No newline at end of file +export const createNativeTextNode: (content: Object) =>void; \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/types/libentry/oh-package.json5 rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/entryability/EntryAbility.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/entryability/EntryAbility.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/entryability/EntryAbility.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc0367fc4c963a401c73f3c4163ea3439e40190d --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/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. + */ + +import { router } from '@kit.ArkUI'; + +interface ListCategories { + title: string, + url: string +} + +@Entry +@Component +struct MenuIndex { + private items: ListCategories[] = + [ + { title: 'Text', url: 'pages/page_text' }, + { title: 'add your router', url: '' }, + ]; + + build() { + Scroll(new Scroller()) { + Column() { + Text('native_node_sample') + .fontWeight(FontWeight.Bold) + .fontSize('20vp') + .textAlign(TextAlign.Center) + .height('5%') + .margin($r('sys.float.titlebar_title_margin_right')) + List() { + ForEach(this.items, (item: ListCategories) => { + ListItem() { + Row() { + Text(item.title) + .fontSize($r('sys.float.text_button_font_size')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start) + .height('100%') + .width('50%') + .padding($r('sys.float.padding_level10')) + Text('>') + .fontSize('25vp') + .fontColor(Color.Black) + .textAlign(TextAlign.End) + .fontColor(Color.Gray) + .height('100%') + .width('50%') + .padding($r('sys.float.padding_level10')) + } + .width('100%') + .height('10%') + .borderRadius($r('sys.float.select_border_radius_default')) + .backgroundColor(Color.White) + .onClick(() => { + router.pushUrl({ url: item.url }) + }) + }.margin($r('sys.float.menu_item_content_align')) + }) + }.width('95%').height('90%').alignListItem(ListItemAlign.Center) + }.width('100%') + }.height('100%').backgroundColor($r('app.color.background_color')) + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_text.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_text.ets new file mode 100644 index 0000000000000000000000000000000000000000..f56f9e8c740a488cefdb25ee8b457c1cf12386a7 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_text.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. + */ + +import Napi from 'libentry.so'; +import { NodeContent } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + private nodeContent = new NodeContent(); + aboutToAppear() { + // 通过C-API创建节点,并添加到管理器nodeContent上 + Napi.createNativeTextNode(this.nodeContent); + } + build() { + Column() { + ContentSlot(this.nodeContent) + } + .width('100%') + .height('100%') + } +} diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/module.json5 b/ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/module.json5 rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/color.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/color.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/color.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/color.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/float.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/float.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/float.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/float.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/string.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/string.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/background.png b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/background.png similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/background.png rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/background.png diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/foreground.png similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/foreground.png rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/foreground.png diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/layered_image.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/layered_image.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/layered_image.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/startIcon.png similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/media/startIcon.png rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/media/startIcon.png diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/backup_config.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/profile/backup_config.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/backup_config.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json similarity index 61% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/profile/main_pages.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json index ef2cbe9a43bf0adae5d5ccc2e84b99ae6234ab52..17e8e7cb8e186c8b7b913f97e3d1ee2c822dca68 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/profile/main_pages.json +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ "pages/Index", - "pages/page_swiper" + "pages/page_text" ] } diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/dark/element/color.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/dark/element/color.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/dark/element/color.json rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/dark/element/color.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/ets/test/Ability.test.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/ets/test/List.test.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/ets/test/List.test.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/module.json5 b/ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/module.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/ohosTest/module.json5 rename to ArkUIKit/NativeNodeBaseSample/entry/src/ohosTest/module.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/test/List.test.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/test/List.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/test/List.test.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/test/List.test.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/test/LocalUnit.test.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/test/LocalUnit.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/test/LocalUnit.test.ets rename to ArkUIKit/NativeNodeBaseSample/entry/src/test/LocalUnit.test.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/hvigor/hvigor-config.json5 b/ArkUIKit/NativeNodeBaseSample/hvigor/hvigor-config.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/hvigor/hvigor-config.json5 rename to ArkUIKit/NativeNodeBaseSample/hvigor/hvigor-config.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/hvigorfile.ts b/ArkUIKit/NativeNodeBaseSample/hvigorfile.ts similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/hvigorfile.ts rename to ArkUIKit/NativeNodeBaseSample/hvigorfile.ts diff --git a/ArkUIKit/NativeNodeBaseSample/log.txt b/ArkUIKit/NativeNodeBaseSample/log.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a39aab2c8785f27910a1b1e8d9da3021c999145 --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/log.txt @@ -0,0 +1,642 @@ +16:01:36:072 log task queue not empty +16:01:36:073 log task size: 1 +16:01:36:073 log before pop task size: 1 +16:01:36:074 log after task size: 0 +16:01:36:386 log task queue not empty +16:01:36:386 log task size: 1 +16:01:36:386 log before pop task size: 1 +16:01:36:386 log after task size: 0 +16:01:36:576 log timer task size: 1 +16:01:36:648 log task queue not empty +16:01:36:649 log task size: 1 +16:01:36:649 log before pop task size: 1 +16:01:36:649 log after task size: 0 +16:01:36:893 log timer task size: 1 +16:01:37:160 log timer task size: 1 +16:01:37:947 log task queue not empty +16:01:37:948 log task size: 1 +16:01:37:948 log before pop task size: 1 +16:01:37:948 log after task size: 0 +16:01:38:106 log task queue not empty +16:01:38:107 log task size: 1 +16:01:38:107 log before pop task size: 1 +16:01:38:107 log after task size: 0 +16:01:38:458 log timer task size: 1 +16:01:38:616 log timer task size: 1 +16:01:38:728 log task queue not empty +16:01:38:729 log task size: 1 +16:01:38:729 log before pop task size: 1 +16:01:38:729 log after task size: 0 +16:01:39:232 log timer task size: 1 +16:06:36:691 log task queue not empty +16:06:36:691 log task size: 1 +16:06:36:691 log before pop task size: 1 +16:06:36:692 log after task size: 0 +16:06:36:875 log task queue not empty +16:06:36:876 log task size: 1 +16:06:36:877 log before pop task size: 1 +16:06:36:877 log after task size: 0 +16:06:36:997 log task queue not empty +16:06:36:997 log task size: 1 +16:06:36:997 log before pop task size: 1 +16:06:36:998 log after task size: 0 +16:06:37:139 log task queue not empty +16:06:37:140 log task size: 1 +16:06:37:140 log before pop task size: 1 +16:06:37:140 log after task size: 0 +16:06:37:203 log timer task size: 1 +16:06:37:275 log task queue not empty +16:06:37:276 log task size: 1 +16:06:37:276 log before pop task size: 1 +16:06:37:276 log after task size: 0 +16:06:37:394 log timer task size: 1 +16:06:37:503 log timer task size: 1 +16:06:37:579 log task queue not empty +16:06:37:579 log task size: 1 +16:06:37:579 log before pop task size: 1 +16:06:37:580 log after task size: 0 +16:06:37:644 log timer task size: 1 +16:06:37:785 log timer task size: 1 +16:06:38:086 log timer task size: 1 +16:06:38:196 log task queue not empty +16:06:38:196 log task size: 1 +16:06:38:196 log before pop task size: 1 +16:06:38:196 log after task size: 0 +16:06:38:440 log task queue not empty +16:06:38:441 log task size: 1 +16:06:38:442 log before pop task size: 1 +16:06:38:443 log after task size: 0 +16:06:38:666 log task queue not empty +16:06:38:666 log task size: 1 +16:06:38:667 log before pop task size: 1 +16:06:38:667 log after task size: 0 +16:06:38:702 log timer task size: 1 +16:06:38:874 log task queue not empty +16:06:38:874 log task size: 1 +16:06:38:874 log before pop task size: 1 +16:06:38:874 log after task size: 0 +16:06:38:953 log timer task size: 1 +16:06:39:174 log timer task size: 1 +16:06:39:377 log timer task size: 1 +16:06:42:082 log task queue not empty +16:06:42:082 log task size: 1 +16:06:42:083 log before pop task size: 1 +16:06:42:083 log after task size: 0 +16:06:42:201 log task queue not empty +16:06:42:201 log task size: 1 +16:06:42:201 log before pop task size: 1 +16:06:42:202 log after task size: 0 +16:06:42:381 log task queue not empty +16:06:42:381 log task size: 1 +16:06:42:381 log before pop task size: 1 +16:06:42:382 log after task size: 0 +16:06:42:514 log task queue not empty +16:06:42:514 log task size: 1 +16:06:42:515 log before pop task size: 1 +16:06:42:515 log after task size: 0 +16:06:42:598 log timer task size: 1 +16:06:42:654 log task queue not empty +16:06:42:654 log task size: 1 +16:06:42:654 log before pop task size: 1 +16:06:42:654 log after task size: 0 +16:06:42:707 log timer task size: 1 +16:06:42:898 log timer task size: 1 +16:06:42:954 log task queue not empty +16:06:42:954 log task size: 1 +16:06:42:954 log before pop task size: 1 +16:06:42:954 log after task size: 0 +16:06:43:023 log timer task size: 1 +16:06:43:162 log timer task size: 1 +16:06:43:464 log timer task size: 1 +16:06:44:098 log task queue not empty +16:06:44:099 log task size: 1 +16:06:44:099 log before pop task size: 1 +16:06:44:099 log after task size: 0 +16:06:44:280 log task queue not empty +16:06:44:280 log task size: 1 +16:06:44:280 log before pop task size: 1 +16:06:44:281 log after task size: 0 +16:06:44:493 log task queue not empty +16:06:44:494 log task size: 1 +16:06:44:494 log before pop task size: 1 +16:06:44:494 log after task size: 0 +16:06:44:612 log timer task size: 1 +16:06:44:692 log task queue not empty +16:06:44:693 log task size: 1 +16:06:44:693 log before pop task size: 1 +16:06:44:693 log after task size: 0 +16:06:44:785 log timer task size: 1 +16:06:45:006 log timer task size: 1 +16:06:45:198 log timer task size: 1 +16:06:47:624 log task queue not empty +16:06:47:624 log task size: 1 +16:06:47:624 log before pop task size: 1 +16:06:47:624 log after task size: 0 +16:06:47:774 log task queue not empty +16:06:47:774 log task size: 1 +16:06:47:774 log before pop task size: 1 +16:06:47:774 log after task size: 0 +16:06:47:921 log task queue not empty +16:06:47:921 log task size: 1 +16:06:47:921 log before pop task size: 1 +16:06:47:922 log after task size: 0 +16:06:48:071 log task queue not empty +16:06:48:072 log task size: 1 +16:06:48:072 log before pop task size: 1 +16:06:48:072 log after task size: 0 +16:06:48:139 log timer task size: 1 +16:06:48:233 log task queue not empty +16:06:48:234 log task size: 1 +16:06:48:234 log before pop task size: 1 +16:06:48:234 log after task size: 0 +16:06:48:278 log timer task size: 1 +16:06:48:435 log timer task size: 1 +16:06:48:493 log task queue not empty +16:06:48:493 log task size: 1 +16:06:48:493 log before pop task size: 1 +16:06:48:494 log after task size: 0 +16:06:48:579 log timer task size: 1 +16:06:48:737 log timer task size: 1 +16:06:49:008 log timer task size: 1 +16:06:49:050 log task queue not empty +16:06:49:050 log task size: 1 +16:06:49:050 log before pop task size: 1 +16:06:49:050 log after task size: 0 +16:06:49:243 log task queue not empty +16:06:49:243 log task size: 1 +16:06:49:246 log before pop task size: 1 +16:06:49:246 log after task size: 0 +16:06:49:488 log task queue not empty +16:06:49:488 log task size: 1 +16:06:49:489 log before pop task size: 1 +16:06:49:489 log after task size: 0 +16:06:49:561 log timer task size: 1 +16:06:49:749 log timer task size: 1 +16:06:49:784 log task queue not empty +16:06:49:784 log task size: 1 +16:06:49:785 log before pop task size: 1 +16:06:49:785 log after task size: 0 +16:06:50:002 log timer task size: 1 +16:06:50:288 log timer task size: 1 +16:08:45:925 log task queue not empty +16:08:45:925 log task size: 1 +16:08:45:926 log before pop task size: 1 +16:08:45:926 log after task size: 0 +16:08:46:431 log timer task size: 1 +16:11:07:398 log task queue not empty +16:11:07:399 log task size: 1 +16:11:07:399 log before pop task size: 1 +16:11:07:399 log after task size: 0 +16:11:07:903 log timer task size: 1 +16:11:08:516 log task queue not empty +16:11:08:516 log task size: 1 +16:11:08:517 log before pop task size: 1 +16:11:08:517 log after task size: 0 +16:11:09:019 log timer task size: 1 +16:11:16:662 log task queue not empty +16:11:16:662 log task size: 1 +16:11:16:662 log before pop task size: 1 +16:11:16:663 log after task size: 0 +16:11:16:665 log task queue not empty +16:11:16:665 log task size: 1 +16:11:16:665 log before pop task size: 1 +16:11:16:665 log after task size: 0 +16:11:16:871 log task queue not empty +16:11:16:871 log task size: 1 +16:11:16:872 log before pop task size: 1 +16:11:16:872 log after task size: 0 +16:11:17:110 log task queue not empty +16:11:17:110 log task size: 1 +16:11:17:111 log before pop task size: 1 +16:11:17:111 log after task size: 0 +16:11:17:169 log timer task size: 1 +16:11:17:318 log task queue not empty +16:11:17:318 log task size: 1 +16:11:17:319 log before pop task size: 1 +16:11:17:319 log after task size: 0 +16:11:17:373 log timer task size: 1 +16:11:17:626 log timer task size: 1 +16:11:17:830 log timer task size: 1 +16:11:24:501 log task queue not empty +16:11:24:501 log task size: 1 +16:11:24:501 log before pop task size: 1 +16:11:24:501 log after task size: 0 +16:11:25:015 log timer task size: 1 +16:11:26:299 log task queue not empty +16:11:26:299 log task size: 1 +16:11:26:299 log before pop task size: 1 +16:11:26:300 log after task size: 0 +16:11:26:813 log timer task size: 1 +16:11:28:189 log task queue not empty +16:11:28:189 log task size: 1 +16:11:28:190 log before pop task size: 1 +16:11:28:190 log after task size: 0 +16:11:28:697 log timer task size: 1 +16:11:30:930 log task queue not empty +16:11:30:930 log task size: 1 +16:11:30:930 log before pop task size: 1 +16:11:30:931 log after task size: 0 +16:11:31:431 log timer task size: 1 +16:11:33:229 log task queue not empty +16:11:33:230 log task size: 1 +16:11:33:230 log before pop task size: 1 +16:11:33:230 log after task size: 0 +16:11:33:734 log timer task size: 1 +16:13:21:847 log task queue not empty +16:13:21:848 log task size: 1 +16:13:21:848 log before pop task size: 1 +16:13:21:848 log after task size: 0 +16:13:22:363 log timer task size: 1 +16:13:51:149 log task queue not empty +16:13:51:150 log task size: 1 +16:13:51:150 log before pop task size: 1 +16:13:51:150 log after task size: 0 +16:13:51:152 log task queue not empty +16:13:51:152 log task size: 1 +16:13:51:152 log before pop task size: 1 +16:13:51:153 log after task size: 0 +16:13:51:240 log task queue not empty +16:13:51:241 log task size: 1 +16:13:51:241 log before pop task size: 1 +16:13:51:241 log after task size: 0 +16:13:51:554 log task queue not empty +16:13:51:554 log task size: 1 +16:13:51:554 log before pop task size: 1 +16:13:51:555 log after task size: 0 +16:13:51:656 log timer task size: 1 +16:13:51:750 log timer task size: 1 +16:13:51:763 log task queue not empty +16:13:51:764 log task size: 1 +16:13:51:764 log before pop task size: 1 +16:13:51:764 log after task size: 0 +16:13:52:068 log timer task size: 1 +16:13:52:273 log timer task size: 1 +16:13:56:946 log task queue not empty +16:13:56:946 log task size: 1 +16:13:56:947 log before pop task size: 1 +16:13:56:947 log after task size: 0 +16:13:57:454 log timer task size: 1 +16:13:58:519 log task queue not empty +16:13:58:519 log task size: 1 +16:13:58:519 log before pop task size: 1 +16:13:58:519 log after task size: 0 +16:13:59:022 log timer task size: 1 +16:13:59:298 log task queue not empty +16:13:59:298 log task size: 1 +16:13:59:298 log before pop task size: 1 +16:13:59:298 log after task size: 0 +16:13:59:808 log timer task size: 1 +16:14:00:342 log task queue not empty +16:14:00:343 log task size: 1 +16:14:00:343 log before pop task size: 1 +16:14:00:343 log after task size: 0 +16:14:00:847 log timer task size: 1 +16:14:01:145 log task queue not empty +16:14:01:145 log task size: 1 +16:14:01:146 log before pop task size: 1 +16:14:01:146 log after task size: 0 +16:14:01:653 log timer task size: 1 +16:14:01:956 log task queue not empty +16:14:01:957 log task size: 1 +16:14:01:957 log before pop task size: 1 +16:14:01:957 log after task size: 0 +16:14:02:471 log timer task size: 1 +16:31:37:896 log task queue not empty +16:31:37:897 log task size: 1 +16:31:37:897 log before pop task size: 1 +16:31:37:897 log after task size: 0 +16:31:38:410 log timer task size: 1 +16:32:53:971 log task queue not empty +16:32:53:972 log task size: 1 +16:32:53:972 log before pop task size: 1 +16:32:53:972 log after task size: 0 +16:32:54:479 log timer task size: 1 +16:32:54:831 log task queue not empty +16:32:54:832 log task size: 1 +16:32:54:832 log before pop task size: 1 +16:32:54:833 log after task size: 0 +16:32:54:999 log task queue not empty +16:32:55:000 log task size: 1 +16:32:55:000 log before pop task size: 1 +16:32:55:000 log after task size: 0 +16:32:55:155 log task queue not empty +16:32:55:155 log task size: 1 +16:32:55:156 log before pop task size: 1 +16:32:55:156 log after task size: 0 +16:32:55:276 log task queue not empty +16:32:55:276 log task size: 1 +16:32:55:276 log before pop task size: 1 +16:32:55:277 log after task size: 0 +16:32:55:343 log timer task size: 1 +16:32:55:516 log timer task size: 1 +16:32:55:658 log timer task size: 1 +16:32:55:781 log timer task size: 1 +16:32:56:423 log task queue not empty +16:32:56:423 log task size: 1 +16:32:56:424 log before pop task size: 1 +16:32:56:424 log after task size: 0 +16:32:56:734 log task queue not empty +16:32:56:734 log task size: 1 +16:32:56:735 log before pop task size: 1 +16:32:56:735 log after task size: 0 +16:32:56:842 log task queue not empty +16:32:56:843 log task size: 1 +16:32:56:843 log before pop task size: 1 +16:32:56:843 log after task size: 0 +16:32:56:926 log timer task size: 1 +16:32:56:990 log task queue not empty +16:32:56:991 log task size: 1 +16:32:56:991 log before pop task size: 1 +16:32:56:991 log after task size: 0 +16:32:57:243 log timer task size: 1 +16:32:57:354 log timer task size: 1 +16:32:57:424 log task queue not empty +16:32:57:424 log task size: 1 +16:32:57:424 log before pop task size: 1 +16:32:57:424 log after task size: 0 +16:32:57:494 log timer task size: 1 +16:32:57:935 log timer task size: 1 +16:33:18:834 log task queue not empty +16:33:18:835 log task size: 1 +16:33:18:835 log before pop task size: 1 +16:33:18:835 log after task size: 0 +16:33:19:023 log task queue not empty +16:33:19:024 log task size: 1 +16:33:19:024 log before pop task size: 1 +16:33:19:024 log after task size: 0 +16:33:19:220 log task queue not empty +16:33:19:220 log task size: 1 +16:33:19:221 log before pop task size: 1 +16:33:19:221 log after task size: 0 +16:33:19:293 log task queue not empty +16:33:19:293 log task size: 1 +16:33:19:293 log before pop task size: 1 +16:33:19:293 log after task size: 0 +16:33:19:343 log timer task size: 1 +16:33:19:402 log task queue not empty +16:33:19:403 log task size: 1 +16:33:19:403 log before pop task size: 1 +16:33:19:403 log after task size: 0 +16:33:19:529 log timer task size: 1 +16:33:19:734 log timer task size: 1 +16:33:19:798 log timer task size: 1 +16:33:19:906 log timer task size: 1 +16:33:21:294 log task queue not empty +16:33:21:295 log task size: 1 +16:33:21:295 log before pop task size: 1 +16:33:21:295 log after task size: 0 +16:33:21:806 log timer task size: 1 +16:33:21:971 log task queue not empty +16:33:21:972 log task size: 1 +16:33:21:972 log before pop task size: 1 +16:33:21:972 log after task size: 0 +16:33:22:147 log task queue not empty +16:33:22:147 log task size: 1 +16:33:22:147 log before pop task size: 1 +16:33:22:147 log after task size: 0 +16:33:22:476 log timer task size: 1 +16:33:22:592 log task queue not empty +16:33:22:593 log task size: 1 +16:33:22:593 log before pop task size: 1 +16:33:22:593 log after task size: 0 +16:33:22:648 log timer task size: 1 +16:33:22:689 log task queue not empty +16:33:22:690 log task size: 1 +16:33:22:690 log before pop task size: 1 +16:33:22:690 log after task size: 0 +16:33:22:798 log task queue not empty +16:33:22:799 log task size: 1 +16:33:22:799 log before pop task size: 1 +16:33:22:799 log after task size: 0 +16:33:23:069 log task queue not empty +16:33:23:070 log task size: 1 +16:33:23:070 log before pop task size: 1 +16:33:23:070 log after task size: 0 +16:33:23:103 log timer task size: 1 +16:33:23:197 log timer task size: 1 +16:33:23:240 log task queue not empty +16:33:23:240 log task size: 1 +16:33:23:240 log before pop task size: 1 +16:33:23:241 log after task size: 0 +16:33:23:310 log timer task size: 1 +16:33:23:401 log task queue not empty +16:33:23:401 log task size: 1 +16:33:23:401 log before pop task size: 1 +16:33:23:401 log after task size: 0 +16:33:23:576 log timer task size: 1 +16:33:23:749 log timer task size: 1 +16:33:23:813 log task queue not empty +16:33:23:813 log task size: 1 +16:33:23:813 log before pop task size: 1 +16:33:23:814 log after task size: 0 +16:33:23:906 log timer task size: 1 +16:33:24:175 log task queue not empty +16:33:24:176 log task size: 1 +16:33:24:177 log before pop task size: 1 +16:33:24:178 log after task size: 0 +16:33:24:314 log timer task size: 1 +16:33:24:384 log task queue not empty +16:33:24:384 log task size: 1 +16:33:24:385 log before pop task size: 1 +16:33:24:385 log after task size: 0 +16:33:24:543 log task queue not empty +16:33:24:544 log task size: 1 +16:33:24:544 log before pop task size: 1 +16:33:24:544 log after task size: 0 +16:33:24:652 log task queue not empty +16:33:24:653 log task size: 1 +16:33:24:653 log before pop task size: 1 +16:33:24:653 log after task size: 0 +16:33:24:694 log timer task size: 1 +16:33:24:900 log timer task size: 1 +16:33:25:056 log timer task size: 1 +16:33:25:084 log task queue not empty +16:33:25:086 log task size: 1 +16:33:25:086 log before pop task size: 1 +16:33:25:087 log after task size: 0 +16:33:25:146 log task queue not empty +16:33:25:146 log task size: 1 +16:33:25:146 log before pop task size: 1 +16:33:25:146 log after task size: 0 +16:33:25:168 log timer task size: 1 +16:33:25:597 log timer task size: 1 +16:33:25:660 log timer task size: 1 +16:33:27:073 log task queue not empty +16:33:27:074 log task size: 1 +16:33:27:074 log before pop task size: 1 +16:33:27:075 log after task size: 0 +16:33:27:299 log task queue not empty +16:33:27:300 log task size: 1 +16:33:27:300 log before pop task size: 1 +16:33:27:300 log after task size: 0 +16:33:27:473 log task queue not empty +16:33:27:473 log task size: 1 +16:33:27:474 log before pop task size: 1 +16:33:27:474 log after task size: 0 +16:33:27:581 log timer task size: 1 +16:33:27:660 log task queue not empty +16:33:27:660 log task size: 1 +16:33:27:661 log before pop task size: 1 +16:33:27:661 log after task size: 0 +16:33:27:816 log timer task size: 1 +16:33:27:989 log timer task size: 1 +16:33:28:164 log timer task size: 1 +16:33:29:769 log task queue not empty +16:33:29:769 log task size: 1 +16:33:29:769 log before pop task size: 1 +16:33:29:769 log after task size: 0 +16:33:30:066 log task queue not empty +16:33:30:066 log task size: 1 +16:33:30:066 log before pop task size: 1 +16:33:30:067 log after task size: 0 +16:33:30:144 log task queue not empty +16:33:30:144 log task size: 1 +16:33:30:144 log before pop task size: 1 +16:33:30:145 log after task size: 0 +16:33:30:276 log timer task size: 1 +16:33:30:299 log task queue not empty +16:33:30:300 log task size: 1 +16:33:30:300 log before pop task size: 1 +16:33:30:300 log after task size: 0 +16:33:30:575 log timer task size: 1 +16:33:30:655 log timer task size: 1 +16:33:30:771 log task queue not empty +16:33:30:771 log task size: 1 +16:33:30:772 log before pop task size: 1 +16:33:30:772 log after task size: 0 +16:33:30:773 log task queue not empty +16:33:30:773 log task size: 1 +16:33:30:774 log before pop task size: 1 +16:33:30:774 log after task size: 0 +16:33:30:810 log timer task size: 1 +16:33:31:280 log timer task size: 1 +16:33:31:280 log timer task size: 1 +16:33:32:231 log task queue not empty +16:33:32:232 log task size: 1 +16:33:32:232 log before pop task size: 1 +16:33:32:232 log after task size: 0 +16:33:32:434 log task queue not empty +16:33:32:434 log task size: 1 +16:33:32:434 log before pop task size: 1 +16:33:32:434 log after task size: 0 +16:33:32:609 log task queue not empty +16:33:32:610 log task size: 1 +16:33:32:610 log before pop task size: 1 +16:33:32:610 log after task size: 0 +16:33:32:741 log timer task size: 1 +16:33:32:948 log timer task size: 1 +16:33:33:121 log timer task size: 1 +16:33:33:859 log task queue not empty +16:33:33:859 log task size: 1 +16:33:33:859 log before pop task size: 1 +16:33:33:859 log after task size: 0 +16:33:33:941 log task queue not empty +16:33:33:942 log task size: 1 +16:33:33:942 log before pop task size: 1 +16:33:33:942 log after task size: 0 +16:33:34:372 log timer task size: 1 +16:33:34:450 log timer task size: 1 +16:33:34:552 log task queue not empty +16:33:34:553 log task size: 1 +16:33:34:553 log before pop task size: 1 +16:33:34:553 log after task size: 0 +16:33:35:059 log timer task size: 1 +16:33:35:606 log task queue not empty +16:33:35:606 log task size: 1 +16:33:35:607 log before pop task size: 1 +16:33:35:607 log after task size: 0 +16:33:35:931 log task queue not empty +16:33:35:932 log task size: 1 +16:33:35:932 log before pop task size: 1 +16:33:35:932 log after task size: 0 +16:33:36:115 log timer task size: 1 +16:33:36:443 log timer task size: 1 +16:33:37:327 log task queue not empty +16:33:37:328 log task size: 1 +16:33:37:329 log before pop task size: 1 +16:33:37:329 log after task size: 0 +16:33:37:521 log task queue not empty +16:33:37:522 log task size: 1 +16:33:37:522 log before pop task size: 1 +16:33:37:523 log after task size: 0 +16:33:37:581 log task queue not empty +16:33:37:581 log task size: 1 +16:33:37:581 log before pop task size: 1 +16:33:37:582 log after task size: 0 +16:33:37:718 log task queue not empty +16:33:37:719 log task size: 1 +16:33:37:719 log before pop task size: 1 +16:33:37:719 log after task size: 0 +16:33:37:832 log timer task size: 1 +16:33:38:036 log timer task size: 1 +16:33:38:084 log timer task size: 1 +16:33:38:226 log timer task size: 1 +16:33:39:540 log task queue not empty +16:33:39:541 log task size: 1 +16:33:39:541 log before pop task size: 1 +16:33:39:541 log after task size: 0 +16:33:40:050 log timer task size: 1 +16:33:40:192 log task queue not empty +16:33:40:192 log task size: 1 +16:33:40:192 log before pop task size: 1 +16:33:40:192 log after task size: 0 +16:33:40:206 log task queue not empty +16:33:40:206 log task size: 1 +16:33:40:206 log before pop task size: 1 +16:33:40:207 log after task size: 0 +16:33:40:210 log task queue not empty +16:33:40:210 log task size: 1 +16:33:40:211 log before pop task size: 1 +16:33:40:211 log after task size: 0 +16:33:40:708 log timer task size: 1 +16:33:40:724 log timer task size: 1 +16:33:41:032 log task queue not empty +16:33:41:033 log task size: 1 +16:33:41:033 log before pop task size: 1 +16:33:41:033 log after task size: 0 +16:33:41:541 log timer task size: 1 +16:33:42:458 log task queue not empty +16:33:42:459 log task size: 1 +16:33:42:459 log before pop task size: 1 +16:33:42:459 log after task size: 0 +16:33:42:960 log timer task size: 1 +16:33:43:033 log task queue not empty +16:33:43:034 log task size: 1 +16:33:43:034 log before pop task size: 1 +16:33:43:035 log after task size: 0 +16:33:43:538 log timer task size: 1 +16:33:44:629 log task queue not empty +16:33:44:629 log task size: 1 +16:33:44:630 log before pop task size: 1 +16:33:44:630 log after task size: 0 +16:33:45:130 log timer task size: 1 +16:33:48:948 log task queue not empty +16:33:48:949 log task size: 1 +16:33:48:949 log before pop task size: 1 +16:33:48:949 log after task size: 0 +16:33:48:950 log task queue not empty +16:33:48:950 log task size: 1 +16:33:48:951 log before pop task size: 1 +16:33:48:951 log after task size: 0 +16:33:48:952 log task queue not empty +16:33:48:952 log task size: 1 +16:33:48:952 log before pop task size: 1 +16:33:48:953 log after task size: 0 +16:33:48:954 log task queue not empty +16:33:48:954 log task size: 1 +16:33:48:954 log before pop task size: 1 +16:33:48:955 log after task size: 0 +16:33:49:455 log timer task size: 1 +16:33:49:455 log timer task size: 1 +16:33:49:455 log timer task size: 1 +16:33:49:455 log timer task size: 1 +16:35:02:470 log task queue not empty +16:35:02:470 log task size: 1 +16:35:02:471 log before pop task size: 1 +16:35:02:471 log after task size: 0 +16:35:02:972 log timer task size: 1 +16:35:02:989 log task queue not empty +16:35:02:990 log task size: 1 +16:35:02:990 log before pop task size: 1 +16:35:02:991 log after task size: 0 +16:35:03:506 log timer task size: 1 diff --git a/ArkUIKit/NativeNodeBaseSample/oh-package.json5 b/ArkUIKit/NativeNodeBaseSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..346d7e239ade076f95cbba216cbc69f1bec6207c --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/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/NativeNodeBaseSample/ohosTest.md b/ArkUIKit/NativeNodeBaseSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..bb401db8cea5067c6b683de95441bb64573f476f --- /dev/null +++ b/ArkUIKit/NativeNodeBaseSample/ohosTest.md @@ -0,0 +1,8 @@ +# 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期显示 | 是否自动 | 测试结果 | +| ------------------------------ | ------------ |--------------------------------------------------------------------| ----------------------------------------------------------- | -------- | -------- | +| 启动应用 | 设备正常运行 | 1.开启开发板
2.编译hap包并将hap包及环境烧录进开发板,运行测试用例
| 成功拉起应用。 | 否 | 验证通过 | +| 文本组件及输入框功能展示 | 应用位于首页 | 1.text仅观察以及读取log 2.textinput、textarea均需要点击,输入,回车,撤销,粘贴等操作以及查看log信息 | 1. 页面展示多个文本、输入框及文本域组件2. 各组件样式符合代码配置,输入框可正常输入 | 否 | 验证通过 | diff --git a/ArkUIKit/NativeNodeBaseSample/screenshot/nativeNode.png b/ArkUIKit/NativeNodeBaseSample/screenshot/nativeNode.png new file mode 100644 index 0000000000000000000000000000000000000000..7b250284bb902a16be04e865b1a4f8a6e12422e1 Binary files /dev/null and b/ArkUIKit/NativeNodeBaseSample/screenshot/nativeNode.png differ diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/.gitignore b/ArkUIKit/NativeNodeNapiSample/.gitignore similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/.gitignore rename to ArkUIKit/NativeNodeNapiSample/.gitignore diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/app.json5 b/ArkUIKit/NativeNodeNapiSample/AppScope/app.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/app.json5 rename to ArkUIKit/NativeNodeNapiSample/AppScope/app.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/element/string.json b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/element/string.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/AppScope/resources/base/element/string.json rename to ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/element/string.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/background.png b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/background.png similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/background.png rename to ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/background.png diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/foreground.png b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/foreground.png similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/foreground.png rename to ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/foreground.png diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/layered_image.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/AppScope/resources/base/media/layered_image.json rename to ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/layered_image.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/build-profile.json5 b/ArkUIKit/NativeNodeNapiSample/build-profile.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/build-profile.json5 rename to ArkUIKit/NativeNodeNapiSample/build-profile.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/code-linter.json5 b/ArkUIKit/NativeNodeNapiSample/code-linter.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/code-linter.json5 rename to ArkUIKit/NativeNodeNapiSample/code-linter.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/.gitignore b/ArkUIKit/NativeNodeNapiSample/entry/.gitignore similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/.gitignore rename to ArkUIKit/NativeNodeNapiSample/entry/.gitignore diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/build-profile.json5 b/ArkUIKit/NativeNodeNapiSample/entry/build-profile.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/build-profile.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/build-profile.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/hvigorfile.ts b/ArkUIKit/NativeNodeNapiSample/entry/hvigorfile.ts similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/hvigorfile.ts rename to ArkUIKit/NativeNodeNapiSample/entry/hvigorfile.ts diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/obfuscation-rules.txt b/ArkUIKit/NativeNodeNapiSample/entry/obfuscation-rules.txt similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/obfuscation-rules.txt rename to ArkUIKit/NativeNodeNapiSample/entry/obfuscation-rules.txt diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/oh-package-lock.json5 b/ArkUIKit/NativeNodeNapiSample/entry/oh-package-lock.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/oh-package-lock.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/oh-package-lock.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/entry/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/oh-package.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/CMakeLists.txt similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/CMakeLists.txt rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/CMakeLists.txt diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/NavigationContext.cpp b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/NavigationContext.cpp similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/NavigationContext.cpp rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/NavigationContext.cpp diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/NavigationContext.h b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/NavigationContext.h similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/NavigationContext.h rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/NavigationContext.h diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/manager.cpp similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/manager.cpp rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/manager.cpp diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/manager.h b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/manager.h similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/manager.h rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/manager.h diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/napi_init.cpp similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/napi_init.cpp rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/napi_init.cpp diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/Index.d.ts similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/cpp/types/libentry/Index.d.ts rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/Index.d.ts diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/types/libentry/oh-package.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entryability/EntryAbility.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/entryability/EntryAbility.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entryability/EntryAbility.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/Index.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/pages/Index.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/Index.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/pages/page_navigation.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/page_navigation.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/ets/pages/page_navigation.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/page_navigation.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/module.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/main/module.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/module.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/module.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/color.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/color.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/color.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/color.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/float.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/float.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/element/float.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/float.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/string.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/string.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/element/string.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/string.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/background.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/background.png similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/background.png rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/background.png diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/foreground.png similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/foreground.png rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/foreground.png diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/layered_image.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/layered_image.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/layered_image.json diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/startIcon.png similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/media/startIcon.png rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/startIcon.png diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/backup_config.json similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/resources/base/profile/backup_config.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/backup_config.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/main_pages.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/base/profile/main_pages.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/main_pages.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/dark/element/color.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/dark/element/color.json similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/main/resources/dark/element/color.json rename to ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/dark/element/color.json diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/ets/test/Ability.test.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/ets/test/List.test.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/List.test.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/module.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/module.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/ohosTest/module.json5 rename to ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/module.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/test/List.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/test/List.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/test/List.test.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/test/List.test.ets diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/test/LocalUnit.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/test/LocalUnit.test.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/entry/src/test/LocalUnit.test.ets rename to ArkUIKit/NativeNodeNapiSample/entry/src/test/LocalUnit.test.ets diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/hvigor/hvigor-config.json5 b/ArkUIKit/NativeNodeNapiSample/hvigor/hvigor-config.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/hvigor/hvigor-config.json5 rename to ArkUIKit/NativeNodeNapiSample/hvigor/hvigor-config.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/hvigorfile.ts b/ArkUIKit/NativeNodeNapiSample/hvigorfile.ts similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/hvigorfile.ts rename to ArkUIKit/NativeNodeNapiSample/hvigorfile.ts diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/oh-package-lock.json5 b/ArkUIKit/NativeNodeNapiSample/oh-package-lock.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/oh-package-lock.json5 rename to ArkUIKit/NativeNodeNapiSample/oh-package-lock.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/oh-package.json5 rename to ArkUIKit/NativeNodeNapiSample/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/ohosTest.md b/ArkUIKit/NativeNodeNapiSample/ohosTest.md similarity index 100% rename from ArkUIKit/CapiSample/NativeNodeNapi/native_node_napi/ohosTest.md rename to ArkUIKit/NativeNodeNapiSample/ohosTest.md diff --git a/ArkUIKit/NativeTypeSample/.gitignore b/ArkUIKit/NativeTypeSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkUIKit/NativeTypeSample/.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/NativeTypeSample/AppScope/app.json5 b/ArkUIKit/NativeTypeSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6bfccda26f1df2cdf0e8b961fefaf6afafe0f425 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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.example.native_type_sample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/NativeTypeSample/AppScope/resources/base/element/string.json b/ArkUIKit/NativeTypeSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..63f6db99cd72d23257e11b8def239e69b3733ab7 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "native_type_sample" + } + ] +} diff --git a/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/background.png b/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/foreground.png b/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/layered_image.json b/ArkUIKit/NativeTypeSample/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/README.md b/ArkUIKit/NativeTypeSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..00ea12c0eaac4bc5e6253ea83a38b8802ef61b35 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/README.md @@ -0,0 +1,75 @@ +# Native_type_Sample + +## 介绍 + +本示例展示了如何创建文本、输入框、文本域等组件,配置其样式、属性与事件设置等功能,构建文本页面。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 首页面会出现对应text选择框,点击选择框进入text界面; + + +## 工程目录 + +``` +Native_type_Sample +entry/src/main/ets/ +└── pages + ├── Index.ets (获取导航页面) + └── page_text.ets (文本界面) +entry/src/main/ +├── cpp +│ ├── types +│ │ └── libentry +│ │ └── Index.d.ts (函数对应的js映射) +│ ├── CMakeLists.txt (CMake脚本) +| ├── manager.cpp +| ├── manager.h +│ ├── napi_init.cpp +| ├── ....... +| ├── baseUtils.cpp +| ├── baseUtils.h +| ├── TextMaker.cpp +│ └── TextMaker.h +└── resources + ├── base + │ ├── element + │ │ ├── color.json + │ │ ├── float.json + │ │ └── string.json + │ └── media +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.36; + +3. 本示例已支持使DevEco Studio 5.1.1 Release (构建版本:5.1.1.840,构建 2025年9月20日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/NativeType/native_type_sample > .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/CapiSample/NativeType/native_type_sample/build-profile.json5 b/ArkUIKit/NativeTypeSample/build-profile.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/build-profile.json5 rename to ArkUIKit/NativeTypeSample/build-profile.json5 diff --git a/ArkUIKit/NativeTypeSample/code-linter.json5 b/ArkUIKit/NativeTypeSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4c531be90a6c875995767bd87f2de3cbd6b55160 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/.gitignore b/ArkUIKit/NativeTypeSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/build-profile.json5 b/ArkUIKit/NativeTypeSample/entry/build-profile.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/build-profile.json5 rename to ArkUIKit/NativeTypeSample/entry/build-profile.json5 diff --git a/ArkUIKit/NativeTypeSample/entry/hvigorfile.ts b/ArkUIKit/NativeTypeSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..10f881f112b08550ed5c8a3ceb7d0148be2a0b6e --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/obfuscation-rules.txt b/ArkUIKit/NativeTypeSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/oh-package.json5 b/ArkUIKit/NativeTypeSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9f254ab4d0e3a4de30318e04483b785b552ce977 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/oh-package.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. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3870e1647c773c33d9773c2925854f267f85864f --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,20 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(native_type_sample) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp TextMaker.cpp) + +find_library(hilog-lib hilog_ndk.z) + +find_library(libace-lib ace_ndk.z) + +find_library(libnapi-lib ace_napi.z) + + +target_link_libraries(entry PUBLIC ${hilog-lib} ${libace-lib} ${libnapi-lib}) +target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/SwiperMaker.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/SwiperMaker.cpp similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/SwiperMaker.cpp rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/SwiperMaker.cpp diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/SwiperMaker.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/SwiperMaker.h similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/SwiperMaker.h rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/SwiperMaker.h diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b222d8652ddb7f5987f9f0969ca6b3dfdb2170c1 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.cpp @@ -0,0 +1,405 @@ +/* + * 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. + */ + +#include "TextMaker.h" +#include "baseUtils.h" +#include "manager.h" +#include +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "manager" +#define LOG_ERROR(...) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xD001400, LOG_TAG, __VA_ARGS__) +#define VALUE_0 0 +#define VALUE_1 1 +#define VALUE_30 30 +#define VALUE_50 50 +#define VALUE_200 200 +#define VALUE_300 300 +#define VALUE_350 350 +#define VALUE_1024 1024 + +constexpr int32_t ON_ERROR_CODE_DEMO_106107 = 106107; // 参数下标越界 +constexpr int32_t ON_ERROR_CODE_DEMO_106109 = 106109; // 不支持返回值 + +typedef struct { + ArkUI_NodeHandle textNode; + ArkUI_NativeNodeAPI_1 *nodeApi; +} FontChangeCtx; + +void OnSystemFontChange(ArkUI_SystemFontStyleEvent *event, void *userData) +{ + if (event == nullptr || userData == nullptr) { + return; + } + FontChangeCtx *ctx = (FontChangeCtx *)userData; + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "System font style changed!"); +} + +static void OnEventReceive(ArkUI_NodeEvent *event) +{ + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "错误码: %d", ARKUI_ERROR_CODE_NODE_EVENT_PARAM_INVALID); + return; + } + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + ArkUI_NativeNodeAPI_1 *nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + switch (eventId) { + // 参数下标越界 + case ON_ERROR_CODE_DEMO_106107: { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "错误码: %d", + ARKUI_ERROR_CODE_NODE_EVENT_PARAM_INDEX_OUT_OF_RANGE); + return; + } + // 不支持返回值 + case ON_ERROR_CODE_DEMO_106109: { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "错误码: %d", ARKUI_ERROR_CODE_NODE_EVENT_NO_RETURN); + return; + } + default: + break; + } +} + +void setBasicTextVal(ArkUI_NodeHandle &basicText) +{ + const char *textContent = + "这是一段包含字体样式、字重、对齐方式、不支持复制、超长时跑马灯显示、的文字,以及无障碍文本"; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_CONTENT, &contentItem); + + // 字体样式:斜体样式(ARKUI_FONT_STYLE_ITALIC) + ArkUI_NumberValue fontStyleVal = {.i32 = ARKUI_FONT_STYLE_ITALIC}; + ArkUI_AttributeItem fontStyleItem = {&fontStyleVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_FONT_STYLE, &fontStyleItem); + + // 字重:600(ARKUI_FONT_WEIGHT_W600) + ArkUI_NumberValue fontWeightVal = {.i32 = ARKUI_FONT_WEIGHT_W600}; + ArkUI_AttributeItem fontWeightItem = {&fontWeightVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_FONT_WEIGHT, &fontWeightItem); + + // 水平对齐:首部对齐(ARKUI_TEXT_ALIGNMENT_START) + ArkUI_NumberValue hAlignVal = {.i32 = ARKUI_TEXT_ALIGNMENT_START}; + ArkUI_AttributeItem hAlignItem = {&hAlignVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_ALIGN, &hAlignItem); + + // 垂直对齐:基线对齐(ARKUI_TEXT_VERTICAL_ALIGNMENT_BASELINE) + ArkUI_NumberValue vAlignVal = {.i32 = ARKUI_TEXT_VERTICAL_ALIGNMENT_BASELINE}; + ArkUI_AttributeItem vAlignItem = {&vAlignVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_VERTICAL_ALIGN, &vAlignItem); + + // 文本溢出:跑马灯(ARKUI_TEXT_OVERFLOW_MARQUEE) + ArkUI_NumberValue overflowVal = {.i32 = ARKUI_TEXT_OVERFLOW_MARQUEE}; + ArkUI_AttributeItem overflowItem = {&overflowVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_OVERFLOW, &overflowItem); + + // 省略位置:行首省略(ARKUI_ELLIPSIS_MODE_START) + ArkUI_NumberValue ellipsisVal = {.i32 = ARKUI_ELLIPSIS_MODE_START}; + ArkUI_AttributeItem ellipsisItem = {&ellipsisVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_ELLIPSIS_MODE, &ellipsisItem); + + // 复制粘贴:不支持复制(ARKUI_COPY_OPTIONS_NONE / ARKUI_TEXT_COPY_OPTIONS_NONE) + ArkUI_NumberValue copyOptVal = {.i32 = ARKUI_COPY_OPTIONS_NONE}; + ArkUI_AttributeItem copyOptItem = {©OptVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_COPY_OPTION, ©OptItem); +} + +void setBasicText(ArkUI_NodeHandle &textContainer) +{ + // --------------------------基础Text组件(应用文本样式枚举)-------------------------- + auto basicText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue textWidth[] = {{.f32 = VALUE_200}}; + ArkUI_AttributeItem textWidthItem = {.value = textWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_WIDTH, &textWidthItem); + ArkUI_NumberValue textHeight[] = {{.f32 = VALUE_30}}; + ArkUI_AttributeItem textHeightItem = {.value = textHeight, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_HEIGHT, &textHeightItem); + ArkUI_NumberValue borderWidth[] = {{.f32 = VALUE_1}}; + ArkUI_AttributeItem borderWidthItem = {.value = borderWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText, NODE_BORDER_WIDTH, &borderWidthItem); + if (basicText != nullptr) { + setBasicTextVal(basicText); + // 设置无障碍文本 + ArkUI_AccessibilityValue *accessibilityVal = OH_ArkUI_AccessibilityValue_Create(); + OH_ArkUI_AccessibilityValue_SetText(accessibilityVal, "基础文本组件,包含字体样式和对齐设置"); + const char *a11yItemVal = OH_ArkUI_AccessibilityValue_GetText(accessibilityVal); + ArkUI_AttributeItem a11yItem = {.string = a11yItemVal}; + Manager::nodeAPI_->setAttribute(basicText, NODE_TEXT_CONTENT, &a11yItem); + + FontChangeCtx *ctx = (FontChangeCtx *)malloc(sizeof(FontChangeCtx)); + if (ctx != nullptr) { + ctx->textNode = basicText; + ctx->nodeApi = Manager::nodeAPI_; + int32_t ret = OH_ArkUI_RegisterSystemFontStyleChangeEvent(basicText, // 目标Text节点 + ctx, // 自定义数据(回调中传回) + OnSystemFontChange); // 字体变化回调 + if (ret != ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", + "Register system font event failed, code: %{public}d", ret); + free(ctx); // 注册失败释放数据 + } + } + Manager::nodeAPI_->addChild(textContainer, basicText); + } +} + +void setBasicText1(ArkUI_NodeHandle &textContainer) +{ + //--------------------------第二段text文本----------------------------------------------------- + auto basicText1 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue textWidth1[] = {{.f32 = VALUE_350}}; + ArkUI_AttributeItem textWidthItem1 = {.value = textWidth1, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_WIDTH, &textWidthItem1); + ArkUI_NumberValue borderWidth1[] = {{.f32 = VALUE_1}}; + ArkUI_AttributeItem borderWidthItem1 = {.value = borderWidth1, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_BORDER_WIDTH, &borderWidthItem1); + if (basicText1 != nullptr) { + const char *textContent = "this is a egg: case_upper、braeak_normal、max_lines_first "; + ArkUI_AttributeItem contentItem = {.string = textContent}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_CONTENT, &contentItem); + + // 文本大小写:(ARKUI_TEXT_CASE_UPPER) + ArkUI_NumberValue textCaseVal = {.i32 = ARKUI_TEXT_CASE_UPPER}; + ArkUI_AttributeItem textCaseItem = {&textCaseVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_CASE, &textCaseItem); + + // 断行规则:CJK任意断行(ARKUI_WORD_BREAK_NORMAL) + ArkUI_NumberValue wordBreakVal = {.i32 = ARKUI_WORD_BREAK_NORMAL}; + ArkUI_AttributeItem wordBreakItem = {&wordBreakVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_WORD_BREAK, &wordBreakItem); + + // 自适应高度:MaxLines优先(ARKUI_TEXT_HEIGHT_ADAPTIVE_POLICY_MAX_LINES_FIRST) + ArkUI_NumberValue adaptPolicyVal = {.i32 = ARKUI_TEXT_HEIGHT_ADAPTIVE_POLICY_MAX_LINES_FIRST}; + ArkUI_AttributeItem adaptPolicyItem = {&adaptPolicyVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_HEIGHT_ADAPTIVE_POLICY, &adaptPolicyItem); + + // 装饰线:下划线(ARKUI_TEXT_DECORATION_TYPE_UNDERLINE) + ArkUI_NumberValue decoTypeVal = {.i32 = ARKUI_TEXT_DECORATION_TYPE_UNDERLINE}; + ArkUI_NumberValue decoStyleVal = {.i32 = ARKUI_TEXT_DECORATION_STYLE_SOLID}; + ArkUI_AttributeItem decoTypeItem = {&decoTypeVal, VALUE_1}; + ArkUI_AttributeItem decoStyleItem = {&decoStyleVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_DECORATION, &decoTypeItem); + Manager::nodeAPI_->setAttribute(basicText1, NODE_TEXT_DECORATION, &decoStyleItem); + + // 添加到容器 + Manager::nodeAPI_->addChild(textContainer, basicText1); + } +} + +void setBasicText2(ArkUI_NodeHandle &textContainer) +{ + //--------------------------第三段text文本----------------------------------------------------- + auto basicText2 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue textWidth2[] = {{.f32 = VALUE_350}}; + ArkUI_AttributeItem textWidthItem2 = {.value = textWidth2, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText2, NODE_WIDTH, &textWidthItem2); + ArkUI_NumberValue textHeight1[] = {{.f32 = VALUE_50}}; + ArkUI_AttributeItem textHeight1Item = {.value = textHeight1, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText2, NODE_HEIGHT, &textHeight1Item); + ArkUI_NumberValue borderWidth2[] = {{.f32 = VALUE_1}}; + ArkUI_AttributeItem borderWidthItem2 = {.value = borderWidth2, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText2, NODE_BORDER_WIDTH, &borderWidthItem2); + + // 设置文本识别 + ArkUI_NumberValue enableDataDetector = {.i32 = true}; + ArkUI_AttributeItem enableDataDetectorItem = {.value = &enableDataDetector, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(basicText2, NODE_TEXT_ENABLE_DATA_DETECTOR, &enableDataDetectorItem); + ArkUI_NumberValue detectorConfig = {.i32 = ARKUI_TEXT_DATA_DETECTOR_TYPE_PHONE_NUMBER}; + ArkUI_AttributeItem detectorConfigItem = {.value = &detectorConfig, .size = 2}; + Manager::nodeAPI_->setAttribute(basicText2, NODE_TEXT_ENABLE_DATA_DETECTOR_CONFIG, &detectorConfigItem); + + auto testText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + const char *testTextStr = "测试ARKUI_ERROR_CODE_INVALID_STYLED_STRING"; + ArkUI_AttributeItem testTextItem = {.string = testTextStr}; + Manager::nodeAPI_->setAttribute(testText, NODE_TEXT_CONTENT, &testTextItem); + Manager::nodeAPI_->addChild(textContainer, testText); + // 序列化过程中返回空值,会打印ARKUI_ERROR_CODE_INVALID_STYLED_STRING的值 + if (basicText2 != nullptr) { + ArkUI_StyledString_Descriptor *descriptor = OH_ArkUI_StyledString_Descriptor_Create(); + uint8_t buffer[VALUE_1024] = {VALUE_0}; + size_t resultSize = VALUE_0; + // 序列化 字节数组 + int32_t marshalResult = + OH_ArkUI_MarshallStyledStringDescriptor(buffer, sizeof(buffer), descriptor, &resultSize); + if (marshalResult != ARKUI_ERROR_CODE_NO_ERROR) { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "序列化失败%{public}d", marshalResult); + } else if (marshalResult == ARKUI_ERROR_CODE_INVALID_STYLED_STRING) { + OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "manager", "无效的属性字符串错误码%{public}d", marshalResult); + } + const char *invalidA11yText = "序列化过程中返回值为空"; + ArkUI_AttributeItem a11yItem = {.string = invalidA11yText}; + int32_t setA11yRet = Manager::nodeAPI_->setAttribute(basicText2, NODE_TEXT_CONTENT, &a11yItem); + + Manager::nodeAPI_->addChild(textContainer, basicText2); + } +} + +void setBasicInputText(ArkUI_NodeHandle &textContainer) +{ + // --------------------------TextInput组件(单行输入框)-------------------------- + auto inputText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + const char *inputTextStr = "单行输入框:输入框风格只支持InputType.Normal,回车newline"; + ArkUI_AttributeItem inputTextItem = {.string = inputTextStr}; + Manager::nodeAPI_->setAttribute(inputText, NODE_TEXT_CONTENT, &inputTextItem); + Manager::nodeAPI_->addChild(textContainer, inputText); + auto textInput = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_INPUT); + if (textInput != nullptr) { + // 输入类型:基本模式(ARKUI_TEXTINPUT_TYPE_NORMAL) + ArkUI_NumberValue inputTypeVal = {.i32 = ARKUI_TEXTINPUT_TYPE_NORMAL}; + ArkUI_AttributeItem inputTypeItem = {&inputTypeVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput, NODE_TEXT_INPUT_TYPE, &inputTypeItem); + + // 回车键类型 + ArkUI_NumberValue enterKeyVal = {.i32 = ARKUI_ENTER_KEY_TYPE_NEW_LINE}; + ArkUI_AttributeItem enterKeyItem = {&enterKeyVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput, NODE_TEXT_INPUT_ENTER_KEY_TYPE, &enterKeyItem); + + // 自动填充类型 + ArkUI_NumberValue autoFillVal = {.i32 = ARKUI_TEXTINPUT_CONTENT_TYPE_USER_NAME}; + ArkUI_AttributeItem autoFillItem = {&autoFillVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput, NODE_TEXT_INPUT_CONTENT_TYPE, &autoFillItem); + + // 输入框风格 + ArkUI_NumberValue inputStyleVal = {.i32 = ARKUI_TEXTINPUT_STYLE_INLINE}; + ArkUI_AttributeItem inputStyleItem = {&inputStyleVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput, NODE_TEXT_INPUT_STYLE, &inputStyleItem); + + // 键盘样式 + ArkUI_NumberValue keyboardStyleVal = {.i32 = ARKUI_KEYBOARD_APPEARANCE_DARK_IMMERSIVE}; + ArkUI_AttributeItem keyboardStyleItem = {&keyboardStyleVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput, NODE_TEXT_INPUT_KEYBOARD_APPEARANCE, &keyboardStyleItem); + + // 添加到容器 + Manager::nodeAPI_->addChild(textContainer, textInput); + } + auto textInput2 = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_INPUT); + // 清除按钮 + ArkUI_NumberValue cancelButton[] = {{.i32 = ARKUI_CANCELBUTTON_STYLE_CONSTANT}}; + ArkUI_AttributeItem cancelButtonItem = {cancelButton, VALUE_1}; + Manager::nodeAPI_->setAttribute(textInput2, NODE_TEXT_INPUT_CANCEL_BUTTON, &cancelButtonItem); + Manager::nodeAPI_->addChild(textContainer, textInput2); +} + +void setBasicAreaText(ArkUI_NodeHandle &textContainer) +{ + // --------------------------TextArea组件(多行输入框,应用多行输入枚举)-------------------------- + auto areaText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + const char *areaTextStr = "多行输入框:基本模式"; + ArkUI_AttributeItem areaTextItem = {.string = areaTextStr}; + Manager::nodeAPI_->setAttribute(areaText, NODE_TEXT_CONTENT, &areaTextItem); + Manager::nodeAPI_->addChild(textContainer, areaText); + auto textArea = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT_AREA); + if (textArea != nullptr) { + // 多行输入类型:基本模式(ARKUI_TEXTAREA_TYPE_NORMAL) + ArkUI_NumberValue textAreaTypeVal = {.i32 = ARKUI_TEXTAREA_TYPE_NORMAL}; + ArkUI_NumberValue textAreaTypeVal1 = {.u32 = 0xFFFF0000}; + ArkUI_AttributeItem textAreaTypeItem = {&textAreaTypeVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(textArea, NODE_TEXT_AREA_TYPE, &textAreaTypeItem); + // 添加到容器 + Manager::nodeAPI_->addChild(textContainer, textArea); + } +} + +void setCustomSpanText(ArkUI_NodeHandle &textContainer) +{ + // -------------------------自定义段落组件(应用CustomSpan相关结构体及函数)-------------------------- + auto customSpanText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + const char *customSpanTextStr = "自定义段落组件:"; + ArkUI_AttributeItem customSpanTextItem = {.string = customSpanTextStr}; + Manager::nodeAPI_->setAttribute(customSpanText, NODE_TEXT_CONTENT, &customSpanTextItem); + Manager::nodeAPI_->addChild(textContainer, customSpanText); + // 创建自定义段落测量信息 + ArkUI_CustomSpanMeasureInfo *measureInfo = OH_ArkUI_CustomSpanMeasureInfo_Create(); + if (measureInfo != nullptr) { + // 获取父Text组件字体大小(模拟场景) + float parentFontSize = OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(measureInfo); + + // 创建自定义段落度量指标 + ArkUI_CustomSpanMetrics *metrics = OH_ArkUI_CustomSpanMetrics_Create(); + // 设置自定义段落宽度(200vp)、高度(30vp) + int32_t setWidthRet = OH_ArkUI_CustomSpanMetrics_SetWidth(metrics, 200.0f); + int32_t setHeightRet = OH_ArkUI_CustomSpanMetrics_SetHeight(metrics, 30.0f); + if (setWidthRet == ARKUI_ERROR_CODE_NO_ERROR && setHeightRet == ARKUI_ERROR_CODE_NO_ERROR) { + // 创建自定义段落绘制信息 + ArkUI_CustomSpanDrawInfo *drawInfo = OH_ArkUI_CustomSpanDrawInfo_Create(); + if (drawInfo != nullptr) { + // 获取绘制偏移量、边距等信息 + float xOffset = OH_ArkUI_CustomSpanDrawInfo_GetXOffset(drawInfo); + float lineTop = OH_ArkUI_CustomSpanDrawInfo_GetLineTop(drawInfo); + float lineBottom = OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(drawInfo); + float baseline = OH_ArkUI_CustomSpanDrawInfo_GetBaseline(drawInfo); + } + // 基于自定义信息创建Text组件(模拟自定义段落渲染) + auto customSpanText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + if (customSpanText != nullptr) { + const char *customText = "自定义段落组件:宽度200vp,高度30vp"; + ArkUI_AttributeItem customTextItem = {.string = customText}; + Manager::nodeAPI_->setAttribute(customSpanText, NODE_TEXT_CONTENT, &customTextItem); + Manager::nodeAPI_->addChild(textContainer, customSpanText); + } + // 销毁绘制信息 + OH_ArkUI_CustomSpanDrawInfo_Dispose(drawInfo); + } + // 销毁度量指标 + OH_ArkUI_CustomSpanMetrics_Dispose(metrics); + // 销毁测量信息 + OH_ArkUI_CustomSpanMeasureInfo_Dispose(measureInfo); + } +} + +void setSpanText(ArkUI_NodeHandle &textContainer) +{ + auto SpanText = Manager::nodeAPI_->createNode(ARKUI_NODE_TEXT); + ArkUI_NodeHandle imageSpan = Manager::nodeAPI_->createNode(ARKUI_NODE_IMAGE_SPAN); + ArkUI_AttributeItem spanUrl = {.string = "/resources/base/media/background.png"}; + ArkUI_NumberValue widthVal[VALUE_1]{}; + widthVal[VALUE_0].f32 = 30.f; + ArkUI_AttributeItem width = {.value = widthVal, .size = VALUE_1}; + ArkUI_NumberValue heightVal[VALUE_1]{}; + heightVal[VALUE_0].f32 = 30.f; + ArkUI_AttributeItem height = {.value = heightVal, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_WIDTH, &width); + Manager::nodeAPI_->setAttribute(imageSpan, NODE_HEIGHT, &height); + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_SRC, &spanUrl); + ArkUI_NumberValue imageSpanVal = {.i32 = ARKUI_IMAGE_SPAN_ALIGNMENT_BASELINE}; + ArkUI_AttributeItem imageSpanValItem = {&imageSpanVal, VALUE_1}; + Manager::nodeAPI_->setAttribute(imageSpan, NODE_IMAGE_SPAN_VERTICAL_ALIGNMENT, &imageSpanValItem); + Manager::nodeAPI_->addChild(SpanText, imageSpan); + Manager::nodeAPI_->addChild(textContainer, SpanText); +} + +ArkUI_NodeHandle TextMaker::createTextPage() +{ +// 创建父容器column + ArkUI_NodeHandle textContainer = Manager::nodeAPI_->createNode(ARKUI_NODE_COLUMN); + ArkUI_NumberValue colWidth[] = {{.f32 = VALUE_300}}; + ArkUI_AttributeItem widthItem = {.value = colWidth, .size = VALUE_1}; + Manager::nodeAPI_->setAttribute(textContainer, NODE_WIDTH, &widthItem); + setBasicText(textContainer); + setBasicText1(textContainer); + setBasicText2(textContainer); + OnEventReceive(nullptr); + setBasicInputText(textContainer); + setBasicAreaText(textContainer); + setCustomSpanText(textContainer); + setSpanText(textContainer); + return textContainer; +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.h new file mode 100644 index 0000000000000000000000000000000000000000..bbd3557af7dfa6b3368a0bab647e21632a515df0 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/TextMaker.h @@ -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. + */ + +#ifndef NATIVE_TYPE_SAMPLE_TEXTMAKER_H +#define NATIVE_TYPE_SAMPLE_TEXTMAKER_H + +#include "manager.h" + +class TextMaker { +public: + TextMaker(){}; + ~TextMaker(){}; + + static ArkUI_NodeHandle createTextPage(); +}; + +#endif // NATIVE_TYPE_SAMPLE_SWIPERMAKER_H \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/baseUtils.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/baseUtils.cpp similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/baseUtils.cpp rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/baseUtils.cpp diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/baseUtils.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/baseUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..c8be5afa4c7c96d341c4c8bc53294e9b5d1d643a --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/baseUtils.h @@ -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. + */ + +#ifndef NATIVE_TYPE_SAMPLE_BASEUTILS_H +#define NATIVE_TYPE_SAMPLE_BASEUTILS_H + +#include "manager.h" +#include + +class BaseUtils { +public: + BaseUtils() {} + ~BaseUtils() {} + static void SetNodeMargin(ArkUI_NodeHandle &node, float margin); + static void SetNodeBackGroundColor(ArkUI_NodeHandle &node, uint32_t color); +}; + +#endif // NATIVE_TYPE_SAMPLE_BASEUTILS_H diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df022f8cd7e211be0f583b129bc9d3ab4b140ac8 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp @@ -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. + */ + +#include "manager.h" +#include "SwiperMaker.h" +#include "TextMaker.h" +#include "baseUtils.h" +#include "napi/native_api.h" +#include +#include +#include +#include +#include + +namespace ConstIde { + const uint32_t NUMBER_0 = 0; + const uint32_t NUMBER_1 = 1; + const uint32_t NUMBER_2 = 2; + const uint32_t MARGIN_NUMBER_30 = 30; +} + +Manager Manager::manager_; +ArkUI_NativeNodeAPI_1 *Manager::nodeAPI_ = reinterpret_cast( + OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1")); + +napi_value Manager::CreateNativeSwiperNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN"); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null"); + return nullptr; + } + size_t argCnt = ConstIde::NUMBER_1; + napi_value args[ConstIde::NUMBER_1] = {nullptr}; + if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed"); + } + + ArkUI_NodeContentHandle nodeContentHandle = nullptr; + + OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after"); + if (nodeAPI_ != nullptr) { + if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) { + ArkUI_NodeHandle testNode = SwiperMaker::createSwiperPage(); + OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode); + } + } + return nullptr; +} + +napi_value Manager::CreateNativeTextNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN"); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null"); + return nullptr; + } + size_t argCnt = ConstIde::NUMBER_1; + napi_value args[ConstIde::NUMBER_1] = {nullptr}; + if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed"); + } + + ArkUI_NodeContentHandle nodeContentHandle = nullptr; + + OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after"); + if (nodeAPI_ != nullptr) { + if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) { + ArkUI_NodeHandle testNode = TextMaker::createTextPage(); + OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode); + } + } + return nullptr; +} \ No newline at end of file diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h similarity index 93% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.h rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h index 9bb890977dab38682dc3f87dee2a8af36a985224..6f9fc248986c9abded2dd5c509194f6643f69bce 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/manager.h +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h @@ -32,7 +32,8 @@ public: ~Manager(){}; static napi_value CreateNativeSwiperNode(napi_env env, napi_callback_info info); - + static napi_value CreateNativeTextNode(napi_env env, napi_callback_info info); + private: static Manager manager_; }; diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp similarity index 93% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/napi_init.cpp rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp index 2f134388db93f68b80463a51e880d3a9262431e5..60f2a287edcdc3fd841c7aaaf05ca2a23d9cef4c 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/cpp/napi_init.cpp +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp @@ -28,6 +28,8 @@ static napi_value Init(napi_env env, napi_value exports) napi_property_descriptor desc[] = { {"createNativeSwiperNode", nullptr, Manager::CreateNativeSwiperNode, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"createNativeTextNode", nullptr, Manager::CreateNativeTextNode, nullptr, nullptr, nullptr, napi_default, + nullptr} // 参考Swiper新增其他createNative方法和Maker类 }; diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9279a70f5dce5d6c9c86abe8e9d46f91c4db8ac --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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. + */ + +export const createNativeSwiperNode: (content: Object) =>void; +export const createNativeTextNode: (content: Object) =>void; \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b81656fe96ca09694282eed65e33f57ddc1d2a05 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -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. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..6678a198c2f39c9309ca7c3e5a9f36999ce001f7 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +import { BusinessError } from '@kit.BasicServicesKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; +const BACKGROUND_COLOR = '#2AA1A6B1' +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + 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.'); + }); + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let systemBarProperties: window.SystemBarProperties = { + statusBarColor: BACKGROUND_COLOR, + navigationBarColor: BACKGROUND_COLOR, + //以下两个属性从API Version8开始支持 + }; + try { + let promise = windowClass.setWindowSystemBarProperties(systemBarProperties); + promise.then(() => { + console.info('Succeeded in setting the system bar properties.'); + }).catch((err: BusinessError) => { + console.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + }); + } catch (exception) { + console.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + } + + 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/NativeTypeSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b37e4b57cd7849ab462574297ff70345c2132ab2 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/CapiSample/NativeType/native_type_sample/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets similarity index 97% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/pages/Index.ets rename to ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets index 8da53caf0c36b574c658a42d5a03a40e5654b2dd..0c09df3daf915533fbf8cd320c77ba4a1a440b2d 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/pages/Index.ets +++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets @@ -26,7 +26,7 @@ struct MenuIndex { private items: ListCategories[] = [ { title: 'Swiper', url: 'pages/page_swiper' }, - { title: 'add your router', url: 'pages/page_swiper' }, + { title: 'text', url: 'pages/page_text' }, ]; build() { diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/pages/page_swiper.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_swiper.ets similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/entry/src/main/ets/pages/page_swiper.ets rename to ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_swiper.ets diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_text.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_text.ets new file mode 100644 index 0000000000000000000000000000000000000000..736e6e97c1ecd00ad31fd7f0236257586c073f16 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_text.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. + */ + +import Napi from 'libentry.so'; +import { NodeContent } from '@kit.ArkUI'; + +@Entry +@Component +struct textComponent { + private nodeContent = new NodeContent(); + aboutToAppear() { + // 通过C-API创建节点,并添加到管理器nodeContent上 + Napi.createNativeTextNode(this.nodeContent); + } + build() { + Column() { + ContentSlot(this.nodeContent) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/module.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6ab131223385e5f7e4f94f0e284489aff17ad82d --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "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": [ + "action.system.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/NativeTypeSample/entry/src/main/resources/base/element/color.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..e14ec8929bece8fe009d91f1145ec962c16661ab --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,12 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background_color", + "value": "#2AA1A6B1" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/float.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/string.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d1558fd0a69ca1e9f26646411b3f5a2c39508286 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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": "native_type_sample" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/background.png b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..a6af93b80c472f148e10c507d751369d50df4077 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,7 @@ +{ + "src": [ + "pages/Index", + "pages/page_swiper", + "pages/page_text" + ] +} diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/dark/element/color.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..bd7fc7c773d766afaad54f86caede9361e448455 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,12 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + }, + { + "name": "background_color", + "value": "#2AA1A6B1" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/NativeTypeSample/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c81579a25ae2430d5c8050c62a1fc14a7b0cf62 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/NativeTypeSample/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cefb5e406030b28a58d7835468d0fe131e352cc0 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/entry/src/ohosTest/module.json5 b/ArkUIKit/NativeTypeSample/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..321c0b4e60f2f4e74219cfac290052130539b178 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * 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", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkUIKit/NativeTypeSample/entry/src/test/List.test.ets b/ArkUIKit/NativeTypeSample/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..74ba3a099410b447742c4a6ecac5c511bb63e5e7 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/entry/src/test/LocalUnit.test.ets b/ArkUIKit/NativeTypeSample/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b367c75db8ae9ad0864a7c14f9bf2ce8c2b5e021 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/NativeTypeSample/hvigor/hvigor-config.json5 b/ArkUIKit/NativeTypeSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c46181e346e0b1a9f966305a9164616bd2db470e --- /dev/null +++ b/ArkUIKit/NativeTypeSample/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "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/NativeTypeSample/hvigorfile.ts b/ArkUIKit/NativeTypeSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..de06c780c9687a49f0161e161816f18af7354ff0 --- /dev/null +++ b/ArkUIKit/NativeTypeSample/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/CapiSample/NativeType/native_type_sample/oh-package.json5 b/ArkUIKit/NativeTypeSample/oh-package.json5 similarity index 100% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/oh-package.json5 rename to ArkUIKit/NativeTypeSample/oh-package.json5 diff --git a/ArkUIKit/CapiSample/NativeType/native_type_sample/ohosTest.md b/ArkUIKit/NativeTypeSample/ohosTest.md similarity index 75% rename from ArkUIKit/CapiSample/NativeType/native_type_sample/ohosTest.md rename to ArkUIKit/NativeTypeSample/ohosTest.md index 0527952b8770adce42fc32c3282e562842b05148..e90656ad312855061e0b9607c06bd0cc58c8b5c7 100644 --- a/ArkUIKit/CapiSample/NativeType/native_type_sample/ohosTest.md +++ b/ArkUIKit/NativeTypeSample/ohosTest.md @@ -7,4 +7,6 @@ | 启动应用 | 设备正常运行 | 1.开启开发板
2.编译hap包并将hap包及环境烧录进开发板,运行测试用例
| 成功拉起应用。 | 否 | 验证通过 | | swiper设置自定义箭头功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第一个swiper左右两侧各有一个圆形的淡灰色的箭头,swiper内容为“0” | 否 | 验证通过 | | swiper设置自定义导航点功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第二个swiper左上角有一个被选中为红色未被选中为灰色的导航栏,swiper内容为“0” | 否 | 验证通过 | -| swiper设置自定义数字导航栏功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第三个swiper左上角显示数字导航栏,左侧数字为1/14,其中数字1为红色,14为灰色,swiper内容为“0” | 否 | 验证通过 | \ No newline at end of file +| swiper设置自定义数字导航栏功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第三个swiper左上角显示数字导航栏,左侧数字为1/14,其中数字1为红色,14为灰色,swiper内容为“0” | 否 | 验证通过 | +| 基础 Text 样式展示 | 应用加载完成 | 1.查看第一段文本 | 1.宽 200vp 高 30vp 带边框,斜体 600 字重,超长跑马灯、不可复制 | 否 | 验证通过 | +| TextInput 输入功能 | 应用加载完成 | 1.点击输入框尝试输入 | 1.支持输入,第一个样式内联,第二个带清除按钮 | 否 | 验证通过 | \ No newline at end of file diff --git a/ArkUIKit/NativeTypeSample/screenshot/nativeType.png b/ArkUIKit/NativeTypeSample/screenshot/nativeType.png new file mode 100644 index 0000000000000000000000000000000000000000..e3cb9030a6cf763030bb783ba247d27185cebbbb Binary files /dev/null and b/ArkUIKit/NativeTypeSample/screenshot/nativeType.png differ