@react-native-ohos/react-native-safe-area-context 4.7.5-rc.1 → 5.1.1-rc.3
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.
- package/LICENSE +1 -1
- package/README.OpenSource +1 -1
- package/README.md +1 -2
- package/harmony/safe_area/index.ets +1 -3
- package/harmony/safe_area/oh-package.json5 +14 -7
- package/harmony/safe_area/src/main/cpp/SafeAreaBeanData.h +2 -1
- package/harmony/safe_area/src/main/cpp/SafeAreaColumnNode.cpp +6 -7
- package/harmony/safe_area/src/main/cpp/SafeAreaColumnNode.h +4 -5
- package/harmony/safe_area/src/main/cpp/SafeAreaManagerMap.cpp +3 -2
- package/harmony/safe_area/src/main/cpp/SafeAreaManagerMap.h +15 -0
- package/harmony/safe_area/src/main/cpp/SafeAreaProviderComponentInstance.cpp +9 -15
- package/harmony/safe_area/src/main/cpp/SafeAreaProviderComponentInstance.h +18 -16
- package/harmony/safe_area/src/main/cpp/SafeAreaStackNode.cpp +64 -48
- package/harmony/safe_area/src/main/cpp/SafeAreaStackNode.h +43 -19
- package/harmony/safe_area/src/main/cpp/SafeAreaViewComponentInstance.cpp +44 -32
- package/harmony/safe_area/src/main/cpp/SafeAreaViewComponentInstance.h +15 -9
- package/harmony/safe_area/src/main/cpp/SafeAreaViewPackage.h +9 -9
- package/harmony/safe_area/src/main/cpp/TurboModuleRequest.cpp +11 -11
- package/harmony/safe_area/src/main/cpp/TurboModuleRequest.h +2 -1
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/BaseReactNativeSafeAreaContextPackage.h +23 -26
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/BaseRNCSafeAreaProviderComponentInstance.h +8 -9
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/BaseRNCSafeAreaViewComponentInstance.h +7 -8
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/RNCSafeAreaProviderJSIBinder.h +6 -7
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/components/RNCSafeAreaViewJSIBinder.h +3 -6
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCSafeAreaContext.cpp +3 -4
- package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCSafeAreaContext.h +2 -1
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ComponentDescriptors.h +6 -2
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/EventEmitters.cpp +35 -36
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/EventEmitters.h +28 -31
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/Props.cpp +5 -2
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/Props.h +46 -57
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ShadowNodes.cpp +4 -2
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/ShadowNodes.h +15 -5
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/States.cpp +5 -2
- package/harmony/safe_area/src/main/cpp/generated/react/renderer/components/react_native_safe_area_context/States.h +5 -2
- package/harmony/safe_area/src/main/ets/Logger.ts +1 -1
- package/harmony/safe_area/src/main/ets/SafeAreaProvider.ets +1 -1
- package/harmony/safe_area/src/main/ets/SafeAreaProviderModifier.ets +1 -1
- package/harmony/safe_area/src/main/ets/SafeAreaView.ets +1 -1
- package/harmony/safe_area/src/main/ets/SafeAreaViewModifier.ets +1 -1
- package/harmony/safe_area/src/main/ets/{SafeAreaViewPackage.ets → SafeAreaViewPackage.ts} +2 -3
- package/harmony/safe_area/src/main/ets/SafeViewTurboModule.ts +1 -1
- package/harmony/safe_area/src/main/ets/common/SafeAreaType.ts +1 -1
- package/harmony/safe_area/{ts.ets → ts.ts} +1 -1
- package/harmony/safe_area.har +0 -0
- package/lib/commonjs/SafeArea.types.js +6 -0
- package/lib/commonjs/SafeArea.types.js.map +1 -0
- package/lib/commonjs/SafeAreaView.js +209 -0
- package/lib/commonjs/SafeAreaView.js.map +1 -0
- package/lib/commonjs/index.js +74 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NativeSafeAreaContext.js +32 -0
- package/lib/commonjs/specs/NativeSafeAreaContext.js.map +1 -0
- package/lib/commonjs/specs/NativeSafeAreaProvider.js +33 -0
- package/lib/commonjs/specs/NativeSafeAreaProvider.js.map +1 -0
- package/lib/commonjs/specs/NativeSafeAreaView.js +35 -0
- package/lib/commonjs/specs/NativeSafeAreaView.js.map +1 -0
- package/lib/module/SafeArea.types.js +4 -0
- package/lib/module/SafeArea.types.js.map +1 -0
- package/lib/module/SafeAreaView.js +202 -0
- package/lib/module/SafeAreaView.js.map +1 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/NativeSafeAreaContext.js +28 -0
- package/lib/module/specs/NativeSafeAreaContext.js.map +1 -0
- package/lib/module/specs/NativeSafeAreaProvider.js +29 -0
- package/lib/module/specs/NativeSafeAreaProvider.js.map +1 -0
- package/lib/module/specs/NativeSafeAreaView.js +30 -0
- package/lib/module/specs/NativeSafeAreaView.js.map +1 -0
- package/lib/typescript/SafeArea.types.d.ts +59 -0
- package/lib/typescript/SafeArea.types.d.ts.map +1 -0
- package/lib/typescript/SafeAreaView.d.ts +29 -0
- package/lib/typescript/SafeAreaView.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaContext.d.ts +46 -0
- package/lib/typescript/specs/NativeSafeAreaContext.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaProvider.d.ts +45 -0
- package/lib/typescript/specs/NativeSafeAreaProvider.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaView.d.ts +24 -0
- package/lib/typescript/specs/NativeSafeAreaView.d.ts.map +1 -0
- package/package.json +39 -39
- package/src/SafeArea.types.ts +23 -0
- package/src/SafeAreaView.tsx +23 -0
- package/src/index.tsx +25 -0
- package/src/specs/NativeSafeAreaContext.ts +23 -0
- package/src/specs/NativeSafeAreaProvider.ts +24 -1
- package/src/specs/NativeSafeAreaView.ts +23 -0
- package/harmony/safe_area/LICENSE +0 -21
- package/harmony/safe_area/NOTICE +0 -33
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
#include <deviceinfo.h>
|
|
25
|
+
#include <info/application_target_sdk_version.h>
|
|
24
26
|
#include "SafeAreaViewComponentInstance.h"
|
|
25
27
|
#include "TurboModuleRequest.h"
|
|
26
28
|
#include "SafeAreaManagerMap.h"
|
|
@@ -28,51 +30,61 @@
|
|
|
28
30
|
namespace rnoh {
|
|
29
31
|
|
|
30
32
|
SafeAreaViewComponentInstance::SafeAreaViewComponentInstance(Context context)
|
|
31
|
-
: BaseRNCSafeAreaViewComponentInstance(std::move(context))
|
|
32
|
-
{
|
|
33
|
+
: BaseRNCSafeAreaViewComponentInstance(std::move(context)) {
|
|
33
34
|
m_safeAreaViewStackNode.setStackNodeDelegate(this);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
void SafeAreaViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
|
|
37
|
-
|
|
38
|
-
{
|
|
38
|
+
std::size_t index) {
|
|
39
39
|
super::onChildInserted(childComponentInstance, index);
|
|
40
40
|
m_safeAreaViewStackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
void SafeAreaViewComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance)
|
|
44
|
-
{
|
|
43
|
+
void SafeAreaViewComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
|
|
45
44
|
super::onChildRemoved(childComponentInstance);
|
|
46
45
|
m_safeAreaViewStackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
SafeAreaStackNode &SafeAreaViewComponentInstance::getLocalRootArkUINode() { return m_safeAreaViewStackNode; }
|
|
50
49
|
|
|
51
|
-
void SafeAreaViewComponentInstance::updateInsert(SharedConcreteProps p)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
void SafeAreaViewComponentInstance::updateInsert(SharedConcreteProps p) {
|
|
51
|
+
DLOG(INFO) << "SafeAreaViewComponentInstance OH_CURRENT_API_VERSION:" << OH_CURRENT_API_VERSION
|
|
52
|
+
<< ";ROM SDK:" << OH_GetSdkApiVersion();
|
|
53
|
+
|
|
54
|
+
#if OH_CURRENT_API_VERSION >= 14
|
|
55
|
+
if (OH_GetSdkApiVersion() < 14) {
|
|
56
|
+
TurboModuleRequest request;
|
|
57
|
+
safeArea::Event data = request.getTurboModuleData(this->m_deps);
|
|
58
|
+
facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {data.insets.top, data.insets.right,
|
|
59
|
+
data.insets.bottom, data.insets.left};
|
|
60
|
+
m_eventEmitter->onSafeAreaValueChange(inset);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
auto parentNodeHandle = findParentNodeHandle(m_safeAreaViewStackNode.getArkUINodeHandle());
|
|
64
|
+
DLOG(INFO) << "SafeAreaViewComponentInstance findParentNodeHandle " << parentNodeHandle.nodeHandle << " hasSafeAreaProvider " << parentNodeHandle.hasSafeAreaProvider;
|
|
65
|
+
if (parentNodeHandle.hasSafeAreaProvider) {
|
|
66
|
+
TurboModuleRequest request;
|
|
67
|
+
safeArea::Event data = request.getTurboModuleData(this->m_deps);
|
|
68
|
+
facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {data.insets.top, data.insets.right,
|
|
69
|
+
data.insets.bottom, data.insets.left};
|
|
70
|
+
m_eventEmitter->onSafeAreaValueChange(inset);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {0, 0, 0, 0};
|
|
74
|
+
m_eventEmitter->onSafeAreaValueChange(inset);
|
|
75
|
+
}
|
|
76
|
+
#else
|
|
58
77
|
TurboModuleRequest request;
|
|
59
78
|
safeArea::Event data = request.getTurboModuleData(this->m_deps);
|
|
60
79
|
facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {data.insets.top, data.insets.right,
|
|
61
|
-
|
|
80
|
+
data.insets.bottom, data.insets.left};
|
|
62
81
|
m_eventEmitter->onSafeAreaValueChange(inset);
|
|
63
|
-
|
|
64
|
-
facebook::react::RNCSafeAreaViewEventEmitter::OnSafeAreaValueChange inset = {0, 0, 0, 0};
|
|
65
|
-
m_eventEmitter->onSafeAreaValueChange(inset);
|
|
66
|
-
}
|
|
82
|
+
#endif
|
|
67
83
|
}
|
|
68
84
|
|
|
69
|
-
SafeAreaViewComponentInstance::ParentNodeInfo SafeAreaViewComponentInstance::findParentNodeHandle(
|
|
70
|
-
ArkUI_NodeHandle nodehandle)
|
|
71
|
-
{
|
|
85
|
+
SafeAreaViewComponentInstance::ParentNodeInfo SafeAreaViewComponentInstance::findParentNodeHandle(ArkUI_NodeHandle nodehandle) {
|
|
72
86
|
ParentNodeInfo parentNodeInfo;
|
|
73
|
-
if
|
|
74
|
-
return parentNodeInfo;
|
|
75
|
-
}
|
|
87
|
+
if(!nodehandle) return parentNodeInfo;
|
|
76
88
|
auto parentNode = OH_ArkUI_NodeUtils_GetParentInPageTree(nodehandle);
|
|
77
89
|
bool hasSafeAreaProvider = SafeAreaManagerMap::getInstance().GetHasSafeAreaProviderByNodeHandle(parentNode);
|
|
78
90
|
parentNodeInfo.hasSafeAreaProvider = hasSafeAreaProvider;
|
|
@@ -83,21 +95,21 @@ SafeAreaViewComponentInstance::ParentNodeInfo SafeAreaViewComponentInstance::fin
|
|
|
83
95
|
return parentNodeInfo;
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
void SafeAreaViewComponentInstance::onPropsChanged(SharedConcreteProps const &props)
|
|
87
|
-
{
|
|
98
|
+
void SafeAreaViewComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
|
|
88
99
|
super::onPropsChanged(props);
|
|
89
100
|
this->m_SharedConcreteProps = props;
|
|
90
|
-
if
|
|
101
|
+
if(this->m_isFirstShow) {
|
|
91
102
|
return;
|
|
92
103
|
}
|
|
93
104
|
updateInsert(props);
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
void SafeAreaViewComponentInstance::onAppear()
|
|
97
|
-
{
|
|
98
|
-
if (this->m_isFirstShow && this->m_SharedConcreteProps) {
|
|
107
|
+
void SafeAreaViewComponentInstance::onAppear(){
|
|
108
|
+
if(this->m_isFirstShow && this->m_SharedConcreteProps) {
|
|
99
109
|
updateInsert(this->m_SharedConcreteProps);
|
|
100
110
|
this->m_isFirstShow = false;
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
|
-
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
} // namespace rnoh
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
#ifndef SAFEAREAVIEWCOMPONENTINSTANCE_H
|
|
25
|
-
#define SAFEAREAVIEWCOMPONENTINSTANCE_H
|
|
26
24
|
#pragma once
|
|
27
25
|
#include "RNOH/CppComponentInstance.h"
|
|
28
26
|
#include "SafeAreaBeanData.h"
|
|
@@ -33,26 +31,34 @@
|
|
|
33
31
|
#include "generated/react/renderer/components/react_native_safe_area_context/EventEmitters.h"
|
|
34
32
|
|
|
35
33
|
namespace rnoh {
|
|
36
|
-
class SafeAreaViewComponentInstance : public BaseRNCSafeAreaViewComponentInstance,
|
|
34
|
+
class SafeAreaViewComponentInstance : public BaseRNCSafeAreaViewComponentInstance,SafeAreaStackNodeDelegate {
|
|
35
|
+
|
|
37
36
|
using super = BaseRNCSafeAreaViewComponentInstance;
|
|
37
|
+
|
|
38
38
|
struct ParentNodeInfo {
|
|
39
39
|
ArkUI_NodeHandle nodeHandle = nullptr;
|
|
40
40
|
bool hasSafeAreaProvider = false;
|
|
41
41
|
};
|
|
42
|
+
|
|
42
43
|
private:
|
|
43
44
|
SafeAreaStackNode m_safeAreaViewStackNode;
|
|
44
45
|
bool m_isFirstShow = true;
|
|
45
46
|
SharedConcreteProps m_SharedConcreteProps;
|
|
46
47
|
public:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
SafeAreaViewComponentInstance(Context context);
|
|
49
|
+
|
|
50
|
+
void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
|
|
51
|
+
|
|
50
52
|
void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
|
|
53
|
+
|
|
51
54
|
void onPropsChanged(SharedConcreteProps const &props) override;
|
|
55
|
+
|
|
52
56
|
SafeAreaStackNode &getLocalRootArkUINode() override;
|
|
57
|
+
|
|
53
58
|
void updateInsert(SharedConcreteProps p);
|
|
59
|
+
|
|
54
60
|
void onAppear() override;
|
|
61
|
+
|
|
55
62
|
ParentNodeInfo findParentNodeHandle(ArkUI_NodeHandle nodehandle);
|
|
56
63
|
};
|
|
57
|
-
} // namespace rnoh
|
|
58
|
-
#endif
|
|
64
|
+
} // namespace rnoh
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define SAFEAREAVIEWPACKAGE_H
|
|
24
|
+
|
|
26
25
|
#include "RNOH/Package.h"
|
|
27
26
|
#include "generated/RNOH/generated/BaseReactNativeSafeAreaContextPackage.h"
|
|
28
27
|
#include "SafeAreaViewComponentInstance.h"
|
|
@@ -37,8 +36,7 @@ class SafeAreaPackageComponentInstanceFactoryDelegate : public ComponentInstance
|
|
|
37
36
|
public:
|
|
38
37
|
using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
|
|
39
38
|
|
|
40
|
-
ComponentInstance::Shared create(ComponentInstance::Context ctx) override
|
|
41
|
-
{
|
|
39
|
+
ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
|
|
42
40
|
if (ctx.componentName == "RNCSafeAreaProvider") {
|
|
43
41
|
return std::make_shared<SafeAreaProviderComponentInstance>(std::move(ctx));
|
|
44
42
|
} else if (ctx.componentName == "RNCSafeAreaView") {
|
|
@@ -47,14 +45,16 @@ public:
|
|
|
47
45
|
return nullptr;
|
|
48
46
|
}
|
|
49
47
|
};
|
|
48
|
+
|
|
50
49
|
class SafeAreaViewPackage : public BaseReactNativeSafeAreaContextPackage {
|
|
51
50
|
using Super = BaseReactNativeSafeAreaContextPackage;
|
|
51
|
+
|
|
52
52
|
public:
|
|
53
53
|
SafeAreaViewPackage(Package::Context ctx) : Super(ctx) {}
|
|
54
|
-
|
|
55
|
-
{
|
|
54
|
+
|
|
55
|
+
ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate() override {
|
|
56
56
|
return std::make_shared<SafeAreaPackageComponentInstanceFactoryDelegate>();
|
|
57
57
|
}
|
|
58
|
+
|
|
58
59
|
};
|
|
59
|
-
}
|
|
60
|
-
#endif
|
|
60
|
+
} // namespace rnoh
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
#include "TurboModuleRequest.h"
|
|
26
26
|
|
|
27
|
-
safeArea::Event TurboModuleRequest::getTurboModuleData(rnoh::ComponentInstance::Dependencies::Shared deps)
|
|
28
|
-
{
|
|
27
|
+
safeArea::Event TurboModuleRequest::getTurboModuleData(rnoh::ComponentInstance::Dependencies::Shared deps) {
|
|
29
28
|
safeArea::Event data = {{0, 0, 0, 0}, {0, 0, 0, 0}};
|
|
30
29
|
auto rnInstancePtr = deps->rnInstance.lock();
|
|
31
30
|
folly::dynamic result1;
|
|
@@ -34,21 +33,21 @@ safeArea::Event TurboModuleRequest::getTurboModuleData(rnoh::ComponentInstance::
|
|
|
34
33
|
auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
|
|
35
34
|
result1 = arkTsTurboModule->callSync("getConstants", {});
|
|
36
35
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: x:"
|
|
37
|
-
|
|
36
|
+
<< result1["initialWindowMetrics"]["frame"]["x"].asDouble();
|
|
38
37
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: y:"
|
|
39
|
-
|
|
38
|
+
<< result1["initialWindowMetrics"]["frame"]["y"].asDouble();
|
|
40
39
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: width:"
|
|
41
|
-
|
|
40
|
+
<< result1["initialWindowMetrics"]["frame"]["width"].asDouble();
|
|
42
41
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: height:"
|
|
43
|
-
|
|
42
|
+
<< result1["initialWindowMetrics"]["frame"]["height"].asDouble();
|
|
44
43
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: top:"
|
|
45
|
-
|
|
44
|
+
<< result1["initialWindowMetrics"]["insets"]["top"].asDouble();
|
|
46
45
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: right:"
|
|
47
|
-
|
|
46
|
+
<< result1["initialWindowMetrics"]["insets"]["right"].asDouble();
|
|
48
47
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: bottom:"
|
|
49
|
-
|
|
48
|
+
<< result1["initialWindowMetrics"]["insets"]["bottom"].asDouble();
|
|
50
49
|
DLOG(INFO) << "[safeArea] <SafeAreaViewComponentInstance::setProps> initialWindowMetrics: left:"
|
|
51
|
-
|
|
50
|
+
<< result1["initialWindowMetrics"]["insets"]["left"].asDouble();
|
|
52
51
|
double_t frameX = result1["initialWindowMetrics"]["frame"]["x"].asDouble();
|
|
53
52
|
double_t frameY = result1["initialWindowMetrics"]["frame"]["y"].asDouble();
|
|
54
53
|
double_t frameWidth = result1["initialWindowMetrics"]["frame"]["width"].asDouble();
|
|
@@ -57,6 +56,7 @@ safeArea::Event TurboModuleRequest::getTurboModuleData(rnoh::ComponentInstance::
|
|
|
57
56
|
double_t insetsRight = result1["initialWindowMetrics"]["insets"]["right"].asDouble();
|
|
58
57
|
double_t insetsBottom = result1["initialWindowMetrics"]["insets"]["bottom"].asDouble();
|
|
59
58
|
double_t insetsLeft = result1["initialWindowMetrics"]["insets"]["left"].asDouble();
|
|
59
|
+
|
|
60
60
|
data = {{insetsTop, insetsRight, insetsBottom, insetsLeft}, {frameX, frameY, frameWidth, frameHeight}};
|
|
61
61
|
}
|
|
62
62
|
return data;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -29,4 +29,5 @@ class TurboModuleRequest {
|
|
|
29
29
|
public:
|
|
30
30
|
safeArea::Event getTurboModuleData(rnoh::ComponentInstance::Dependencies::Shared deps);
|
|
31
31
|
};
|
|
32
|
+
|
|
32
33
|
#endif // HARMONY_TURBOMODULEREQUEST_H
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
#define BASEREACTNATIVESAFEAREACONTEXTPACKAGE_H
|
|
4
|
+
|
|
6
5
|
#pragma once
|
|
6
|
+
|
|
7
7
|
#include <react/renderer/components/react_native_safe_area_context/ComponentDescriptors.h>
|
|
8
8
|
#include "RNOH/Package.h"
|
|
9
9
|
#include "RNOH/ArkTSTurboModule.h"
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
namespace rnoh {
|
|
15
15
|
|
|
16
16
|
class BaseReactNativeSafeAreaContextPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
17
|
-
public:
|
|
18
|
-
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
|
|
19
|
-
{
|
|
17
|
+
public:
|
|
18
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
20
19
|
if (name == "RNCSafeAreaContext") {
|
|
21
20
|
return std::make_shared<RNCSafeAreaContext>(ctx, name);
|
|
22
21
|
}
|
|
@@ -25,51 +24,49 @@ public:
|
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
class BaseReactNativeSafeAreaContextPackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
28
|
-
public:
|
|
29
|
-
void handleEvent(Context const &ctx) override
|
|
30
|
-
{
|
|
27
|
+
public:
|
|
28
|
+
void handleEvent(Context const &ctx) override {
|
|
31
29
|
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
32
30
|
if (eventEmitter == nullptr) {
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
33
|
+
|
|
35
34
|
std::vector<std::string> supportedEventNames = {
|
|
36
35
|
};
|
|
37
|
-
if (std::find(supportedEventNames.begin(),
|
|
38
|
-
supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
36
|
+
if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
39
37
|
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
40
|
-
}
|
|
38
|
+
}
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
|
|
42
|
+
|
|
44
43
|
class BaseReactNativeSafeAreaContextPackage : public Package {
|
|
45
|
-
public:
|
|
44
|
+
public:
|
|
46
45
|
BaseReactNativeSafeAreaContextPackage(Package::Context ctx) : Package(ctx){};
|
|
47
|
-
|
|
48
|
-
{
|
|
46
|
+
|
|
47
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
49
48
|
return std::make_unique<BaseReactNativeSafeAreaContextPackageTurboModuleFactoryDelegate>();
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
{
|
|
50
|
+
|
|
51
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
53
52
|
return {
|
|
54
|
-
facebook::react::concreteComponentDescriptorProvider<
|
|
55
|
-
facebook::react::
|
|
56
|
-
facebook::react::concreteComponentDescriptorProvider<
|
|
57
|
-
facebook::react::RNCSafeAreaProviderComponentDescriptor>(),
|
|
53
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::RNCSafeAreaViewComponentDescriptor>(),
|
|
54
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::RNCSafeAreaProviderComponentDescriptor>(),
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
|
-
|
|
61
|
-
{
|
|
57
|
+
|
|
58
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
62
59
|
return {
|
|
63
60
|
{"RNCSafeAreaView", std::make_shared<RNCSafeAreaViewJSIBinder>()},
|
|
64
61
|
{"RNCSafeAreaProvider", std::make_shared<RNCSafeAreaProviderJSIBinder>()},
|
|
65
62
|
};
|
|
66
63
|
};
|
|
67
|
-
|
|
68
|
-
{
|
|
64
|
+
|
|
65
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
69
66
|
return {
|
|
70
67
|
std::make_shared<BaseReactNativeSafeAreaContextPackageEventEmitRequestHandler>(),
|
|
71
68
|
};
|
|
72
69
|
}
|
|
73
70
|
};
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
|
|
72
|
+
} // namespace rnoh
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This code was generated by "react-native codegen-lib-harmony"
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
#define BASERNCSAFEAREAPROVIDERCOMPONENTINSTANCE_H
|
|
5
|
+
|
|
7
6
|
#pragma once
|
|
8
7
|
|
|
9
8
|
#include "RNOH/CppComponentInstance.h"
|
|
10
9
|
#include <react/renderer/components/react_native_safe_area_context/ShadowNodes.h>
|
|
11
10
|
|
|
12
11
|
namespace rnoh {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
12
|
+
class BaseRNCSafeAreaProviderComponentInstance
|
|
13
|
+
: public CppComponentInstance<facebook::react::RNCSafeAreaProviderShadowNode> {
|
|
14
|
+
public:
|
|
15
|
+
using CppComponentInstance::CppComponentInstance;
|
|
16
|
+
|
|
17
|
+
};
|
|
18
|
+
} // namespace rnoh
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This code was generated by "react-native codegen-lib-harmony"
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
#define BASERNCSAFEAREAVIEWCOMPONENTINSTANCE_H
|
|
5
|
+
|
|
7
6
|
#pragma once
|
|
8
7
|
|
|
9
8
|
#include "RNOH/CppComponentInstance.h"
|
|
10
9
|
#include <react/renderer/components/react_native_safe_area_context/ShadowNodes.h>
|
|
11
10
|
|
|
12
11
|
namespace rnoh {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
class BaseRNCSafeAreaViewComponentInstance
|
|
13
|
+
: public CppComponentInstance<facebook::react::RNCSafeAreaViewShadowNode> {
|
|
14
|
+
public:
|
|
15
|
+
using CppComponentInstance::CppComponentInstance;
|
|
16
|
+
|
|
17
|
+
};
|
|
18
18
|
} // namespace rnoh
|
|
19
|
-
#endif
|
|
@@ -8,21 +8,20 @@
|
|
|
8
8
|
namespace rnoh {
|
|
9
9
|
class RNCSafeAreaProviderJSIBinder : public ViewComponentJSIBinder {
|
|
10
10
|
protected:
|
|
11
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
|
|
12
|
-
{
|
|
11
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
13
12
|
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
14
13
|
return object;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
{
|
|
15
|
+
|
|
16
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
18
17
|
facebook::jsi::Object events(rt);
|
|
19
18
|
return events;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
{
|
|
20
|
+
|
|
21
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
23
22
|
facebook::jsi::Object events(rt);
|
|
24
23
|
events.setProperty(rt, "topInsetsChange", createDirectEvent(rt, "onInsetsChange"));
|
|
25
24
|
return events;
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
|
-
}
|
|
27
|
+
} // namespace rnoh
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
namespace rnoh {
|
|
9
9
|
class RNCSafeAreaViewJSIBinder : public ViewComponentJSIBinder {
|
|
10
10
|
protected:
|
|
11
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
|
|
12
|
-
{
|
|
11
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
13
12
|
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
14
13
|
object.setProperty(rt, "mode", true);
|
|
15
14
|
object.setProperty(rt, "edges", "Object");
|
|
@@ -17,14 +16,12 @@ class RNCSafeAreaViewJSIBinder : public ViewComponentJSIBinder {
|
|
|
17
16
|
return object;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
|
|
21
|
-
{
|
|
19
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
22
20
|
facebook::jsi::Object events(rt);
|
|
23
21
|
return events;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
|
|
27
|
-
{
|
|
24
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
28
25
|
facebook::jsi::Object events(rt);
|
|
29
26
|
events.setProperty(rt, "topSafeAreaValueChange", createDirectEvent(rt, "onSafeAreaValueChange"));
|
|
30
27
|
return events;
|
package/harmony/safe_area/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCSafeAreaContext.cpp
CHANGED
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
namespace rnoh {
|
|
8
8
|
using namespace facebook;
|
|
9
9
|
|
|
10
|
-
RNCSafeAreaContext::RNCSafeAreaContext(const ArkTSTurboModule::Context ctx,
|
|
11
|
-
const std::string name) : ArkTSTurboModule(ctx, name)
|
|
12
|
-
{
|
|
10
|
+
RNCSafeAreaContext::RNCSafeAreaContext(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
13
11
|
methodMap_ = {
|
|
14
12
|
ARK_METHOD_METADATA(getConstants, 0),
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
} // namespace rnoh
|
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
namespace facebook {
|
|
17
17
|
namespace react {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
using RNCSafeAreaProviderComponentDescriptor = ConcreteComponentDescriptor<RNCSafeAreaProviderShadowNode>;
|
|
20
|
+
|
|
21
|
+
using RNCSafeAreaViewComponentDescriptor = ConcreteComponentDescriptor<RNCSafeAreaViewShadowNode>;
|
|
22
|
+
|
|
23
|
+
|
|
20
24
|
} // namespace react
|
|
21
25
|
} // namespace facebook
|
|
@@ -14,44 +14,43 @@
|
|
|
14
14
|
namespace facebook {
|
|
15
15
|
namespace react {
|
|
16
16
|
|
|
17
|
-
void RNCSafeAreaViewEventEmitter::onSafeAreaValueChange(OnSafeAreaValueChange $event) const
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
17
|
+
void RNCSafeAreaViewEventEmitter::onSafeAreaValueChange(OnSafeAreaValueChange $event) const {
|
|
18
|
+
dispatchEvent("safeAreaValueChange", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
19
|
+
auto $payload = jsi::Object(runtime);
|
|
20
|
+
{
|
|
21
|
+
auto safeAreaViewInsetsValue = jsi::Object(runtime);
|
|
22
|
+
safeAreaViewInsetsValue.setProperty(runtime, "top", $event.safeAreaViewInsetsValue.top);
|
|
23
|
+
safeAreaViewInsetsValue.setProperty(runtime, "left", $event.safeAreaViewInsetsValue.left);
|
|
24
|
+
safeAreaViewInsetsValue.setProperty(runtime, "bottom", $event.safeAreaViewInsetsValue.bottom);
|
|
25
|
+
safeAreaViewInsetsValue.setProperty(runtime, "right", $event.safeAreaViewInsetsValue.right);
|
|
26
|
+
$payload.setProperty(runtime, "safeAreaViewInsetsValue", safeAreaViewInsetsValue);
|
|
27
|
+
}
|
|
28
|
+
return $payload;
|
|
29
|
+
});
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
void RNCSafeAreaProviderEventEmitter::onInsetsChange(OnInsetsChange $event) const
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
});
|
|
32
|
+
void RNCSafeAreaProviderEventEmitter::onInsetsChange(OnInsetsChange $event) const {
|
|
33
|
+
dispatchEvent("insetsChange", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
34
|
+
auto $payload = jsi::Object(runtime);
|
|
35
|
+
{
|
|
36
|
+
auto insets = jsi::Object(runtime);
|
|
37
|
+
insets.setProperty(runtime, "top", $event.insets.top);
|
|
38
|
+
insets.setProperty(runtime, "right", $event.insets.right);
|
|
39
|
+
insets.setProperty(runtime, "bottom", $event.insets.bottom);
|
|
40
|
+
insets.setProperty(runtime, "left", $event.insets.left);
|
|
41
|
+
$payload.setProperty(runtime, "insets", insets);
|
|
55
42
|
}
|
|
43
|
+
{
|
|
44
|
+
auto frame = jsi::Object(runtime);
|
|
45
|
+
frame.setProperty(runtime, "x", $event.frame.x);
|
|
46
|
+
frame.setProperty(runtime, "y", $event.frame.y);
|
|
47
|
+
frame.setProperty(runtime, "width", $event.frame.width);
|
|
48
|
+
frame.setProperty(runtime, "height", $event.frame.height);
|
|
49
|
+
$payload.setProperty(runtime, "frame", frame);
|
|
56
50
|
}
|
|
51
|
+
return $payload;
|
|
52
|
+
});
|
|
57
53
|
}
|
|
54
|
+
|
|
55
|
+
} // namespace react
|
|
56
|
+
} // namespace facebook
|