@react-native-ohos/react-native-safe-area-context 4.7.5-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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +11 -0
  4. package/harmony/safe_area/LICENSE +21 -0
  5. package/harmony/safe_area/NOTICE +33 -0
  6. package/harmony/safe_area/build-profile.json5 +9 -0
  7. package/harmony/safe_area/hvigorfile.ts +6 -0
  8. package/harmony/safe_area/index.ets +28 -0
  9. package/harmony/safe_area/oh-package.json5 +15 -0
  10. package/harmony/safe_area/src/main/cpp/CMakeLists.txt +9 -0
  11. package/harmony/safe_area/src/main/cpp/SafeAreaBeanData.h +55 -0
  12. package/harmony/safe_area/src/main/cpp/SafeAreaColumnNode.cpp +46 -0
  13. package/harmony/safe_area/src/main/cpp/SafeAreaColumnNode.h +39 -0
  14. package/harmony/safe_area/src/main/cpp/SafeAreaManagerMap.cpp +65 -0
  15. package/harmony/safe_area/src/main/cpp/SafeAreaManagerMap.h +42 -0
  16. package/harmony/safe_area/src/main/cpp/SafeAreaProviderComponentInstance.cpp +81 -0
  17. package/harmony/safe_area/src/main/cpp/SafeAreaProviderComponentInstance.h +47 -0
  18. package/harmony/safe_area/src/main/cpp/SafeAreaStackNode.cpp +78 -0
  19. package/harmony/safe_area/src/main/cpp/SafeAreaStackNode.h +29 -0
  20. package/harmony/safe_area/src/main/cpp/SafeAreaViewComponentInstance.cpp +103 -0
  21. package/harmony/safe_area/src/main/cpp/SafeAreaViewComponentInstance.h +58 -0
  22. package/harmony/safe_area/src/main/cpp/SafeAreaViewPackage.h +60 -0
  23. package/harmony/safe_area/src/main/cpp/TurboModuleRequest.cpp +63 -0
  24. package/harmony/safe_area/src/main/cpp/TurboModuleRequest.h +32 -0
  25. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/BaseReactNativeSafeAreaContextPackage.h +75 -0
  26. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/BaseRNCSafeAreaProviderComponentInstance.h +19 -0
  27. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/BaseRNCSafeAreaViewComponentInstance.h +19 -0
  28. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/RNCSafeAreaProviderJSIBinder.h +28 -0
  29. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/RNCSafeAreaViewJSIBinder.h +33 -0
  30. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCSafeAreaContext.cpp +17 -0
  31. package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCSafeAreaContext.h +15 -0
  32. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ComponentDescriptors.h +21 -0
  33. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/EventEmitters.cpp +57 -0
  34. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/EventEmitters.h +62 -0
  35. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/Props.cpp +33 -0
  36. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/Props.h +99 -0
  37. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ShadowNodes.cpp +18 -0
  38. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ShadowNodes.h +29 -0
  39. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/States.cpp +15 -0
  40. package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/States.h +20 -0
  41. package/harmony/safe_area/src/main/ets/Logger.ts +64 -0
  42. package/harmony/safe_area/src/main/ets/SafeAreaProvider.ets +128 -0
  43. package/harmony/safe_area/src/main/ets/SafeAreaProviderModifier.ets +121 -0
  44. package/harmony/safe_area/src/main/ets/SafeAreaView.ets +242 -0
  45. package/harmony/safe_area/src/main/ets/SafeAreaViewModifier.ets +140 -0
  46. package/harmony/safe_area/src/main/ets/SafeAreaViewPackage.ets +47 -0
  47. package/harmony/safe_area/src/main/ets/SafeViewTurboModule.ts +131 -0
  48. package/harmony/safe_area/src/main/ets/common/SafeAreaType.ts +70 -0
  49. package/harmony/safe_area/src/main/module.json5 +7 -0
  50. package/harmony/safe_area/src/main/resources/base/element/string.json +8 -0
  51. package/harmony/safe_area/src/main/resources/en_US/element/string.json +8 -0
  52. package/harmony/safe_area/src/main/resources/zh_CN/element/string.json +8 -0
  53. package/harmony/safe_area/ts.ets +26 -0
  54. package/harmony/safe_area.har +0 -0
  55. package/package.json +139 -0
  56. package/src/SafeArea.types.ts +47 -0
  57. package/src/SafeAreaView.tsx +201 -0
  58. package/src/index.tsx +4 -0
  59. package/src/specs/NativeSafeAreaContext.ts +23 -0
  60. package/src/specs/NativeSafeAreaProvider.ts +29 -0
  61. package/src/specs/NativeSafeAreaView.ts +28 -0
