@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.
Files changed (59) hide show
  1. package/harmony/gesture_handler/BuildProfile.ets +1 -1
  2. package/harmony/gesture_handler/index.ets +1 -2
  3. package/harmony/gesture_handler/oh-package-lock.json5 +1 -1
  4. package/harmony/gesture_handler/oh-package.json5 +1 -1
  5. package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +1 -1
  6. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +9 -18
  7. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +123 -0
  8. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +15 -0
  9. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +17 -17
  10. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +203 -200
  11. package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +17 -0
  12. package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +84 -35
  13. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +20 -11
  14. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +2 -2
  15. package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +4 -4
  16. package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +26 -0
  17. package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +7 -3
  18. package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +1 -2
  19. package/harmony/gesture_handler/src/main/ets/core/index.ts +2 -2
  20. package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +12 -4
  21. package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +8 -5
  22. package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +14 -2
  23. package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +9 -1
  24. package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +13 -4
  25. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +31 -12
  26. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +145 -130
  27. package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +9 -1
  28. package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +15 -5
  29. package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +7 -4
  30. package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +74 -16
  31. package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +35 -12
  32. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +182 -0
  33. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +62 -0
  34. package/harmony/gesture_handler/src/main/ets/rnoh/{GestureHandlerArkUIAdapter.ts → RNGHViewController.ts} +44 -22
  35. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +19 -0
  36. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +130 -96
  37. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -9
  38. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +1 -8
  39. package/harmony/gesture_handler.har +0 -0
  40. package/package.json +7 -3
  41. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +0 -149
  42. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +0 -36
  43. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +0 -32
  44. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +0 -22
  45. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +0 -15
  46. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +0 -36
  47. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +0 -25
  48. package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +0 -11
  49. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +0 -24
  50. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerButton.ts +0 -139
  51. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerRootView.ts +0 -101
  52. package/harmony/gesture_handler/src/main/ets/namespace/components/ts.ts +0 -2
  53. package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +0 -2
  54. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +0 -98
  55. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerCAPI.ts +0 -110
  56. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerButton.ets +0 -38
  57. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerRootView.ets +0 -53
  58. package/harmony/gesture_handler/src/main/ets/rnoh/View.ts +0 -134
  59. 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 "../RNGestureHandlerRootViewComponentDescriptor.h"
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
- using Point = facebook::react::Point;
15
-
16
- /**
17
- * This function is borrowed from TouchEventDispatcher
18
- */
19
- static TouchTarget::Shared findTargetForTouchPoint(Point const &point, TouchTarget::Shared const &target) {
20
- bool canHandleTouch =
21
- target->canHandleTouch() && target->containsPoint(point) && (target->getTouchEventEmitter() != nullptr);
22
- bool canChildrenHandleTouch = target->canChildrenHandleTouch() && target->containsPointInBoundingBox(point);
23
-
24
- if (canChildrenHandleTouch) {
25
- auto children = target->getTouchTargetChildren();
26
- // we want to check the children in reverse order, since the last child is the topmost one
27
- std::reverse(children.begin(), children.end());
28
- for (auto const &child : children) {
29
- auto childPoint = target->computeChildPoint(point, child);
30
- auto result = findTargetForTouchPoint(childPoint, child);
31
- if (result != nullptr) {
32
- return result;
33
- }
34
- }
35
- }
36
- if (canHandleTouch) {
37
- return target;
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
- bool m_isHandlingTouches = false;
44
- StackNode m_stackNode;
45
-
46
- struct TouchableView {
47
- Tag tag;
48
- facebook::react::Float width;
49
- facebook::react::Float height;
50
- facebook::react::Float x;
51
- facebook::react::Float y;
52
- bool buttonRole;
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
- RNGestureHandlerRootViewComponentInstance(Context context) : CppComponentInstance(std::move(context)) {
57
- ArkUINodeRegistry::getInstance().registerTouchHandler(&m_stackNode, this);
58
- NativeNodeApi::getInstance()->registerNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT,
59
- NODE_TOUCH_EVENT, 0);
60
- auto rnInstance = m_deps->rnInstance.lock();
61
- if (rnInstance) {
62
- rnInstance->postMessageToArkTS("RNGH::ROOT_CREATED", m_tag);
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
- auto ancestorTouchTarget = this->getTouchTargetParent();
86
- auto rnInstance = m_deps->rnInstance.lock();
87
- while (ancestorTouchTarget != nullptr) {
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
- folly::dynamic payload = folly::dynamic::object;
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
- // point relative to top left corner of this component
102
- auto componentX = OH_ArkUI_PointerEvent_GetX(e);
103
- auto componentY = OH_ArkUI_PointerEvent_GetY(e);
104
- auto touchableViews = this->findTouchableViews(componentX, componentY);
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
- std::stringstream touchableViewTags;
107
- for (auto touchableView : touchableViews) {
108
- touchableViewTags << touchableView.tag << ";";
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
- payload["touchableViews"] = this->dynamicFromTouchableViews(touchableViews);
97
+ folly::dynamic payload = folly::dynamic::object;
98
+ folly::dynamic touchPoints = folly::dynamic::array();
99
+ std::vector<TouchableView> touchableViews;
112
100
 
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() && activeWindowY == touchPoint["windowY"].asDouble()) {
119
- activePointerIdx = i;
120
- }
121
- }
122
- payload["actionTouch"] = touchPoints[activePointerIdx];
123
- payload["touchPoints"] = touchPoints;
124
- payload["sourceType"] = OH_ArkUI_UIInputEvent_GetSourceType(e);
125
- payload["timestamp"] = OH_ArkUI_UIInputEvent_GetEventTime(e);
126
- payload["rootTag"] = m_tag;
127
- if (rnInstance) {
128
- rnInstance->postMessageToArkTS("RNGH::TOUCH_EVENT", payload);
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
- void setIsHandlingTouches(bool isHandlingTouches) { m_isHandlingTouches = isHandlingTouches; }
135
+ void setIsHandlingTouches(bool isHandlingTouches) { m_isHandlingTouches = isHandlingTouches; }
133
136
 
134
- bool isHandlingTouches() const override { return m_isHandlingTouches; }
137
+ bool isHandlingTouches() const override { return m_isHandlingTouches; }
135
138
 
136
139
  private:
137
- std::vector<TouchableView> findTouchableViews(float componentX, float componentY) {
138
- auto touchTarget = findTargetForTouchPoint({.x = componentX, .y = componentY}, this->shared_from_this());
139
- std::vector<TouchTarget::Shared> touchTargets{};
140
- auto tmp = touchTarget;
141
- while (tmp != nullptr) {
142
- touchTargets.push_back(tmp);
143
- tmp = tmp->getTouchTargetParent();
144
- }
145
- std::reverse(touchTargets.begin(), touchTargets.end()); // leaf / ... / root -> root / ... / leaf
146
- std::vector<TouchableView> touchableViews{};
147
-
148
- float offsetX = 0;
149
- float offsetY = 0;
150
- auto surface = this->getSurface().lock();
151
- if (surface != nullptr) {
152
- offsetX = surface->getLayoutContext().viewportOffset.x;
153
- offsetY = surface->getLayoutContext().viewportOffset.y;
154
- } else {
155
- LOG(WARNING) << "Surface is nullptr";
156
- }
157
- for (auto &touchTarget : touchTargets) {
158
- auto buttonRole = dynamic_cast<RNGestureHandlerButtonComponentInstance*>(touchTarget.get()) != nullptr;
159
- auto frame = touchTarget->getLayoutMetrics().frame;
160
- auto transform = touchTarget->getTransform();
161
- auto transformedFrame = frame * transform;
162
- touchableViews.push_back({
163
- .tag = touchTarget->getTouchTargetTag(),
164
- .width = transformedFrame.size.width,
165
- .height = transformedFrame.size.height,
166
- .x = transformedFrame.origin.x + offsetX,
167
- .y = transformedFrame.origin.y + offsetY,
168
- .buttonRole = buttonRole,
169
- });
170
- offsetX += transformedFrame.origin.x;
171
- offsetY += transformedFrame.origin.y;
172
- offsetX -= touchTarget->getCurrentOffset().x;
173
- offsetY -= touchTarget->getCurrentOffset().y;
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
- return touchableViews;
177
- }
178
-
179
- folly::dynamic dynamicFromTouchableViews(const std::vector<TouchableView> &touchableViews) {
180
- folly::dynamic d_touchableViews = folly::dynamic::array();
181
- for (auto touchableView : touchableViews) {
182
- folly::dynamic d_touchableView = folly::dynamic::object;
183
- d_touchableView["tag"] = touchableView.tag;
184
- d_touchableView["x"] = touchableView.x;
185
- d_touchableView["y"] = touchableView.y;
186
- d_touchableView["width"] = touchableView.width;
187
- d_touchableView["height"] = touchableView.height;
188
- d_touchableView["buttonRole"] = touchableView.buttonRole;
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
- folly::dynamic convertNodeTouchPointToDynamic(ArkUI_UIInputEvent *e, int32_t index = 0) {
195
- folly::dynamic result = folly::dynamic::object;
196
- result["pointerId"] = OH_ArkUI_PointerEvent_GetPointerId(e, index);
197
- result["windowX"] = OH_ArkUI_PointerEvent_GetWindowXByIndex(e, index);
198
- result["windowY"] = OH_ArkUI_PointerEvent_GetWindowYByIndex(e, index);
199
- return result;
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
- void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
204
- CppComponentInstance::onChildInserted(childComponentInstance, index);
205
- m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
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
- void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
209
- CppComponentInstance::onChildRemoved(childComponentInstance);
210
- m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
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
- Surface::Weak m_surface;
217
+ Surface::Weak m_surface;
215
218
 
216
- Surface::Weak getSurface() {
217
- if (m_surface.lock() != nullptr) {
218
- return m_surface;
219
- }
220
- auto rnInstance = m_deps->rnInstance.lock();
221
- if (rnInstance == nullptr) {
222
- m_surface.reset();
223
- return m_surface;
224
- }
225
- ComponentInstance::Shared currentRoot = shared_from_this();
226
- while (true) {
227
- auto maybeNewCurrentRoot = currentRoot->getParent().lock();
228
- if (maybeNewCurrentRoot == nullptr) {
229
- break;
230
- }
231
- currentRoot = maybeNewCurrentRoot;
232
- }
233
- auto maybeSurface = rnInstance->getSurfaceByRootTag(currentRoot->getTag());
234
- if (!maybeSurface.has_value()) {
235
- m_surface.reset();
236
- return m_surface;
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
+ }