@react-native-oh-tpl/react-native-gesture-handler 2.14.13 → 2.14.14
Sign up to get free protection for your applications and to get access to all the features.
- package/harmony/gesture_handler/BuildProfile.ets +1 -1
- package/harmony/gesture_handler/index.ets +1 -2
- package/harmony/gesture_handler/oh-package-lock.json5 +1 -1
- package/harmony/gesture_handler/oh-package.json5 +1 -1
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +1 -1
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +9 -18
- package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +123 -0
- package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +15 -0
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +17 -17
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +203 -200
- package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +17 -0
- package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +84 -35
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +20 -11
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +4 -4
- package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +26 -0
- package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +7 -3
- package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +1 -2
- package/harmony/gesture_handler/src/main/ets/core/index.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +12 -4
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +8 -5
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +14 -2
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +9 -1
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +13 -4
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +31 -12
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +145 -130
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +9 -1
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +15 -5
- package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +7 -4
- package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +74 -16
- package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +35 -12
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +182 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +62 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/{GestureHandlerArkUIAdapter.ts → RNGHViewController.ts} +44 -22
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +19 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +130 -96
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -9
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +1 -8
- package/harmony/gesture_handler.har +0 -0
- package/package.json +7 -3
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +0 -149
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +0 -36
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +0 -32
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +0 -22
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +0 -15
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +0 -36
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +0 -25
- package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +0 -11
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +0 -24
- package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerButton.ts +0 -139
- package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerRootView.ts +0 -101
- package/harmony/gesture_handler/src/main/ets/namespace/components/ts.ts +0 -2
- package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +0 -2
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +0 -98
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerCAPI.ts +0 -110
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerButton.ets +0 -38
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerRootView.ets +0 -53
- package/harmony/gesture_handler/src/main/ets/rnoh/View.ts +0 -134
- package/harmony/gesture_handler/src/main/ets/rnoh/ViewRegistry.ts +0 -97
@@ -4,239 +4,242 @@
|
|
4
4
|
#import "RNOH/arkui/ArkUINodeRegistry.h"
|
5
5
|
#import "RNOH/arkui/NativeNodeApi.h"
|
6
6
|
#import "RNOH/RNInstanceCAPI.h"
|
7
|
-
#import "
|
7
|
+
#import "generated/RNGestureHandlerRootViewComponentDescriptor.h"
|
8
8
|
#import "RNGestureHandlerButtonComponentInstance.h"
|
9
9
|
|
10
10
|
namespace rnoh {
|
11
11
|
class RNGestureHandlerRootViewComponentInstance
|
12
12
|
: public CppComponentInstance<facebook::react::RNGestureHandlerRootViewShadowNode>,
|
13
13
|
public TouchEventHandler {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
14
|
+
using Point = facebook::react::Point;
|
15
|
+
|
16
|
+
enum class ActionType { Cancel, Down, Move, Up };
|
17
|
+
|
18
|
+
/**
|
19
|
+
* This function is borrowed from TouchEventDispatcher
|
20
|
+
*/
|
21
|
+
static TouchTarget::Shared findTargetForTouchPoint(Point const &point, TouchTarget::Shared const &target) {
|
22
|
+
bool canHandleTouch =
|
23
|
+
target->canHandleTouch() && target->containsPoint(point) && (target->getTouchEventEmitter() != nullptr);
|
24
|
+
bool canChildrenHandleTouch = target->canChildrenHandleTouch() && target->containsPointInBoundingBox(point);
|
25
|
+
|
26
|
+
if (canChildrenHandleTouch) {
|
27
|
+
auto children = target->getTouchTargetChildren();
|
28
|
+
// we want to check the children in reverse order, since the last child is the topmost one
|
29
|
+
std::reverse(children.begin(), children.end());
|
30
|
+
for (auto const &child : children) {
|
31
|
+
auto childPoint = target->computeChildPoint(point, child);
|
32
|
+
auto result = findTargetForTouchPoint(childPoint, child);
|
33
|
+
if (result != nullptr) {
|
34
|
+
return result;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
if (canHandleTouch) {
|
39
|
+
return target;
|
40
|
+
}
|
41
|
+
return nullptr;
|
38
42
|
}
|
39
|
-
return nullptr;
|
40
|
-
}
|
41
43
|
|
42
44
|
private:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
bool m_isHandlingTouches = false;
|
46
|
+
StackNode m_stackNode;
|
47
|
+
|
48
|
+
struct TouchableView {
|
49
|
+
Tag tag;
|
50
|
+
facebook::react::Float width;
|
51
|
+
facebook::react::Float height;
|
52
|
+
facebook::react::Float x;
|
53
|
+
facebook::react::Float y;
|
54
|
+
bool buttonRole;
|
55
|
+
};
|
54
56
|
|
55
57
|
public:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
~RNGestureHandlerRootViewComponentInstance() override {
|
67
|
-
NativeNodeApi::getInstance()->unregisterNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT);
|
68
|
-
ArkUINodeRegistry::getInstance().unregisterTouchHandler(&m_stackNode);
|
69
|
-
}
|
70
|
-
|
71
|
-
StackNode &getLocalRootArkUINode() override { return m_stackNode; };
|
72
|
-
|
73
|
-
void onTouchEvent(ArkUI_UIInputEvent *e) override {
|
74
|
-
auto ancestor = this->getParent().lock();
|
75
|
-
while (ancestor != nullptr) {
|
76
|
-
auto ancestorRNGHRootView = std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor);
|
77
|
-
if (ancestorRNGHRootView != nullptr) {
|
78
|
-
// If there are multiple nested GestureHandlerRootViews, the one nearest to the actual root will handle the
|
79
|
-
// touch.
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
ancestor = ancestor->getParent().lock();
|
83
|
-
}
|
58
|
+
RNGestureHandlerRootViewComponentInstance(Context context) : CppComponentInstance(std::move(context)) {
|
59
|
+
ArkUINodeRegistry::getInstance().registerTouchHandler(&m_stackNode, this);
|
60
|
+
NativeNodeApi::getInstance()->registerNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT,
|
61
|
+
NODE_TOUCH_EVENT, 0);
|
62
|
+
auto rnInstance = m_deps->rnInstance.lock();
|
63
|
+
if (rnInstance) {
|
64
|
+
rnInstance->postMessageToArkTS("RNGH::ROOT_CREATED", m_tag);
|
65
|
+
}
|
66
|
+
};
|
84
67
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
if (ancestorTouchTarget->isHandlingTouches()) {
|
89
|
-
rnInstance->postMessageToArkTS("RNGH::CANCEL_TOUCHES", m_tag);
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
ancestorTouchTarget = ancestorTouchTarget->getTouchTargetParent();
|
68
|
+
~RNGestureHandlerRootViewComponentInstance() override {
|
69
|
+
NativeNodeApi::getInstance()->unregisterNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT);
|
70
|
+
ArkUINodeRegistry::getInstance().unregisterTouchHandler(&m_stackNode);
|
93
71
|
}
|
94
72
|
|
95
|
-
|
96
|
-
payload["action"] = OH_ArkUI_UIInputEvent_GetAction(e);
|
97
|
-
folly::dynamic touchPoints = folly::dynamic::array();
|
98
|
-
auto activeWindowX = OH_ArkUI_PointerEvent_GetWindowX(e);
|
99
|
-
auto activeWindowY = OH_ArkUI_PointerEvent_GetWindowY(e);
|
73
|
+
StackNode &getLocalRootArkUINode() override { return m_stackNode; };
|
100
74
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
75
|
+
void onTouchEvent(ArkUI_UIInputEvent *e) override {
|
76
|
+
auto ancestor = this->getParent().lock();
|
77
|
+
while (ancestor != nullptr) {
|
78
|
+
auto ancestorRNGHRootView = std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor);
|
79
|
+
if (ancestorRNGHRootView != nullptr) {
|
80
|
+
// If there are multiple nested GestureHandlerRootViews, the one nearest to the actual root will handle
|
81
|
+
// the touch.
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
ancestor = ancestor->getParent().lock();
|
85
|
+
}
|
105
86
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
87
|
+
auto ancestorTouchTarget = this->getTouchTargetParent();
|
88
|
+
auto rnInstance = m_deps->rnInstance.lock();
|
89
|
+
while (ancestorTouchTarget != nullptr) {
|
90
|
+
if (ancestorTouchTarget->isHandlingTouches()) {
|
91
|
+
rnInstance->postMessageToArkTS("RNGH::CANCEL_TOUCHES", m_tag);
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
ancestorTouchTarget = ancestorTouchTarget->getTouchTargetParent();
|
95
|
+
}
|
110
96
|
|
111
|
-
|
97
|
+
folly::dynamic payload = folly::dynamic::object;
|
98
|
+
folly::dynamic touchPoints = folly::dynamic::array();
|
99
|
+
std::vector<TouchableView> touchableViews;
|
112
100
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
101
|
+
auto action = OH_ArkUI_UIInputEvent_GetAction(e);
|
102
|
+
auto actionType = static_cast<ActionType>(action);
|
103
|
+
|
104
|
+
if (actionType != ActionType::Move) {
|
105
|
+
// point relative to top left corner of this component
|
106
|
+
auto componentX = OH_ArkUI_PointerEvent_GetX(e);
|
107
|
+
auto componentY = OH_ArkUI_PointerEvent_GetY(e);
|
108
|
+
touchableViews = this->findTouchableViews(componentX, componentY);
|
109
|
+
}
|
110
|
+
|
111
|
+
auto activeWindowX = OH_ArkUI_PointerEvent_GetWindowX(e);
|
112
|
+
auto activeWindowY = OH_ArkUI_PointerEvent_GetWindowY(e);
|
113
|
+
int32_t pointerCount = OH_ArkUI_PointerEvent_GetPointerCount(e);
|
114
|
+
int activePointerIdx = 0;
|
115
|
+
for (int i = 0; i < pointerCount; i++) {
|
116
|
+
auto touchPoint = this->convertNodeTouchPointToDynamic(e, i);
|
117
|
+
touchPoints.push_back(touchPoint);
|
118
|
+
if (activeWindowX == touchPoint["windowX"].asDouble() &&
|
119
|
+
activeWindowY == touchPoint["windowY"].asDouble()) {
|
120
|
+
activePointerIdx = i;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
payload["actionTouch"] = touchPoints[activePointerIdx];
|
124
|
+
payload["touchPoints"] = touchPoints;
|
125
|
+
payload["sourceType"] = OH_ArkUI_UIInputEvent_GetSourceType(e);
|
126
|
+
payload["timestamp"] = OH_ArkUI_UIInputEvent_GetEventTime(e);
|
127
|
+
payload["touchableViews"] = this->dynamicFromTouchableViews(touchableViews);
|
128
|
+
payload["rootTag"] = m_tag;
|
129
|
+
payload["action"] = action;
|
130
|
+
if (rnInstance) {
|
131
|
+
rnInstance->postMessageToArkTS("RNGH::TOUCH_EVENT", payload);
|
132
|
+
}
|
129
133
|
}
|
130
|
-
}
|
131
134
|
|
132
|
-
|
135
|
+
void setIsHandlingTouches(bool isHandlingTouches) { m_isHandlingTouches = isHandlingTouches; }
|
133
136
|
|
134
|
-
|
137
|
+
bool isHandlingTouches() const override { return m_isHandlingTouches; }
|
135
138
|
|
136
139
|
private:
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
140
|
+
std::vector<TouchableView> findTouchableViews(float componentX, float componentY) {
|
141
|
+
auto touchTarget = findTargetForTouchPoint({.x = componentX, .y = componentY}, this->shared_from_this());
|
142
|
+
std::vector<TouchTarget::Shared> touchTargets{};
|
143
|
+
auto tmp = touchTarget;
|
144
|
+
while (tmp != nullptr) {
|
145
|
+
touchTargets.push_back(tmp);
|
146
|
+
tmp = tmp->getTouchTargetParent();
|
147
|
+
}
|
148
|
+
std::reverse(touchTargets.begin(), touchTargets.end()); // leaf / ... / root -> root / ... / leaf
|
149
|
+
std::vector<TouchableView> touchableViews{};
|
150
|
+
|
151
|
+
float offsetX = 0;
|
152
|
+
float offsetY = 0;
|
153
|
+
auto surface = this->getSurface().lock();
|
154
|
+
if (surface != nullptr) {
|
155
|
+
offsetX = surface->getLayoutContext().viewportOffset.x;
|
156
|
+
offsetY = surface->getLayoutContext().viewportOffset.y;
|
157
|
+
} else {
|
158
|
+
LOG(WARNING) << "Surface is nullptr";
|
159
|
+
}
|
160
|
+
for (auto &touchTarget : touchTargets) {
|
161
|
+
auto buttonRole = dynamic_cast<RNGestureHandlerButtonComponentInstance *>(touchTarget.get()) != nullptr;
|
162
|
+
auto frame = touchTarget->getLayoutMetrics().frame;
|
163
|
+
auto transform = touchTarget->getTransform();
|
164
|
+
auto transformedFrame = frame * transform;
|
165
|
+
touchableViews.push_back({
|
166
|
+
.tag = touchTarget->getTouchTargetTag(),
|
167
|
+
.width = transformedFrame.size.width,
|
168
|
+
.height = transformedFrame.size.height,
|
169
|
+
.x = transformedFrame.origin.x + offsetX,
|
170
|
+
.y = transformedFrame.origin.y + offsetY,
|
171
|
+
.buttonRole = buttonRole,
|
172
|
+
});
|
173
|
+
offsetX += transformedFrame.origin.x;
|
174
|
+
offsetY += transformedFrame.origin.y;
|
175
|
+
offsetX -= touchTarget->getCurrentOffset().x;
|
176
|
+
offsetY -= touchTarget->getCurrentOffset().y;
|
177
|
+
}
|
178
|
+
|
179
|
+
return touchableViews;
|
174
180
|
}
|
175
181
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
d_touchableViews.push_back(d_touchableView);
|
182
|
+
folly::dynamic dynamicFromTouchableViews(const std::vector<TouchableView> &touchableViews) {
|
183
|
+
folly::dynamic d_touchableViews = folly::dynamic::array();
|
184
|
+
for (auto touchableView : touchableViews) {
|
185
|
+
folly::dynamic d_touchableView = folly::dynamic::object;
|
186
|
+
d_touchableView["tag"] = touchableView.tag;
|
187
|
+
d_touchableView["x"] = touchableView.x;
|
188
|
+
d_touchableView["y"] = touchableView.y;
|
189
|
+
d_touchableView["width"] = touchableView.width;
|
190
|
+
d_touchableView["height"] = touchableView.height;
|
191
|
+
d_touchableView["buttonRole"] = touchableView.buttonRole;
|
192
|
+
d_touchableViews.push_back(d_touchableView);
|
193
|
+
}
|
194
|
+
return d_touchableViews;
|
190
195
|
}
|
191
|
-
return d_touchableViews;
|
192
|
-
}
|
193
196
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
folly::dynamic convertNodeTouchPointToDynamic(ArkUI_UIInputEvent *e, int32_t index = 0) {
|
198
|
+
folly::dynamic result = folly::dynamic::object;
|
199
|
+
result["pointerId"] = OH_ArkUI_PointerEvent_GetPointerId(e, index);
|
200
|
+
result["windowX"] = OH_ArkUI_PointerEvent_GetWindowXByIndex(e, index);
|
201
|
+
result["windowY"] = OH_ArkUI_PointerEvent_GetWindowYByIndex(e, index);
|
202
|
+
return result;
|
203
|
+
}
|
201
204
|
|
202
205
|
protected:
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
206
|
+
void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
|
207
|
+
CppComponentInstance::onChildInserted(childComponentInstance, index);
|
208
|
+
m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
|
209
|
+
};
|
207
210
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
211
|
+
void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
|
212
|
+
CppComponentInstance::onChildRemoved(childComponentInstance);
|
213
|
+
m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
|
214
|
+
};
|
212
215
|
|
213
216
|
private:
|
214
|
-
|
217
|
+
Surface::Weak m_surface;
|
215
218
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
219
|
+
Surface::Weak getSurface() {
|
220
|
+
if (m_surface.lock() != nullptr) {
|
221
|
+
return m_surface;
|
222
|
+
}
|
223
|
+
auto rnInstance = m_deps->rnInstance.lock();
|
224
|
+
if (rnInstance == nullptr) {
|
225
|
+
m_surface.reset();
|
226
|
+
return m_surface;
|
227
|
+
}
|
228
|
+
ComponentInstance::Shared currentRoot = shared_from_this();
|
229
|
+
while (true) {
|
230
|
+
auto maybeNewCurrentRoot = currentRoot->getParent().lock();
|
231
|
+
if (maybeNewCurrentRoot == nullptr) {
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
currentRoot = maybeNewCurrentRoot;
|
235
|
+
}
|
236
|
+
auto maybeSurface = rnInstance->getSurfaceByRootTag(currentRoot->getTag());
|
237
|
+
if (!maybeSurface.has_value()) {
|
238
|
+
m_surface.reset();
|
239
|
+
return m_surface;
|
240
|
+
}
|
241
|
+
m_surface = maybeSurface.value();
|
242
|
+
return m_surface;
|
237
243
|
}
|
238
|
-
m_surface = maybeSurface.value();
|
239
|
-
return m_surface;
|
240
|
-
}
|
241
244
|
};
|
242
245
|
} // namespace rnoh
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { RNPackage, RNPackageContext } from "@rnoh/react-native-openharmony";
|
2
|
+
import type { TurboModule, TurboModuleContext } from "@rnoh/react-native-openharmony/ts";
|
3
|
+
import { RNGestureHandlerModule } from './rnoh/RNGestureHandlerModule';
|
4
|
+
|
5
|
+
export default class RnohReactNativeHarmonyGestureHandlerPackage extends RNPackage {
|
6
|
+
private isRNGHDevModeEnabled: boolean
|
7
|
+
|
8
|
+
constructor(ctx: RNPackageContext, isRNGHDevModeEnabled: boolean = false) {
|
9
|
+
super(ctx)
|
10
|
+
this.isRNGHDevModeEnabled = isRNGHDevModeEnabled
|
11
|
+
}
|
12
|
+
|
13
|
+
getUITurboModuleFactoryByNameMap(): Map<string, (ctx: TurboModuleContext) => TurboModule | null> {
|
14
|
+
return new Map().set(RNGestureHandlerModule.NAME,
|
15
|
+
(ctx: TurboModuleContext) => new RNGestureHandlerModule(ctx, this.isRNGHDevModeEnabled))
|
16
|
+
}
|
17
|
+
}
|