diff --git a/OAT.xml b/OAT.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a247f4392037143a9535fc31c38c554b3d7be040
--- /dev/null
+++ b/OAT.xml
@@ -0,0 +1,64 @@
+
+
+
+ LICENSE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c9465f7a80c7139c57ac4cd013dfdcaeb050b9a5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# @react-native-ohos/react-native-linear-gradient
+
+This project is based on [react-native-linear-gradient](https://github.com/react-native-linear-gradient/react-native-linear-gradient)
+
+## Documentation
+
+[中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-linear-gradient.md)
+
+[English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-linear-gradient.md)
+
+
+## License
+
+This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-linear-gradient/blob/sig/LICENSE).
+
diff --git a/harmony/linear_gradient/.gitignore b/harmony/linear_gradient/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/harmony/linear_gradient/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/harmony/linear_gradient/build-profile.json5 b/harmony/linear_gradient/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edb0aee0da6d32b99f32f7c5c2d6241b01561901
--- /dev/null
+++ b/harmony/linear_gradient/build-profile.json5
@@ -0,0 +1,8 @@
+{
+ "apiType": "stageMode",
+ "targets": [
+ {
+ "name": "default",
+ }
+ ]
+}
diff --git a/harmony/linear_gradient/hvigorfile.ts b/harmony/linear_gradient/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..120de5c3954f9e94e9725d4f2504f4c75a617733
--- /dev/null
+++ b/harmony/linear_gradient/hvigorfile.ts
@@ -0,0 +1 @@
+export { harTasks } from '@ohos/hvigor-ohos-plugin';
\ No newline at end of file
diff --git a/harmony/linear_gradient/index.ets b/harmony/linear_gradient/index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9983c71df6a9e6328269d78eb5a108f72a8a1354
--- /dev/null
+++ b/harmony/linear_gradient/index.ets
@@ -0,0 +1,25 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+// NO-OP
\ No newline at end of file
diff --git a/harmony/linear_gradient/oh-package.json5 b/harmony/linear_gradient/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..486b9bdef546f1c775876f3a160705e6ac510df6
--- /dev/null
+++ b/harmony/linear_gradient/oh-package.json5
@@ -0,0 +1,8 @@
+{
+ "name": "@react-native-ohos/react-native-linear-gradient",
+ "version": "3.0.0-alpha.1",
+ "description": "react-native-linear-gradient for RNOH.",
+ "main": "index.ets",
+ "license": "MIT",
+ "dependencies": {}
+}
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/cpp/CMakeLists.txt b/harmony/linear_gradient/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c03fd0104299a048b55c7ef3c381dacc9c1ffa58
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.13)
+set(CMAKE_VERBOSE_MAKEFILE on)
+
+set(rnoh_linear_gradient_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
+file(GLOB_RECURSE rnoh_linear_gradient_generated_SRC "${rnoh_linear_gradient_generated_dir}/**/*.cpp")
+file(GLOB rnoh_linear_gradient_SRC CONFIGURE_DEPENDS *.cpp)
+add_library(rnoh_linear_gradient SHARED ${rnoh_linear_gradient_SRC} ${rnoh_linear_gradient_generated_SRC})
+target_include_directories(rnoh_linear_gradient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_linear_gradient_generated_dir})
+target_link_libraries(rnoh_linear_gradient PUBLIC rnoh)
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.cpp b/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47e3f4aee65f5bf1fba9368deab8db3100ba230f
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.cpp
@@ -0,0 +1,138 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "LinearGradientComponentInstance.h"
+#include
+
+namespace rnoh {
+
+constexpr float STRAIGHT_ANGLE = 180.0f;
+constexpr float RIGHT_ANGLE = 90.0f;
+constexpr float FULL_STOP = 1.0f;
+
+LinearGradientComponentInstance::LinearGradientComponentInstance(Context context)
+ : BaseRNLinearGradientComponentInstance(std::move(context)) {}
+
+void LinearGradientComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
+ std::size_t index) {
+ Super::onChildInserted(childComponentInstance, index);
+ m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
+}
+
+void LinearGradientComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
+ Super::onChildRemoved(childComponentInstance);
+ m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
+};
+
+LinearGradientStackNode &LinearGradientComponentInstance::getLocalRootArkUINode() { return m_stackNode; }
+
+void LinearGradientComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
+ Super::onPropsChanged(props);
+ m_colors = props->colors;
+ m_angle = props->angle;
+ m_useAngle = props->useAngle;
+ m_locations = props->locations;
+ m_startPoint = props->startPoint;
+ m_endPoint = props->endPoint;
+ m_angleCenter = props->angleCenter;
+ this->getLinearGradient();
+ this->getLocalRootArkUINode().setLinearGradient(m_colors, m_stops, static_cast(m_angle),
+ ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM, false);
+}
+
+void LinearGradientComponentInstance::getLinearGradient() {
+ if (m_colors.size() == 0 ||
+ m_locations.size() != 0 && (m_locations.size() != 0 && m_colors.size() != m_locations.size())) {
+ m_angle = 0;
+ return;
+ }
+ if (m_useAngle && m_angleCenter == facebook::react::Point{0, 0}) {
+ // OH dose not support angleCenter
+ } else {
+ if (!m_useAngle) {
+ m_angle = this->computeAngle(m_startPoint, m_endPoint);
+ }
+ }
+ if (m_locations.size() != 0) {
+ for (int index = 0; index < m_colors.size(); index++) {
+ m_stops.push_back(static_cast(m_locations[index]));
+ }
+ } else {
+ this->computeStops();
+ }
+ return;
+}
+
+void LinearGradientComponentInstance::computeStops() {
+ float startPointX = m_startPoint.x > 0 ? m_startPoint.x : 0.0;
+ float startPointY = m_startPoint.y > 0 ? m_startPoint.y : 0.0;
+ float endPointX = m_endPoint.x > 0 ? m_endPoint.x : 0.0;
+ float endPointY = m_endPoint.y > 0 ? m_endPoint.y : 0.0;
+ // 确定 pointMin 和 pointMax 值
+ float pointMax = 0.0;
+ float pointMin = 0.0;
+ if (startPointX == endPointX) {
+ pointMin = std::min(startPointY, endPointY);
+ pointMax = std::max(startPointY, endPointY);
+ } else if (startPointY == endPointY) {
+ pointMin = std::min(startPointX, endPointX);
+ pointMax = std::max(startPointX, endPointX);
+ } else {
+ float pointMinX = std::min(startPointX, endPointX);
+ float pointMaxX = std::max(startPointX, endPointX);
+ float pointMinY = std::min(startPointY, endPointY);
+ float pointMaxY = std::max(startPointY, endPointY);
+ pointMin = (pointMaxY - pointMinY < pointMaxX - pointMinX) ? pointMinX : pointMinY;
+ pointMax = (pointMaxY - pointMinY < pointMaxX - pointMinX) ? pointMaxX : pointMaxY;
+ }
+ // 确定每个颜色在渐变中的分布位置
+ int colorsSize = m_colors.size();
+ if (colorsSize == 1) {
+ m_stops.push_back(1);
+ } else {
+ for (int index = 0; index < colorsSize; ++index) {
+ if (index == 0) {
+ m_stops.push_back(pointMin);
+ } else if (index == colorsSize - 1) {
+ m_stops.push_back(pointMax);
+ } else {
+ m_stops.push_back(pointMin + index * 1.0f / (colorsSize - 1) * (pointMax - pointMin));
+ }
+ }
+ }
+}
+
+facebook::react::Float LinearGradientComponentInstance::computeAngle(facebook::react::Point const &start,
+ facebook::react::Point const &end) {
+ if (start.x == end.x) {
+ return (start.y < end.y) ? STRAIGHT_ANGLE : 0;
+ }
+ if (start.y == end.y) {
+ return (start.x < end.x) ? RIGHT_ANGLE : -RIGHT_ANGLE;
+ }
+
+ float tanAngle = (end.x - start.x) / (end.y - start.y);
+ return STRAIGHT_ANGLE - atan(tanAngle) * STRAIGHT_ANGLE / M_PI;
+}
+} // namespace rnoh
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.h b/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.h
new file mode 100644
index 0000000000000000000000000000000000000000..f2b02dc8ad2bfa6955c0a4ca5e39b4bcd4bc4eea
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/LinearGradientComponentInstance.h
@@ -0,0 +1,61 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#pragma once
+
+#include "RNOH/CppComponentInstance.h"
+#include "LinearGradientStackNode.h"
+#include "generated/react/renderer/components/react_native_linear_gradient/Props.h"
+#include "generated/RNOH/generated/components/BaseRNLinearGradientComponentInstance.h"
+
+namespace rnoh {
+class LinearGradientComponentInstance : public BaseRNLinearGradientComponentInstance {
+ using Super = BaseRNLinearGradientComponentInstance;
+
+private:
+ LinearGradientStackNode m_stackNode;
+ std::vector m_colors;
+ facebook::react::Float m_angle;
+ bool m_useAngle;
+ std::vector m_locations;
+ facebook::react::Point m_startPoint;
+ facebook::react::Point m_endPoint;
+ facebook::react::Point m_angleCenter;
+ std::vector m_stops;
+ void getLinearGradient();
+ void computeStops();
+
+public:
+ explicit LinearGradientComponentInstance(Context context);
+
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
+
+ LinearGradientStackNode &getLocalRootArkUINode() override;
+
+ void onPropsChanged(SharedConcreteProps const &props) override;
+
+ facebook::react::Float computeAngle(facebook::react::Point const &start, facebook::react::Point const &end);
+};
+} // namespace rnoh
diff --git a/harmony/linear_gradient/src/main/cpp/LinearGradientPackage.h b/harmony/linear_gradient/src/main/cpp/LinearGradientPackage.h
new file mode 100644
index 0000000000000000000000000000000000000000..311be9a2a7f7d20e70e31fcc0225993e19fec0d6
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/LinearGradientPackage.h
@@ -0,0 +1,45 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#pragma once
+
+#include "LinearGradientComponentInstance.h"
+#include "RNOH/generated/BaseReactNativeLinearGradientPackage.h"
+
+namespace rnoh {
+
+class LinearGradientPackage : public BaseReactNativeLinearGradientPackage {
+ using Super = BaseReactNativeLinearGradientPackage;
+
+public:
+ LinearGradientPackage(Package::Context ctx) : Super(ctx) {}
+
+ ComponentInstance::Shared createComponentInstance(const ComponentInstance::Context &ctx) {
+ if (ctx.componentName == "RNLinearGradient") {
+ return std::make_shared(ctx);
+ }
+ return nullptr;
+ };
+};
+} // namespace rnoh
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.cpp b/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5680e92ed20299ba343454b2b6f512dea4d78669
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.cpp
@@ -0,0 +1,58 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "LinearGradientStackNode.h"
+#include "RNOH/arkui/NativeNodeApi.h"
+
+namespace rnoh {
+LinearGradientStackNode::LinearGradientStackNode()
+ : ArkUINode(NativeNodeApi::getInstance()->createNode(ArkUI_NodeType::ARKUI_NODE_STACK)) {}
+
+void LinearGradientStackNode::insertChild(ArkUINode &child, std::size_t index) {
+ maybeThrow(NativeNodeApi::getInstance()->insertChildAt(m_nodeHandle, child.getArkUINodeHandle(), index));
+}
+
+void LinearGradientStackNode::removeChild(ArkUINode &child) {
+ maybeThrow(NativeNodeApi::getInstance()->removeChild(m_nodeHandle, child.getArkUINodeHandle()));
+}
+LinearGradientStackNode &
+LinearGradientStackNode::setLinearGradient(const std::vector &colors,
+ std::vector const &stops, const float &angle,
+ const ArkUI_LinearGradientDirection &direction, const bool &repeating) {
+ std::vector colorsInput;
+ std::vector stopsInput = stops;
+ for (auto color : colors) {
+ uint32_t colorValue = *color;
+ colorsInput.push_back(colorValue);
+ }
+ ArkUI_ColorStop colorStop = {colorsInput.data(), stopsInput.data(), static_cast(colorsInput.size())};
+ ArkUI_NumberValue linearGradientValue[] = {angle, {.u32 = direction}, static_cast(repeating)};
+ ArkUI_AttributeItem linearGradientItem = {linearGradientValue,
+ sizeof(linearGradientValue) / sizeof(ArkUI_NumberValue),
+ .object = reinterpret_cast(&colorStop)};
+ maybeThrow(NativeNodeApi::getInstance()->setAttribute(m_nodeHandle, NODE_LINEAR_GRADIENT, &linearGradientItem));
+ return *this;
+}
+
+} // namespace rnoh
diff --git a/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.h b/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d8a9014ca119810bb522c7438b5d036262a2d30
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/LinearGradientStackNode.h
@@ -0,0 +1,43 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#pragma once
+
+#include "RNOH/arkui/ArkUINode.h"
+#include "RNOH/arkui/StackNode.h"
+#include
+
+namespace rnoh {
+class LinearGradientStackNode : public ArkUINode {
+public:
+ LinearGradientStackNode();
+
+ void insertChild(ArkUINode &child, std::size_t index);
+ void removeChild(ArkUINode &child);
+
+ LinearGradientStackNode &setLinearGradient(std::vector const &,
+ std::vector const &, float const &,
+ ArkUI_LinearGradientDirection const &, bool const &);
+};
+} // namespace rnoh
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/BaseReactNativeLinearGradientPackage.h b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/BaseReactNativeLinearGradientPackage.h
new file mode 100644
index 0000000000000000000000000000000000000000..ba295d572cf0f0c9ecb3ef0989c53b0858e0dbec
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/BaseReactNativeLinearGradientPackage.h
@@ -0,0 +1,65 @@
+/**
+ * This code was generated by "react-native codegen-lib-harmony"
+ */
+
+#pragma once
+
+#include
+#include "RNOH/Package.h"
+#include "RNOH/ArkTSTurboModule.h"
+#include "RNOH/generated/components/RNLinearGradientJSIBinder.h"
+
+namespace rnoh {
+
+class BaseReactNativeLinearGradientPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
+ public:
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
+ return nullptr;
+ };
+};
+
+class BaseReactNativeLinearGradientPackageEventEmitRequestHandler : public EventEmitRequestHandler {
+ public:
+ void handleEvent(Context const &ctx) override {
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter(ctx.tag);
+ if (eventEmitter == nullptr) {
+ return;
+ }
+
+ std::vector supportedEventNames = {
+ };
+ if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
+ }
+ }
+};
+
+
+class BaseReactNativeLinearGradientPackage : public Package {
+ public:
+ BaseReactNativeLinearGradientPackage(Package::Context ctx) : Package(ctx){};
+
+ std::unique_ptr createTurboModuleFactoryDelegate() override {
+ return std::make_unique();
+ }
+
+ std::vector createComponentDescriptorProviders() override {
+ return {
+ facebook::react::concreteComponentDescriptorProvider(),
+ };
+ }
+
+ ComponentJSIBinderByString createComponentJSIBinderByName() override {
+ return {
+ {"RNLinearGradient", std::make_shared()},
+ };
+ };
+
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override {
+ return {
+ std::make_shared(),
+ };
+ }
+};
+
+} // namespace rnoh
diff --git a/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/BaseRNLinearGradientComponentInstance.h b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/BaseRNLinearGradientComponentInstance.h
new file mode 100644
index 0000000000000000000000000000000000000000..5eedf8a5daf89ced2069519a707a753d5e3bd258
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/BaseRNLinearGradientComponentInstance.h
@@ -0,0 +1,21 @@
+
+/**
+ * This code was generated by "react-native codegen-lib-harmony"
+ */
+
+#pragma once
+
+#include "RNOH/CppComponentInstance.h"
+#include
+
+namespace rnoh {
+ class BaseRNLinearGradientComponentInstance
+ : public CppComponentInstance {
+ public:
+ using CppComponentInstance::CppComponentInstance;
+
+ void handleCommand(std::string const &commandName, folly::dynamic const &args) override {
+ }
+
+ };
+} // namespace rnoh
diff --git a/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/RNLinearGradientJSIBinder.h b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/RNLinearGradientJSIBinder.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f5b3e773161249f92f919a1e9a21bd46dc57e82
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/RNOH/generated/components/RNLinearGradientJSIBinder.h
@@ -0,0 +1,34 @@
+/**
+ * This code was generated by "react-native codegen-lib-harmony"
+ */
+
+#pragma once
+#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
+
+namespace rnoh {
+class RNLinearGradientJSIBinder : public ViewComponentJSIBinder {
+ protected:
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
+ object.setProperty(rt, "startPoint", true);
+ object.setProperty(rt, "endPoint", true);
+ object.setProperty(rt, "colors", true);
+ object.setProperty(rt, "locations", true);
+ object.setProperty(rt, "useAngle", true);
+ object.setProperty(rt, "angleCenter", true);
+ object.setProperty(rt, "angle", true);
+ object.setProperty(rt, "borderRadii", true);
+ return object;
+ }
+
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
+ facebook::jsi::Object events(rt);
+ return events;
+ }
+
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
+ facebook::jsi::Object events(rt);
+ return events;
+ }
+};
+} // namespace rnoh
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ComponentDescriptors.h b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ComponentDescriptors.h
new file mode 100644
index 0000000000000000000000000000000000000000..1caa8a3f4bb3efb1796bb81f5436bb72e08ee5f6
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ComponentDescriptors.h
@@ -0,0 +1,22 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateComponentDescriptorH.js
+ */
+
+#pragma once
+
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+using RNLinearGradientComponentDescriptor = ConcreteComponentDescriptor;
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.cpp b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4afd2258ab06ce6c5d93d8199ddfe0a388c5c503
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.cpp
@@ -0,0 +1,18 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateEventEmitterCpp.js
+ */
+
+#include
+
+
+namespace facebook {
+namespace react {
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.h b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.h
new file mode 100644
index 0000000000000000000000000000000000000000..4df2f14edc2d6b2ceeffd0d95811395efd0cf739
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/EventEmitters.h
@@ -0,0 +1,25 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateEventEmitterH.js
+ */
+#pragma once
+
+#include
+
+
+namespace facebook {
+namespace react {
+class RNLinearGradientEventEmitter : public ViewEventEmitter {
+ public:
+ using ViewEventEmitter::ViewEventEmitter;
+
+
+
+};
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.cpp b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..32300640de1f0940e728e6ca74560f33d4919968
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.cpp
@@ -0,0 +1,34 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GeneratePropsCpp.js
+ */
+
+#include
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+RNLinearGradientProps::RNLinearGradientProps(
+ const PropsParserContext &context,
+ const RNLinearGradientProps &sourceProps,
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
+
+ startPoint(convertRawProp(context, rawProps, "startPoint", sourceProps.startPoint, {})),
+ endPoint(convertRawProp(context, rawProps, "endPoint", sourceProps.endPoint, {})),
+ colors(convertRawProp(context, rawProps, "colors", sourceProps.colors, {})),
+ locations(convertRawProp(context, rawProps, "locations", sourceProps.locations, {})),
+ useAngle(convertRawProp(context, rawProps, "useAngle", sourceProps.useAngle, {false})),
+ angleCenter(convertRawProp(context, rawProps, "angleCenter", sourceProps.angleCenter, {})),
+ angle(convertRawProp(context, rawProps, "angle", sourceProps.angle, {0.0})),
+ borderRadii(convertRawProp(context, rawProps, "borderRadii", sourceProps.borderRadii, {}))
+ {}
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.h b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.h
new file mode 100644
index 0000000000000000000000000000000000000000..bc17fda00598b41672beabfd6a296717df01f4b1
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/Props.h
@@ -0,0 +1,39 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GeneratePropsH.js
+ */
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+class RNLinearGradientProps final : public ViewProps {
+ public:
+ RNLinearGradientProps() = default;
+ RNLinearGradientProps(const PropsParserContext& context, const RNLinearGradientProps &sourceProps, const RawProps &rawProps);
+
+#pragma mark - Props
+
+ Point startPoint{};
+ Point endPoint{};
+ std::vector colors{};
+ std::vector locations{};
+ bool useAngle{false};
+ Point angleCenter{};
+ Float angle{0.0};
+ std::vector borderRadii{};
+};
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.cpp b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0cd5de12c2b8fca57077ed65563ddfef8b016cab
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.cpp
@@ -0,0 +1,19 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateShadowNodeCpp.js
+ */
+
+#include
+
+namespace facebook {
+namespace react {
+
+extern const char RNLinearGradientComponentName[] = "RNLinearGradient";
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.h b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b44c7adc90df6f28ff35a52a65d478b9ca68f6f
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/ShadowNodes.h
@@ -0,0 +1,34 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateShadowNodeH.js
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+JSI_EXPORT extern const char RNLinearGradientComponentName[];
+
+/*
+ * `ShadowNode` for component.
+ */
+using RNLinearGradientShadowNode = ConcreteViewShadowNode<
+ RNLinearGradientComponentName,
+ RNLinearGradientProps,
+ RNLinearGradientEventEmitter,
+ RNLinearGradientState>;
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.cpp b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bebc48b87018f2c009df986aa95d088e97b8cc82
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.cpp
@@ -0,0 +1,18 @@
+
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateStateCpp.js
+ */
+#include
+
+namespace facebook {
+namespace react {
+
+
+
+} // namespace react
+} // namespace facebook
diff --git a/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.h b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.h
new file mode 100644
index 0000000000000000000000000000000000000000..d6af49e8f11aff30c38733bf73c5c6461b2d48b2
--- /dev/null
+++ b/harmony/linear_gradient/src/main/cpp/generated/react/renderer/components/react_native_linear_gradient/States.h
@@ -0,0 +1,36 @@
+/**
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
+ *
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
+ * once the code is regenerated.
+ *
+ * @generated by codegen project: GenerateStateH.js
+ */
+#pragma once
+
+#ifdef ANDROID
+#include
+#include
+#include
+#endif
+
+namespace facebook {
+namespace react {
+
+class RNLinearGradientState {
+public:
+ RNLinearGradientState() = default;
+
+#ifdef ANDROID
+ RNLinearGradientState(RNLinearGradientState const &previousState, folly::dynamic data){};
+ folly::dynamic getDynamic() const {
+ return {};
+ };
+ MapBuffer getMapBuffer() const {
+ return MapBufferBuilder::EMPTY();
+ };
+#endif
+};
+
+} // namespace react
+} // namespace facebook
\ No newline at end of file
diff --git a/harmony/linear_gradient/src/main/module.json5 b/harmony/linear_gradient/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..29ef246679e2c1085be5bcb2a358a2dd221a4f18
--- /dev/null
+++ b/harmony/linear_gradient/src/main/module.json5
@@ -0,0 +1,9 @@
+{
+ "module": {
+ "name": "linear_gradient",
+ "type": "har",
+ "deviceTypes": [
+ "default"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/index.harmony.js b/index.harmony.js
new file mode 100644
index 0000000000000000000000000000000000000000..0f91fe35df50b905d216b631da2fb69edbdcdf2d
--- /dev/null
+++ b/index.harmony.js
@@ -0,0 +1,77 @@
+/**
+ * @providesModule LinearGradient
+ * @flow
+ */
+import React, { Component, createRef } from 'react';
+import { processColor, StyleSheet, View } from 'react-native';
+
+import NativeLinearGradient, { type Props } from './src';
+
+const convertPoint = (name, point) => {
+ if (Array.isArray(point)) {
+ console.warn(
+ `LinearGradient '${name}' property should be an object with fields 'x' and 'y', ` +
+ 'Array type is deprecated.'
+ );
+
+ return {
+ x: point[0],
+ y: point[1]
+ };
+ }
+ return point;
+};
+
+export default class LinearGradient extends Component {
+ props: Props;
+ gradientRef = createRef();
+
+ static defaultProps = {
+ start: { x: 0.5, y: 0.0 },
+ end: { x: 0.5, y: 1.0 },
+ };
+
+ setNativeProps(props: Props) {
+ this.gradientRef.current.setNativeProps(props);
+ }
+
+ render() {
+ const {
+ children,
+ style,
+ start,
+ end,
+ colors,
+ locations,
+ useAngle,
+ angleCenter,
+ angle,
+ ...otherProps
+ } = this.props;
+ if ((colors && locations) && (colors.length !== locations.length)) {
+ console.warn('LinearGradient colors and locations props should be arrays of the same length');
+ }
+
+ return (
+
+
+ {children}
+
+ );
+ }
+
+ styles = StyleSheet.create({
+ LinearGradientContainer: {
+ overflow: 'hidden',
+ },
+ })
+}
diff --git a/index.js b/index.js
index d0403550e46de3055ab3556a755c2eaf4e0235a4..4bb978767b9a9c241c49e3ec94cf06b121a3d9d1 100644
--- a/index.js
+++ b/index.js
@@ -1,10 +1,6 @@
import { Platform } from "react-native";
-import LinearGradientIos from "./index.ios.js";
-import LinearGradientAndroid from "./index.android.js";
-import LinearGradientWindows from "./index.windows.js";
+import LinearGradientHarmony from "./index.harmony.js";
-export const LinearGradient = Platform.OS === "ios"
- ? LinearGradientIos : Platform.OS === "android"
- ? LinearGradientAndroid : LinearGradientWindows;
+export const LinearGradient = LinearGradientHarmony;
export default LinearGradient;
diff --git a/package.json b/package.json
index 42232c3957cb58666a750fe535393fc1b01cdb26..70b0ce3baa529b73c8db312ddbc040af52b0f934 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,16 @@
{
- "name": "react-native-linear-gradient",
+ "name": "@react-native-ohos/react-native-linear-gradient",
"version": "3.0.0-alpha.1",
"description": "A element for React Native",
"main": "index.js",
"types": "index.d.ts",
+ "harmony": {
+ "alias": "react-native-linear-gradient"
+ },
"files": [
+ "harmony",
"src",
+ "index.harmony.js",
"index.d.ts"
],
"scripts": {