@@ -0,0 +1,103 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ #include "SafeAreaViewComponentInstance.h"
25
+ #include "TurboModuleRequest.h"
26
+ #include "SafeAreaManagerMap.h"
27
+
28
+ namespace rnoh {
29
+
30
+ SafeAreaViewComponentInstance::SafeAreaViewComponentInstance(Context context)
31
+ : BaseRNCSafeAreaViewComponentInstance(std::move(context))
32
+ {
33
+ m_safeAreaViewStackNode.setStackNodeDelegate(this);
34
+ }
35
+
36
+ void SafeAreaViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
37
+ std::size_t index)
38
+ {
39
+ super::onChildInserted(childComponentInstance, index);
40
+ m_safeAreaViewStackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
41
+ }
42
+
43
+ void SafeAreaViewComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance)
44
+ {
45
+ super::onChildRemoved(childComponentInstance);
46
+ m_safeAreaViewStackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
47
+ };
48
+
49
+ SafeAreaStackNode &SafeAreaViewComponentInstance::getLocalRootArkUINode() { return m_safeAreaViewStackNode; }
50
+
51
+ void SafeAreaViewComponentInstance::updateInsert(SharedConcreteProps p)
52
+ {
53
+ auto parentNodeHandle = findParentNodeHandle(m_safeAreaViewStackNode.getArkUINodeHandle());
54
+ DLOG(INFO) << "SafeAreaViewComponentInstance findParentNodeHandle "
55
+ << parentNodeHandle.nodeHandle << " hasSafeAreaProvider "
56
+ << parentNodeHandle.hasSafeAreaProvider;
57
+ if (parentNodeHandle.hasSafeAreaProvider) {
58
+ TurboModuleRequest request;
59
+ safeArea::Event data = request.getTurboModuleData(this->m_deps);
60
+ facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {data.insets.top, data.insets.right,
61
+ data.insets.bottom, data.insets.left};
62
+ m_eventEmitter->onSafeAreaValueChange(inset);
63
+ } else {
64
+ facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {0, 0, 0, 0};
65
+ m_eventEmitter->onSafeAreaValueChange(inset);
66
+ }
67
+ }
68
+
69
+ SafeAreaViewComponentInstance::ParentNodeInfo SafeAreaViewComponentInstance::findParentNodeHandle(
70
+ ArkUI_NodeHandle nodehandle)
71
+ {
72
+ ParentNodeInfo parentNodeInfo;
73
+ if (!nodehandle) {
74
+ return parentNodeInfo;
75
+ }
76
+ auto parentNode = OH_ArkUI_NodeUtils_GetParentInPageTree(nodehandle);
77
+ bool hasSafeAreaProvider = SafeAreaManagerMap::getInstance().GetHasSafeAreaProviderByNodeHandle(parentNode);
78
+ parentNodeInfo.hasSafeAreaProvider = hasSafeAreaProvider;
79
+ parentNodeInfo.nodeHandle = parentNode;
80
+ if (!hasSafeAreaProvider && parentNode) {
81
+ return findParentNodeHandle(parentNode);
82
+ }
83
+ return parentNodeInfo;
84
+ }
85
+
86
+ void SafeAreaViewComponentInstance::onPropsChanged(SharedConcreteProps const &props)
87
+ {
88
+ super::onPropsChanged(props);
89
+ this->m_SharedConcreteProps = props;
90
+ if (this->m_isFirstShow) {
91
+ return;
92
+ }
93
+ updateInsert(props);
94
+ }
95
+
96
+ void SafeAreaViewComponentInstance::onAppear()
97
+ {
98
+ if (this->m_isFirstShow && this->m_SharedConcreteProps) {
99
+ updateInsert(this->m_SharedConcreteProps);
100
+ this->m_isFirstShow = false;
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ #ifndef SAFEAREAVIEWCOMPONENTINSTANCE_H
25
+ #define SAFEAREAVIEWCOMPONENTINSTANCE_H
26
+ #pragma once
27
+ #include "RNOH/CppComponentInstance.h"
28
+ #include "SafeAreaBeanData.h"
29
+ #include "SafeAreaColumnNode.h"
30
+ #include "SafeAreaStackNode.h"
31
+ #include "SafeAreaProviderComponentInstance.h"
32
+ #include "generated/RNOH/generated/components/BaseRNCSafeAreaViewComponentInstance.h"
33
+ #include "generated/react/renderer/components/react_native_safe_area_context/EventEmitters.h"
34
+
35
+ namespace rnoh {
36
+ class SafeAreaViewComponentInstance : public BaseRNCSafeAreaViewComponentInstance, SafeAreaStackNodeDelegate {
37
+ using super = BaseRNCSafeAreaViewComponentInstance;
38
+ struct ParentNodeInfo {
39
+ ArkUI_NodeHandle nodeHandle = nullptr;
40
+ bool hasSafeAreaProvider = false;
41
+ };
42
+ private:
43
+ SafeAreaStackNode m_safeAreaViewStackNode;
44
+ bool m_isFirstShow = true;
45
+ SharedConcreteProps m_SharedConcreteProps;
46
+ public:
47
+ explicit SafeAreaViewComponentInstance(Context context);
48
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance,
49
+ std::size_t index) override;
50
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
51
+ void onPropsChanged(SharedConcreteProps const &props) override;
52
+ SafeAreaStackNode &getLocalRootArkUINode() override;
53
+ void updateInsert(SharedConcreteProps p);
54
+ void onAppear() override;
55
+ ParentNodeInfo findParentNodeHandle(ArkUI_NodeHandle nodehandle);
56
+ };
57
+ } // namespace rnoh
58
+ #endif
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ #ifndef SAFEAREAVIEWPACKAGE_H
25
+ #define SAFEAREAVIEWPACKAGE_H
26
+ #include "RNOH/Package.h"
27
+ #include "generated/RNOH/generated/BaseReactNativeSafeAreaContextPackage.h"
28
+ #include "SafeAreaViewComponentInstance.h"
29
+ #include "SafeAreaProviderComponentInstance.h"
30
+
31
+ using namespace rnoh;
32
+ using namespace facebook;
33
+
34
+ namespace rnoh {
35
+
36
+ class SafeAreaPackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
37
+ public:
38
+ using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
39
+
40
+ ComponentInstance::Shared create(ComponentInstance::Context ctx) override
41
+ {
42
+ if (ctx.componentName == "RNCSafeAreaProvider") {
43
+ return std::make_shared<SafeAreaProviderComponentInstance>(std::move(ctx));
44
+ } else if (ctx.componentName == "RNCSafeAreaView") {
45
+ return std::make_shared<SafeAreaViewComponentInstance>(std::move(ctx));
46
+ }
47
+ return nullptr;
48
+ }
49
+ };
50
+ class SafeAreaViewPackage : public BaseReactNativeSafeAreaContextPackage {
51
+ using Super = BaseReactNativeSafeAreaContextPackage;
52
+ public:
53
+ SafeAreaViewPackage(Package::Context ctx) : Super(ctx) {}
54
+ ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate() override
55
+ {
56
+ return std::make_shared<SafeAreaPackageComponentInstanceFactoryDelegate>();
57
+ }
58
+ };
59
+ }
60
+ #endif
@@ -0,0 +1,63 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #include "TurboModuleRequest.h"
26
+
27
+ safeArea::Event TurboModuleRequest::getTurboModuleData(rnoh::ComponentInstance::Dependencies::Shared deps)
28
+ {
29
+ safeArea::Event data = {{0, 0, 0, 0}, {0, 0, 0, 0}};
30
+ auto rnInstancePtr = deps->rnInstance.lock();
31
+ folly::dynamic result1;
32
+ if (rnInstancePtr != nullptr) {
33
+ auto turboModule = rnInstancePtr->getTurboModule("RNCSafeAreaContext");
34
+ auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
35
+ result1 = arkTsTurboModule->callSync("getConstants", {});
36
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: x:"
37
+ << result1["initialWindowMetrics"]["frame"]["x"].asDouble();
38
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: y:"
39
+ << result1["initialWindowMetrics"]["frame"]["y"].asDouble();
40
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: width:"
41
+ << result1["initialWindowMetrics"]["frame"]["width"].asDouble();
42
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: height:"
43
+ << result1["initialWindowMetrics"]["frame"]["height"].asDouble();
44
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: top:"
45
+ << result1["initialWindowMetrics"]["insets"]["top"].asDouble();
46
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: right:"
47
+ << result1["initialWindowMetrics"]["insets"]["right"].asDouble();
48
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: bottom:"
49
+ << result1["initialWindowMetrics"]["insets"]["bottom"].asDouble();
50
+ DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: left:"
51
+ << result1["initialWindowMetrics"]["insets"]["left"].asDouble();
52
+ double_t frameX = result1["initialWindowMetrics"]["frame"]["x"].asDouble();
53
+ double_t frameY = result1["initialWindowMetrics"]["frame"]["y"].asDouble();
54
+ double_t frameWidth = result1["initialWindowMetrics"]["frame"]["width"].asDouble();
55
+ double_t frameHeight = result1["initialWindowMetrics"]["frame"]["height"].asDouble();
56
+ double_t insetsTop = result1["initialWindowMetrics"]["insets"]["top"].asDouble();
57
+ double_t insetsRight = result1["initialWindowMetrics"]["insets"]["right"].asDouble();
58
+ double_t insetsBottom = result1["initialWindowMetrics"]["insets"]["bottom"].asDouble();
59
+ double_t insetsLeft = result1["initialWindowMetrics"]["insets"]["left"].asDouble();
60
+ data = {{insetsTop, insetsRight, insetsBottom, insetsLeft}, {frameX, frameY, frameWidth, frameHeight}};
61
+ }
62
+ return data;
63
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ #ifndef HARMONY_TURBOMODULEREQUEST_H
25
+ #define HARMONY_TURBOMODULEREQUEST_H
26
+ #include "RNOH/CppComponentInstance.h"
27
+ #include "SafeAreaBeanData.h"
28
+ class TurboModuleRequest {
29
+ public:
30
+ safeArea::Event getTurboModuleData(rnoh::ComponentInstance::Dependencies::Shared deps);
31
+ };
32
+ #endif // HARMONY_TURBOMODULEREQUEST_H
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+ #ifndef BASEREACTNATIVESAFEAREACONTEXTPACKAGE_H
5
+ #define BASEREACTNATIVESAFEAREACONTEXTPACKAGE_H
6
+ #pragma once
7
+ #include <react/renderer/components/react_native_safe_area_context/ComponentDescriptors.h>
8
+ #include "RNOH/Package.h"
9
+ #include "RNOH/ArkTSTurboModule.h"
10
+ #include "RNOH/generated/turbo_modules/RNCSafeAreaContext.h"
11
+ #include "RNOH/generated/components/RNCSafeAreaViewJSIBinder.h"
12
+ #include "RNOH/generated/components/RNCSafeAreaProviderJSIBinder.h"
13
+
14
+ namespace rnoh {
15
+
16
+ class BaseReactNativeSafeAreaContextPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
17
+ public:
18
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
19
+ {
20
+ if (name == "RNCSafeAreaContext") {
21
+ return std::make_shared<RNCSafeAreaContext>(ctx, name);
22
+ }
23
+ return nullptr;
24
+ };
25
+ };
26
+
27
+ class BaseReactNativeSafeAreaContextPackageEventEmitRequestHandler : public EventEmitRequestHandler {
28
+ public:
29
+ void handleEvent(Context const &ctx) override
30
+ {
31
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
32
+ if (eventEmitter == nullptr) {
33
+ return;
34
+ }
35
+ std::vector<std::string> supportedEventNames = {
36
+ };
37
+ if (std::find(supportedEventNames.begin(),
38
+ supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
39
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
40
+ }
41
+ }
42
+ };
43
+
44
+ class BaseReactNativeSafeAreaContextPackage : public Package {
45
+ public:
46
+ BaseReactNativeSafeAreaContextPackage(Package::Context ctx) : Package(ctx){};
47
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override
48
+ {
49
+ return std::make_unique<BaseReactNativeSafeAreaContextPackageTurboModuleFactoryDelegate>();
50
+ }
51
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override
52
+ {
53
+ return {
54
+ facebook::react::concreteComponentDescriptorProvider<
55
+ facebook::react::RNCSafeAreaViewComponentDescriptor>(),
56
+ facebook::react::concreteComponentDescriptorProvider<
57
+ facebook::react::RNCSafeAreaProviderComponentDescriptor>(),
58
+ };
59
+ }
60
+ ComponentJSIBinderByString createComponentJSIBinderByName() override
61
+ {
62
+ return {
63
+ {"RNCSafeAreaView", std::make_shared<RNCSafeAreaViewJSIBinder>()},
64
+ {"RNCSafeAreaProvider", std::make_shared<RNCSafeAreaProviderJSIBinder>()},
65
+ };
66
+ };
67
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override
68
+ {
69
+ return {
70
+ std::make_shared<BaseReactNativeSafeAreaContextPackageEventEmitRequestHandler>(),
71
+ };
72
+ }
73
+ };
74
+ }
75
+ #endif
@@ -0,0 +1,19 @@
1
+
2
+ /**
3
+ * This code was generated by "react-native codegen-lib-harmony"
4
+ */
5
+ #ifndef BASERNCSAFEAREAPROVIDERCOMPONENTINSTANCE_H
6
+ #define BASERNCSAFEAREAPROVIDERCOMPONENTINSTANCE_H
7
+ #pragma once
8
+
9
+ #include "RNOH/CppComponentInstance.h"
10
+ #include <react/renderer/components/react_native_safe_area_context/ShadowNodes.h>
11
+
12
+ namespace rnoh {
13
+ class BaseRNCSafeAreaProviderComponentInstance
14
+ : public CppComponentInstance<facebook::react::RNCSafeAreaProviderShadowNode> {
15
+ public:
16
+ using CppComponentInstance::CppComponentInstance;
17
+ };
18
+ }
19
+ #endif
@@ -0,0 +1,19 @@
1
+
2
+ /**
3
+ * This code was generated by "react-native codegen-lib-harmony"
4
+ */
5
+ #ifndef BASERNCSAFEAREAVIEWCOMPONENTINSTANCE_H
6
+ #define BASERNCSAFEAREAVIEWCOMPONENTINSTANCE_H
7
+ #pragma once
8
+
9
+ #include "RNOH/CppComponentInstance.h"
10
+ #include <react/renderer/components/react_native_safe_area_context/ShadowNodes.h>
11
+
12
+ namespace rnoh {
13
+ class BaseRNCSafeAreaViewComponentInstance
14
+ : public CppComponentInstance<facebook::react::RNCSafeAreaViewShadowNode> {
15
+ public:
16
+ using CppComponentInstance::CppComponentInstance;
17
+ };
18
+ } // namespace rnoh
19
+ #endif
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
7
+
8
+ namespace rnoh {
9
+ class RNCSafeAreaProviderJSIBinder : public ViewComponentJSIBinder {
10
+ protected:
11
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
12
+ {
13
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
14
+ return object;
15
+ }
16
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
17
+ {
18
+ facebook::jsi::Object events(rt);
19
+ return events;
20
+ }
21
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
22
+ {
23
+ facebook::jsi::Object events(rt);
24
+ events.setProperty(rt, "topInsetsChange", createDirectEvent(rt, "onInsetsChange"));
25
+ return events;
26
+ }
27
+ };
28
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
7
+
8
+ namespace rnoh {
9
+ class RNCSafeAreaViewJSIBinder : public ViewComponentJSIBinder {
10
+ protected:
11
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
12
+ {
13
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
14
+ object.setProperty(rt, "mode", true);
15
+ object.setProperty(rt, "edges", "Object");
16
+ object.setProperty(rt, "isFirstRefresh", true);
17
+ return object;
18
+ }
19
+
20
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
21
+ {
22
+ facebook::jsi::Object events(rt);
23
+ return events;
24
+ }
25
+
26
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
27
+ {
28
+ facebook::jsi::Object events(rt);
29
+ events.setProperty(rt, "topSafeAreaValueChange", createDirectEvent(rt, "onSafeAreaValueChange"));
30
+ return events;
31
+ }
32
+ };
33
+ } // namespace rnoh
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #include "RNCSafeAreaContext.h"
6
+
7
+ namespace rnoh {
8
+ using namespace facebook;
9
+
10
+ RNCSafeAreaContext::RNCSafeAreaContext(const ArkTSTurboModule::Context ctx,
11
+ const std::string name) : ArkTSTurboModule(ctx, name)
12
+ {
13
+ methodMap_ = {
14
+ ARK_METHOD_METADATA(getConstants, 0),
15
+ };
16
+ }
17
+ } // namespace rnoh
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+
7
+ #include "RNOH/ArkTSTurboModule.h"
8
+
9
+ namespace rnoh {
10
+
11
+ class JSI_EXPORT RNCSafeAreaContext : public ArkTSTurboModule {
12
+ public:
13
+ RNCSafeAreaContext(const ArkTSTurboModule::Context ctx, const std::string name);
14
+ };
15
+ } // namespace rnoh
@@ -0,0 +1,21 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <react/renderer/components/react_native_safe_area_context/ShadowNodes.h>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+
16
+ namespace facebook {
17
+ namespace react {
18
+ using RNCSafeAreaProviderComponentDescriptor = ConcreteComponentDescriptor<RNCSafeAreaProviderShadowNode>;
19
+ using RNCSafeAreaViewComponentDescriptor = ConcreteComponentDescriptor<RNCSafeAreaViewShadowNode>;
20
+ } // namespace react
21
+ } // namespace facebook
@@ -0,0 +1,57 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include <react/renderer/components/react_native_safe_area_context/EventEmitters.h>
12
+
13
+
14
+ namespace facebook {
15
+ namespace react {
16
+
17
+ void RNCSafeAreaViewEventEmitter::onSafeAreaValueChange(OnSafeAreaValueChange $event) const
18
+ {
19
+ dispatchEvent("safeAreaValueChange", [$event = std::move($event)](jsi::Runtime &runtime) {
20
+ auto $payload = jsi::Object(runtime);
21
+ {
22
+ auto safeAreaViewInsetsValue = jsi::Object(runtime);
23
+ safeAreaViewInsetsValue.setProperty(runtime, "top", $event.safeAreaViewInsetsValue.top);
24
+ safeAreaViewInsetsValue.setProperty(runtime, "left", $event.safeAreaViewInsetsValue.left);
25
+ safeAreaViewInsetsValue.setProperty(runtime, "bottom", $event.safeAreaViewInsetsValue.bottom);
26
+ safeAreaViewInsetsValue.setProperty(runtime, "right", $event.safeAreaViewInsetsValue.right);
27
+ $payload.setProperty(runtime, "safeAreaViewInsetsValue", safeAreaViewInsetsValue);
28
+ }
29
+ return $payload;
30
+ });
31
+ }
32
+
33
+ void RNCSafeAreaProviderEventEmitter::onInsetsChange(OnInsetsChange $event) const
34
+ {
35
+ dispatchEvent("insetsChange", [$event = std::move($event)](jsi::Runtime &runtime) {
36
+ auto $payload = jsi::Object(runtime);
37
+ {
38
+ auto insets = jsi::Object(runtime);
39
+ insets.setProperty(runtime, "top", $event.insets.top);
40
+ insets.setProperty(runtime, "right", $event.insets.right);
41
+ insets.setProperty(runtime, "bottom", $event.insets.bottom);
42
+ insets.setProperty(runtime, "left", $event.insets.left);
43
+ $payload.setProperty(runtime, "insets", insets);
44
+ }
45
+ {
46
+ auto frame = jsi::Object(runtime);
47
+ frame.setProperty(runtime, "x", $event.frame.x);
48
+ frame.setProperty(runtime, "y", $event.frame.y);
49
+ frame.setProperty(runtime, "width", $event.frame.width);
50
+ frame.setProperty(runtime, "height", $event.frame.height);
51
+ $payload.setProperty(runtime, "frame", frame);
52
+ }
53
+ return $payload;
54
+ });
55
+ }
56
+ }
57
+ }