@react-native-ohos/react-native-clippathview 1.1.9-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/harmony/clipPath/BuildProfile.ets +6 -0
  4. package/harmony/clipPath/LICENSE +21 -0
  5. package/harmony/clipPath/OAT.xml +39 -0
  6. package/harmony/clipPath/README.OpenSource +11 -0
  7. package/harmony/clipPath/ResourceTable.txt +0 -0
  8. package/harmony/clipPath/build-profile.json5 +11 -0
  9. package/harmony/clipPath/consumer-rules.txt +0 -0
  10. package/harmony/clipPath/hvigorfile.ts +6 -0
  11. package/harmony/clipPath/index.ets +15 -0
  12. package/harmony/clipPath/obfuscation-rules.txt +18 -0
  13. package/harmony/clipPath/oh-package.json5 +14 -0
  14. package/harmony/clipPath/src/main/cpp/CMakeLists.txt +7 -0
  15. package/harmony/clipPath/src/main/cpp/ClipPathProps.h +127 -0
  16. package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.cpp +102 -0
  17. package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.h +33 -0
  18. package/harmony/clipPath/src/main/cpp/ClipPathViewJSIBinder.h +60 -0
  19. package/harmony/clipPath/src/main/cpp/ClipPathViewNapiBinder.h +79 -0
  20. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.cpp +102 -0
  21. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.h +38 -0
  22. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneJSIBinder.h +61 -0
  23. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNapiBinder.h +80 -0
  24. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.cpp +381 -0
  25. package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.h +98 -0
  26. package/harmony/clipPath/src/main/cpp/ClipPathViewPackage.h +85 -0
  27. package/harmony/clipPath/src/main/cpp/ComponentDescriptors.h +30 -0
  28. package/harmony/clipPath/src/main/cpp/ModUtil.cpp +47 -0
  29. package/harmony/clipPath/src/main/cpp/ModUtil.h +36 -0
  30. package/harmony/clipPath/src/main/cpp/Props.cpp +95 -0
  31. package/harmony/clipPath/src/main/cpp/Props.h +108 -0
  32. package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.cpp +38 -0
  33. package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.h +37 -0
  34. package/harmony/clipPath/src/main/cpp/SVGPathParser.cpp +617 -0
  35. package/harmony/clipPath/src/main/cpp/SVGPathParser.h +71 -0
  36. package/harmony/clipPath/src/main/cpp/SVGViewBox.cpp +94 -0
  37. package/harmony/clipPath/src/main/cpp/SVGViewBox.h +32 -0
  38. package/harmony/clipPath/src/main/cpp/ShadowNodes.cpp +22 -0
  39. package/harmony/clipPath/src/main/cpp/ShadowNodes.h +41 -0
  40. package/harmony/clipPath/src/main/cpp/pen_style_node.h +10 -0
  41. package/harmony/clipPath/src/main/ets/ClipPathPackage.ts +46 -0
  42. package/harmony/clipPath/src/main/ets/ClipPathTurboModule.ts +32 -0
  43. package/harmony/clipPath/src/main/module.json5 +7 -0
  44. package/harmony/clipPath/src/main/resources/base/element/string.json +8 -0
  45. package/harmony/clipPath/src/main/resources/en_US/element/string.json +8 -0
  46. package/harmony/clipPath/src/main/resources/zh_CN/element/string.json +8 -0
  47. package/harmony/clipPath/ts.ts +26 -0
  48. package/harmony/clipPath.har +0 -0
  49. package/index.d.ts +58 -0
  50. package/index.js +5 -0
  51. package/package.json +64 -0
  52. package/react-native-clippath.podspec +30 -0
  53. package/src/ClipPath.android.js +7 -0
  54. package/src/ClipPath.ios.js +5 -0
  55. package/src/ClipPath.web.js +5 -0
  56. package/src/ClipPathH.android.js +6 -0
  57. package/src/ClipPathH.ios.js +5 -0
  58. package/src/ClipPathH.web.js +5 -0
  59. package/src/ClipPathMobile.js +6 -0
  60. package/src/ClipPathMobileN.js +6 -0
  61. package/src/ClipPathNativeComponent.ts +48 -0
  62. package/src/ClipPathWeb.js +345 -0
  63. package/src/demo.jpg +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Juan J LF
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @react-native-oh-tpl/react-native-clippathview
2
+
3
+ This project is based on [react-native-clippathview](https://github.com/Only-IceSoul/react-native-clippath)
4
+
5
+ ## Documentation
6
+
7
+ [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-clippath-capi.md)
8
+
9
+ [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-clippath-capi.md)
10
+
11
+
12
+ ## License
13
+
14
+ This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-clippath/blob/capi/LICENSE).
15
+
@@ -0,0 +1,6 @@
1
+ export default class BuildProfile {
2
+ static readonly HAR_VERSION = '1.1.8-0.2.2';
3
+ static readonly BUILD_MODE_NAME = 'debug';
4
+ static readonly DEBUG = true;
5
+ static readonly TARGET_NAME = 'default';
6
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Juan J LF
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <configuration>
3
+ <oatconfig>
4
+ <licensefile>LICENSE</licensefile>
5
+ <filefilterlist>
6
+ <filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
7
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
8
+ <filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
9
+ <filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
10
+ <filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
11
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
12
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
13
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
14
+ <filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
15
+ </filefilter>
16
+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
17
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
18
+ <filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
19
+ <filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
20
+ <filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
21
+ <filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
22
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
23
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
24
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
25
+ </filefilter>
26
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
27
+ <filteritem type="filename" name="icon.png" desc="应用图标"/>
28
+ <filteritem type="filename" name="app_icon.png" desc="应用图标"/>
29
+ <filteritem type="filename" name="warn.png" desc="页面展示图标"/>
30
+ <filteritem type="filename" name="*.png" desc="展示图标"/>
31
+ </filefilter>
32
+ </filefilterlist>
33
+ <policylist>
34
+ <policy name="projectPolicy" desc="">
35
+ <policyitem type="license" name="Apache" path="src/.*" desc="license under the Apache"/>
36
+ </policy>
37
+ </policylist>
38
+ </oatconfig>
39
+ </configuration>
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "react-native-clippath",
4
+ "License": "MIT License",
5
+ "License File": "https://github.com/Only-IceSoul/react-native-clippath/blob/main/LICENSE",
6
+ "Version Number": "1.1.8",
7
+ "Owner" : "Only-IceSoul"
8
+ "Upstream URL": "https://github.com/Only-IceSoul/react-native-clippath",
9
+ "Description": "ClipPath - Hardware accelerated"
10
+ }
11
+ ]
File without changes
@@ -0,0 +1,11 @@
1
+ {
2
+ "apiType": "stageMode",
3
+ "buildOption": {
4
+ },
5
+ "targets": [
6
+ {
7
+ "name": "default",
8
+ "runtimeOS": "HarmonyOS"
9
+ }
10
+ ]
11
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ export * from './ts'
@@ -0,0 +1,18 @@
1
+ # Define project specific obfuscation rules here.
2
+ # You can include the obfuscation configuration files in the current module's build-profile.json5.
3
+ #
4
+ # For more details, see
5
+ # https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6
+
7
+ # Obfuscation options:
8
+ # -disable-obfuscation: disable all obfuscations
9
+ # -enable-property-obfuscation: obfuscate the property names
10
+ # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11
+ # -compact: remove unnecessary blank spaces and all line feeds
12
+ # -remove-log: remove all console.* statements
13
+ # -print-namecache: print the name cache that contains the mapping from the old names to new names
14
+ # -apply-namecache: reuse the given cache file
15
+
16
+ # Keep options:
17
+ # -keep-property-name: specifies property names that you want to keep
18
+ # -keep-global-name: specifies names that you want to keep in the global scope
@@ -0,0 +1,14 @@
1
+ {
2
+ "license": "MIT License",
3
+ "devDependencies": {
4
+ },
5
+ "author": "",
6
+ "name": "@react-native-ohos/react-native-clippathview",
7
+ "description": "Please describe the basic information.",
8
+ "main": "index.ets",
9
+ "version": "1.1.9-rc.1",
10
+ "dependencies": {
11
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony"
12
+ },
13
+ "compileOnlyDependencies": {}
14
+ }
@@ -0,0 +1,7 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ set(CMAKE_VERBOSE_MAKEFILE on)
3
+
4
+ file(GLOB rnoh_clip_path_SRC CONFIGURE_DEPENDS *.cpp)
5
+ add_library(rnoh_clip_path SHARED ${rnoh_clip_path_SRC})
6
+ target_include_directories(rnoh_clip_path PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
7
+ target_link_libraries(rnoh_clip_path PUBLIC rnoh)
@@ -0,0 +1,127 @@
1
+ //
2
+ // Created on 2024/6/27.
3
+ //
4
+ // Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
5
+ // please include "napi/native_api.h".
6
+
7
+ #pragma once
8
+ #include "ModUtil.h"
9
+ #include <native_drawing/drawing_path.h>
10
+ #include <native_drawing/drawing_pen.h>
11
+ #include <string>
12
+ namespace rnoh {
13
+ class ClipPathProps {
14
+ public:
15
+ float mOpacity{1.0f};
16
+ bool mOpacityStatus{false};
17
+ std::string mMask{""};
18
+ std::string mOldMask{""};
19
+ bool mFillColorStatus{false};
20
+ float mFillOpacity{1.0f};
21
+ bool mFillOpacityStatus{false};
22
+ std::string mFillRule{"none"};
23
+ bool mFillRuleStatus{false};
24
+ bool mStrokeColorStatus{false};
25
+ float mStrokeOpacity{1.0f};
26
+ bool mStrokeOpacityStatus{false};
27
+ float mStrokeWidth{1.0f};
28
+ bool mStrokeWidthStatus{false};
29
+ std::string mStrokeCap{"none"};
30
+ std::string mStrokeJoin{"none"};
31
+ float mStrokeMiter{4.0f};
32
+ bool mStrokeMiterStatus{false};
33
+ float mStrokeStart{0.0f};
34
+ bool mStrokeStartStatus{false};
35
+ float mStrokeEnd{1.0f};
36
+ bool mStrokeEndStatus{false};
37
+ bool mShadowColorStatus{false};
38
+ float mShadowOpacity{0.0f};
39
+ bool mShadowOpacityStatus{false};
40
+ float mShadowRadius{2.0f};
41
+ bool mShadowRadiusStatus{false};
42
+ float mShadowOffsetX{2.0f};
43
+ float mShadowOffsetY{2.0f};
44
+ bool mShadowOffsetIsPercent{false};
45
+ bool mShadowOffsetStatus{false};
46
+
47
+ public:
48
+ float getOpacity() { return ModUtil::clamp(mOpacity); }
49
+
50
+ std::string getMask() { return mMask; }
51
+
52
+ float getFillOpacity() { return ModUtil::clamp(mFillOpacity); }
53
+
54
+ OH_Drawing_PathFillType getFillRule() {
55
+ return mFillRule.compare("evenodd") == 0 ? OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD
56
+ : OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING;
57
+ }
58
+
59
+
60
+ float getStrokeOpacity() { return ModUtil::clamp(mStrokeOpacity); }
61
+
62
+ float getStrokeWidth() { return ModUtil::uClamp(mStrokeWidth, 1.0f); }
63
+
64
+ OH_Drawing_PenLineCapStyle getStrokeCap() {
65
+ return mStrokeCap.compare("round") == 0
66
+ ? OH_Drawing_PenLineCapStyle::LINE_ROUND_CAP
67
+ : (mStrokeCap.compare("square") == 0 ? OH_Drawing_PenLineCapStyle::LINE_SQUARE_CAP
68
+ : OH_Drawing_PenLineCapStyle::LINE_FLAT_CAP);
69
+ }
70
+ OH_Drawing_PenLineJoinStyle getStrokeJoin() {
71
+ return mStrokeJoin.compare("round") == 0
72
+ ? OH_Drawing_PenLineJoinStyle::LINE_ROUND_JOIN
73
+ : (mStrokeJoin.compare("bevel") == 0 ? OH_Drawing_PenLineJoinStyle::LINE_BEVEL_JOIN
74
+ : OH_Drawing_PenLineJoinStyle::LINE_MITER_JOIN);
75
+ }
76
+
77
+ float getStrokeMiter() { return mStrokeMiter; }
78
+
79
+ float getStrokeStart() { return ModUtil::clamp(mStrokeStart); }
80
+
81
+ float getStrokeEnd() { return ModUtil::clamp(mStrokeEnd); }
82
+
83
+
84
+ float getShadowOpacity() { return ModUtil::clamp(mShadowOpacity); }
85
+
86
+ float getShadowRadius() { return ModUtil::uClamp(mShadowRadius); }
87
+
88
+ float getShadowOffsetX() { return mShadowOffsetX; }
89
+
90
+ float getShadowOffsetY() { return mShadowOffsetY; }
91
+
92
+ bool getShadowOffsetIsPercent() { return mShadowOffsetIsPercent; }
93
+
94
+ void set(ClipPathProps props) {
95
+
96
+ if (!mOpacityStatus)
97
+ mOpacity = props.mOpacity;
98
+ if (!mFillOpacityStatus)
99
+ mFillOpacity = props.mFillOpacity;
100
+ if (!mFillRuleStatus)
101
+ mFillRule = props.mFillRule;
102
+ if (!mStrokeOpacityStatus)
103
+ mStrokeOpacity = props.mStrokeOpacity;
104
+ if (!mStrokeWidthStatus)
105
+ mStrokeWidth = props.mStrokeWidth;
106
+ if (mStrokeCap == "none")
107
+ mStrokeCap = props.mStrokeCap;
108
+ if (mStrokeJoin == "none")
109
+ mStrokeJoin = props.mStrokeJoin;
110
+ if (!mStrokeMiterStatus)
111
+ mStrokeMiter = props.mStrokeMiter;
112
+ if (!mStrokeStartStatus)
113
+ mStrokeStart = props.mStrokeStart;
114
+ if (!mStrokeEndStatus)
115
+ mStrokeEnd = props.mStrokeEnd;
116
+ if (!mShadowOpacityStatus)
117
+ mShadowOpacity = props.mShadowOpacity;
118
+ if (!mShadowRadiusStatus)
119
+ mShadowRadius = props.mShadowRadius;
120
+ if (!mShadowOffsetStatus) {
121
+ mShadowOffsetX = props.mShadowOffsetX;
122
+ mShadowOffsetY = props.mShadowOffsetY;
123
+ mShadowOffsetIsPercent = props.mShadowOffsetIsPercent;
124
+ }
125
+ }
126
+ };
127
+ } // namespace rnoh
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ #include "ClipPathViewComponentInstance.h"
17
+ #include "ModUtil.h"
18
+ #include <glog/logging.h>
19
+
20
+ namespace rnoh {
21
+ ClipPathViewComponentInstance::ClipPathViewComponentInstance(Context context)
22
+ : CppComponentInstance(std::move(context)) {
23
+ auto rnInstancePtr = this->m_deps->rnInstance.lock();
24
+ if (rnInstancePtr != nullptr) {
25
+ auto turboModule = rnInstancePtr->getTurboModule("RNCClipPathContext");
26
+ auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
27
+ folly::dynamic result = arkTsTurboModule->callSync("getDensity", {});
28
+ ModUtil::setDensity(static_cast<float>(result.asDouble()));
29
+ }
30
+ }
31
+ void ClipPathViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
32
+ std::size_t index) {
33
+ CppComponentInstance::onChildInserted(childComponentInstance, index);
34
+ mClipPathNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
35
+ }
36
+
37
+ void ClipPathViewComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
38
+ CppComponentInstance::onChildRemoved(childComponentInstance);
39
+ mClipPathNode.removeChild(childComponentInstance->getLocalRootArkUINode());
40
+ };
41
+
42
+ ClipPathViewNoneNode &ClipPathViewComponentInstance::getLocalRootArkUINode() { return mClipPathNode; }
43
+
44
+ void ClipPathViewComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
45
+ CppComponentInstance::onPropsChanged(props);
46
+ if (auto p = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewProps>(props)) {
47
+ mClipPathNode.setD(p->d);
48
+ mClipPathNode.setViewBox(p->viewBox);
49
+ if (p->translateZ != 0) {
50
+ mClipPathNode.setTranslateZ(p->translateZ);
51
+ }
52
+ mClipPathNode.setAlign(p->align);
53
+ mClipPathNode.setAspect(p->aspect);
54
+
55
+ mClipPathNode.setStrokeCap(p->strokeCap);
56
+ mClipPathNode.setStrokeJoin(p->strokeJoin);
57
+ mClipPathNode.setStrokeWidth(p->strokeWidth);
58
+ mClipPathNode.setStrokeMiter(p->strokeMiter);
59
+ mClipPathNode.setStrokeStart(p->strokeStart);
60
+ mClipPathNode.setStrokeEnd(p->strokeEnd);
61
+ mClipPathNode.setFillRule(p->fillRule);
62
+ if (p->rot != 0.0f) {
63
+ mClipPathNode.setRot(p->rot);
64
+ }
65
+ if (p->rotO != 0.0f) {
66
+ mClipPathNode.setRotO(p->rotO);
67
+ }
68
+ if (p->rotOx != 0.0f) {
69
+ mClipPathNode.setRotOx(p->rotOx);
70
+ }
71
+ if (p->rotOy != 0.0f) {
72
+ mClipPathNode.setRotOy(p->rotOy);
73
+ }
74
+
75
+ mClipPathNode.setRotPercentageValue(p->rotPercentageValue);
76
+ if (p->sc != 1.0f) {
77
+ mClipPathNode.setSc(p->sc);
78
+ }
79
+ if (p->scX != 1.0f) {
80
+ mClipPathNode.setScX(p->scX);
81
+ }
82
+ if (p->scY != 1.0f) {
83
+ mClipPathNode.setScY(p->scY);
84
+ }
85
+
86
+ if (p->scO != 0.0f) {
87
+ mClipPathNode.setScO(p->scO);
88
+ }
89
+ if (p->scOx != 0.0f) {
90
+ mClipPathNode.setScOx(p->scOx);
91
+ }
92
+ if (p->scOy != 0.0f) {
93
+ mClipPathNode.setScOy(p->scOy);
94
+ }
95
+ mClipPathNode.setScPercentageValue(p->scPercentageValue);
96
+
97
+ mClipPathNode.setTransX(p->transX);
98
+ mClipPathNode.setTransY(p->transY);
99
+ mClipPathNode.setTransPercentageValue(p->transPercentageValue);
100
+ }
101
+ }
102
+ } // namespace rnoh
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ #include "ClipPathViewNoneNode.h"
17
+ #include "RNOH/CppComponentInstance.h"
18
+ #include "ShadowNodes.h"
19
+
20
+ namespace rnoh {
21
+ class ClipPathViewComponentInstance : public CppComponentInstance<facebook::react::RNCClipPathViewShadowNode> {
22
+ private:
23
+ ClipPathViewNoneNode mClipPathNode;
24
+
25
+ public:
26
+ ClipPathViewComponentInstance(Context context);
27
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
28
+
29
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
30
+ ClipPathViewNoneNode &getLocalRootArkUINode() override;
31
+ void onPropsChanged(SharedConcreteProps const &props) override;
32
+ };
33
+ } // namespace rnoh
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+
17
+ #ifndef HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWJSIBINDER_H
18
+ #define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWJSIBINDER_H
19
+
20
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
21
+
22
+ namespace rnoh {
23
+ class ClipPathViewJSIBinder : public ViewComponentJSIBinder {
24
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
25
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
26
+ object.setProperty(rt, "d", "string");
27
+ object.setProperty(rt, "viewBox", "array");
28
+ object.setProperty(rt, "aspect", "string");
29
+ object.setProperty(rt, "align", "string");
30
+ object.setProperty(rt, "translateZ", "float");
31
+ object.setProperty(rt, "fillRule", "string");
32
+ object.setProperty(rt, "strokeWidth", "float");
33
+ object.setProperty(rt, "strokeCap", "string");
34
+ object.setProperty(rt, "strokeJoin", "string");
35
+ object.setProperty(rt, "strokeMiter", "float");
36
+ object.setProperty(rt, "strokeStart", "float");
37
+ object.setProperty(rt, "strokeEnd", "float");
38
+
39
+ object.setProperty(rt, "sc", "float");
40
+ object.setProperty(rt, "scX", "float");
41
+ object.setProperty(rt, "scY", "float");
42
+ object.setProperty(rt, "scO", "float");
43
+ object.setProperty(rt, "scOx", "float");
44
+ object.setProperty(rt, "scOy", "float");
45
+ object.setProperty(rt, "scPercentageValue", "float");
46
+
47
+ object.setProperty(rt, "rot", "float");
48
+ object.setProperty(rt, "rotO", "float");
49
+ object.setProperty(rt, "rotOx", "float");
50
+ object.setProperty(rt, "rotOy", "float");
51
+ object.setProperty(rt, "rotPercentageValue", "bool");
52
+
53
+ object.setProperty(rt, "transX", "float");
54
+ object.setProperty(rt, "transY", "float");
55
+ object.setProperty(rt, "transPercentageValue", "bool");
56
+ return object;
57
+ }
58
+ };
59
+ } // namespace rnoh
60
+ #endif
@@ -0,0 +1,79 @@
1
+ /*
2
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ #ifndef HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNAPIBINDER_H
17
+ #define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNAPIBINDER_H
18
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentNapiBinder.h"
19
+ #include "Props.h"
20
+
21
+ namespace rnoh {
22
+
23
+ class ClipPathViewNapiBinder : public ViewComponentNapiBinder {
24
+ public:
25
+ napi_value createProps(napi_env env, facebook::react::ShadowView const shadowView) override {
26
+ napi_value napiViewProps = ViewComponentNapiBinder::createProps(env, shadowView);
27
+ auto propsObjBuilder = ArkJS(env).getObjectBuilder(napiViewProps);
28
+
29
+ if (auto props = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewProps>(shadowView.props)) {
30
+ propsObjBuilder.addProperty("d", props->d);
31
+ propsObjBuilder.addProperty("aspect", props->aspect);
32
+ propsObjBuilder.addProperty("align", props->align);
33
+ propsObjBuilder.addProperty("translateZ", props->translateZ);
34
+
35
+ propsObjBuilder.addProperty("fillRule", props->fillRule);
36
+ propsObjBuilder.addProperty("strokeWidth", props->strokeWidth);
37
+ propsObjBuilder.addProperty("strokeCap", props->strokeCap);
38
+ propsObjBuilder.addProperty("strokeJoin", props->strokeJoin);
39
+ propsObjBuilder.addProperty("strokeMiter", props->strokeMiter);
40
+ propsObjBuilder.addProperty("strokeStart", props->strokeStart);
41
+ propsObjBuilder.addProperty("strokeEnd", props->strokeEnd);
42
+
43
+ propsObjBuilder.addProperty("sc", props->sc);
44
+ propsObjBuilder.addProperty("scX", props->scX);
45
+ propsObjBuilder.addProperty("scY", props->scY);
46
+ propsObjBuilder.addProperty("scO", props->scO);
47
+ propsObjBuilder.addProperty("scOx", props->scOx);
48
+ propsObjBuilder.addProperty("scOy", props->scOy);
49
+ propsObjBuilder.addProperty("scPercentageValue", props->scPercentageValue);
50
+
51
+ propsObjBuilder.addProperty("rot", props->rot);
52
+ propsObjBuilder.addProperty("rotO", props->rotO);
53
+ propsObjBuilder.addProperty("rotOx", props->rotOx);
54
+ propsObjBuilder.addProperty("rotOy", props->rotOy);
55
+ propsObjBuilder.addProperty("rotPercentageValue", props->rotPercentageValue);
56
+
57
+ propsObjBuilder.addProperty("transX", props->transX);
58
+ propsObjBuilder.addProperty("transY", props->transY);
59
+ propsObjBuilder.addProperty("transPercentageValue", props->transPercentageValue);
60
+ auto boxArray = std::vector<napi_value>();
61
+ auto boxArrayRaw = props->viewBox;
62
+
63
+ for (auto item : boxArrayRaw) {
64
+ auto itemObjBuilder = ArkJS(env).createDouble(item);
65
+ boxArray.push_back(itemObjBuilder);
66
+ }
67
+
68
+ auto boxArrayArray = ArkJS(env).createArray(boxArray);
69
+
70
+ propsObjBuilder.addProperty("viewBox", boxArrayArray);
71
+
72
+ return propsObjBuilder.build();
73
+ }
74
+ return napiViewProps;
75
+ };
76
+ };
77
+
78
+ } // namespace rnoh
79
+ #endif