@react-native-oh-tpl/react-native-gesture-handler 2.12.6-1 → 2.12.9-1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. package/harmony/gesture_handler/BuildProfile.ets +6 -0
  2. package/harmony/gesture_handler/build-profile.json5 +18 -7
  3. package/harmony/gesture_handler/hvigorfile.ts +2 -2
  4. package/harmony/gesture_handler/index.ets +3 -3
  5. package/harmony/gesture_handler/oh-package-lock.json5 +18 -0
  6. package/harmony/gesture_handler/oh-package.json5 +12 -11
  7. package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
  8. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +103 -34
  9. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +21 -15
  10. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +36 -60
  11. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentInstance.h +27 -0
  12. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +32 -0
  13. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +22 -17
  14. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +15 -12
  15. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerPackage.h +72 -0
  16. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +36 -60
  17. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentInstance.h +123 -0
  18. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
  19. package/harmony/gesture_handler/src/main/ets/CircularBuffer.ts +42 -42
  20. package/harmony/gesture_handler/src/main/ets/Event.ts +67 -67
  21. package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +52 -37
  22. package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
  23. package/harmony/gesture_handler/src/main/ets/{GestureHandlerArkUIAdapter.ets → GestureHandlerArkUIAdapter.ts} +202 -201
  24. package/harmony/gesture_handler/src/main/ets/GestureHandlerFactory.ts +44 -44
  25. package/harmony/gesture_handler/src/main/ets/GestureHandlerOrchestrator.ts +280 -280
  26. package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +22 -22
  27. package/harmony/gesture_handler/src/main/ets/GestureHandlerRegistry.ts +27 -27
  28. package/harmony/gesture_handler/src/main/ets/InteractionManager.ts +108 -108
  29. package/harmony/gesture_handler/src/main/ets/LeastSquareSolver.ts +182 -182
  30. package/harmony/gesture_handler/src/main/ets/NativeViewGestureHandler.ts +114 -114
  31. package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +33 -33
  32. package/harmony/gesture_handler/src/main/ets/PanGestureHandler.ts +327 -327
  33. package/harmony/gesture_handler/src/main/ets/PointerTracker.ts +239 -239
  34. package/harmony/gesture_handler/src/main/ets/RNGHError.ts +4 -4
  35. package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +47 -28
  36. package/harmony/gesture_handler/src/main/ets/{RNGHRootTouchHandler.ets → RNGHRootTouchHandlerArkTS.ts} +59 -57
  37. package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandlerCAPI.ts +87 -0
  38. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +37 -36
  39. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +183 -125
  40. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +52 -55
  41. package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +23 -11
  42. package/harmony/gesture_handler/src/main/ets/State.ts +46 -46
  43. package/harmony/gesture_handler/src/main/ets/TapGestureHandler.ts +205 -205
  44. package/harmony/gesture_handler/src/main/ets/Vector2D.ts +36 -36
  45. package/harmony/gesture_handler/src/main/ets/VelocityTracker.ts +98 -98
  46. package/harmony/gesture_handler/src/main/ets/View.ts +70 -70
  47. package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +42 -42
  48. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerButton.ts +140 -0
  49. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +25 -0
  50. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerRootView.ts +101 -0
  51. package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +3 -0
  52. package/harmony/gesture_handler/src/main/ets/pages/Index.ets +16 -16
  53. package/harmony/gesture_handler/src/main/ets/types.ts +25 -0
  54. package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
  55. package/harmony/gesture_handler/src/main/module.json5 +7 -7
  56. package/harmony/gesture_handler/src/main/resources/base/element/color.json +7 -7
  57. package/harmony/gesture_handler/src/main/resources/base/element/string.json +15 -15
  58. package/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json +5 -5
  59. package/harmony/gesture_handler/src/main/resources/en_US/element/string.json +15 -15
  60. package/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json +15 -15
  61. package/harmony/gesture_handler/ts.ts +2 -1
  62. package/harmony/gesture_handler.har +0 -0
  63. package/lib/commonjs/RNGestureHandlerModule.js +6 -3
  64. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  65. package/lib/commonjs/components/GestureHandlerRootView.js +5 -13
  66. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  67. package/lib/commonjs/handlers/createHandler.js +31 -28
  68. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  69. package/lib/commonjs/index.js +42 -19
  70. package/lib/commonjs/index.js.map +1 -1
  71. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +10 -0
  72. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
  73. package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js +11 -0
  74. package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  75. package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js +11 -0
  76. package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  77. package/lib/module/RNGestureHandlerModule.js +3 -2
  78. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  79. package/lib/module/components/GestureHandlerRootView.js +3 -11
  80. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  81. package/lib/module/handlers/createHandler.js +20 -19
  82. package/lib/module/handlers/createHandler.js.map +1 -1
  83. package/lib/module/index.js +6 -14
  84. package/lib/module/index.js.map +1 -1
  85. package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
  86. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
  87. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js +3 -0
  88. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  89. package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js +3 -0
  90. package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  91. package/lib/typescript/RNGestureHandlerModule.d.ts +2 -6
  92. package/lib/typescript/RNGestureHandlerModule.d.ts.map +1 -1
  93. package/lib/typescript/components/GestureHandlerRootView.d.ts +6 -6
  94. package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
  95. package/lib/typescript/handlers/createHandler.d.ts +11 -11
  96. package/lib/typescript/handlers/createHandler.d.ts.map +1 -1
  97. package/lib/typescript/index.d.ts +9 -8
  98. package/lib/typescript/index.d.ts.map +1 -1
  99. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +15 -0
  100. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -0
  101. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +15 -0
  102. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -0
  103. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +7 -0
  104. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -0
  105. package/package.json +66 -70
  106. package/src/RNGestureHandlerModule.ts +5 -6
  107. package/src/components/GestureHandlerRootView.tsx +23 -34
  108. package/src/handlers/createHandler.tsx +534 -535
  109. package/src/index.ts +172 -172
  110. package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
  111. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +18 -0
  112. package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -0
  113. package/README.md +0 -1
  114. package/lib/commonjs/components/GestureButtons.js +0 -186
  115. package/lib/commonjs/components/GestureButtons.js.map +0 -1
  116. package/lib/commonjs/components/GestureHandlerButton.js +0 -9
  117. package/lib/commonjs/components/GestureHandlerButton.js.map +0 -1
  118. package/lib/commonjs/components/RNGestureHandlerButton.js +0 -23
  119. package/lib/commonjs/components/RNGestureHandlerButton.js.map +0 -1
  120. package/lib/commonjs/components/touchables/GenericTouchable.js +0 -247
  121. package/lib/commonjs/components/touchables/GenericTouchable.js.map +0 -1
  122. package/lib/commonjs/components/touchables/TouchableOpacity.js +0 -58
  123. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +0 -1
  124. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +0 -18
  125. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +0 -1
  126. package/lib/commonjs/components/touchables/index.js +0 -21
  127. package/lib/commonjs/components/touchables/index.js.map +0 -1
  128. package/lib/commonjs/handlers/NativeViewGestureHandler.js +0 -19
  129. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +0 -1
  130. package/lib/commonjs/handlers/PanGestureHandler.js +0 -103
  131. package/lib/commonjs/handlers/PanGestureHandler.js.map +0 -1
  132. package/lib/commonjs/handlers/TapGestureHandler.js +0 -22
  133. package/lib/commonjs/handlers/TapGestureHandler.js.map +0 -1
  134. package/lib/commonjs/handlers/createNativeWrapper.js +0 -64
  135. package/lib/commonjs/handlers/createNativeWrapper.js.map +0 -1
  136. package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -22
  137. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +0 -1
  138. package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -554
  139. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
  140. package/lib/commonjs/init.js +0 -24
  141. package/lib/commonjs/init.js.map +0 -1
  142. package/lib/module/components/GestureButtons.js +0 -168
  143. package/lib/module/components/GestureButtons.js.map +0 -1
  144. package/lib/module/components/GestureHandlerButton.js +0 -3
  145. package/lib/module/components/GestureHandlerButton.js.map +0 -1
  146. package/lib/module/components/RNGestureHandlerButton.js +0 -17
  147. package/lib/module/components/RNGestureHandlerButton.js.map +0 -1
  148. package/lib/module/components/touchables/GenericTouchable.js +0 -238
  149. package/lib/module/components/touchables/GenericTouchable.js.map +0 -1
  150. package/lib/module/components/touchables/TouchableOpacity.js +0 -49
  151. package/lib/module/components/touchables/TouchableOpacity.js.map +0 -1
  152. package/lib/module/components/touchables/TouchableWithoutFeedback.js +0 -9
  153. package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +0 -1
  154. package/lib/module/components/touchables/index.js +0 -8
  155. package/lib/module/components/touchables/index.js.map +0 -1
  156. package/lib/module/handlers/NativeViewGestureHandler.js +0 -12
  157. package/lib/module/handlers/NativeViewGestureHandler.js.map +0 -1
  158. package/lib/module/handlers/PanGestureHandler.js +0 -92
  159. package/lib/module/handlers/PanGestureHandler.js.map +0 -1
  160. package/lib/module/handlers/TapGestureHandler.js +0 -14
  161. package/lib/module/handlers/TapGestureHandler.js.map +0 -1
  162. package/lib/module/handlers/createNativeWrapper.js +0 -57
  163. package/lib/module/handlers/createNativeWrapper.js.map +0 -1
  164. package/lib/module/handlers/gestureHandlerCommon.js +0 -15
  165. package/lib/module/handlers/gestureHandlerCommon.js.map +0 -1
  166. package/lib/module/handlers/gestures/GestureDetector.js +0 -543
  167. package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
  168. package/lib/module/init.js +0 -17
  169. package/lib/module/init.js.map +0 -1
  170. package/lib/typescript/components/GestureButtons.d.ts +0 -122
  171. package/lib/typescript/components/GestureButtons.d.ts.map +0 -1
  172. package/lib/typescript/components/GestureHandlerButton.d.ts +0 -5
  173. package/lib/typescript/components/GestureHandlerButton.d.ts.map +0 -1
  174. package/lib/typescript/components/RNGestureHandlerButton.d.ts +0 -2
  175. package/lib/typescript/components/RNGestureHandlerButton.d.ts.map +0 -1
  176. package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -68
  177. package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +0 -1
  178. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -26
  179. package/lib/typescript/components/touchables/TouchableOpacity.d.ts.map +0 -1
  180. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -8
  181. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts.map +0 -1
  182. package/lib/typescript/components/touchables/index.d.ts +0 -4
  183. package/lib/typescript/components/touchables/index.d.ts.map +0 -1
  184. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -29
  185. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts.map +0 -1
  186. package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -140
  187. package/lib/typescript/handlers/PanGestureHandler.d.ts.map +0 -1
  188. package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -58
  189. package/lib/typescript/handlers/TapGestureHandler.d.ts.map +0 -1
  190. package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -4
  191. package/lib/typescript/handlers/createNativeWrapper.d.ts.map +0 -1
  192. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -2
  193. package/lib/typescript/handlers/gestureHandlerCommon.d.ts.map +0 -1
  194. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -24
  195. package/lib/typescript/handlers/gestures/GestureDetector.d.ts.map +0 -1
  196. package/lib/typescript/init.d.ts +0 -3
  197. package/lib/typescript/init.d.ts.map +0 -1
  198. package/src/components/GestureButtons.tsx +0 -334
  199. package/src/components/GestureHandlerButton.tsx +0 -5
  200. package/src/components/RNGestureHandlerButton.tsx +0 -23
  201. package/src/components/touchables/GenericTouchable.tsx +0 -301
  202. package/src/components/touchables/TouchableOpacity.tsx +0 -76
  203. package/src/components/touchables/TouchableWithoutFeedback.tsx +0 -14
  204. package/src/components/touchables/index.ts +0 -7
  205. package/src/handlers/NativeViewGestureHandler.ts +0 -55
  206. package/src/handlers/PanGestureHandler.ts +0 -327
  207. package/src/handlers/TapGestureHandler.ts +0 -95
  208. package/src/handlers/createNativeWrapper.tsx +0 -81
  209. package/src/handlers/gestureHandlerCommon.ts +0 -15
  210. package/src/handlers/gestures/GestureDetector.tsx +0 -823
  211. package/src/init.ts +0 -18
@@ -1,60 +1,36 @@
1
- #pragma once
2
-
3
- #include <react/renderer/core/ConcreteComponentDescriptor.h>
4
- #include <react/renderer/components/view/ConcreteViewShadowNode.h>
5
- #include <react/renderer/components/view/ViewShadowNode.h>
6
- #include "RNOH/ArkJS.h"
7
- #include "RNOH/EventEmitRequestHandler.h"
8
-
9
- namespace facebook {
10
- namespace react {
11
-
12
- extern const char RNGestureHandlerRootViewComponentName[] = "RNGestureHandlerRootView";
13
-
14
- class RNGestureHandlerRootViewEventEmitter : public ViewEventEmitter {
15
- using ViewEventEmitter::ViewEventEmitter;
16
-
17
- public:
18
- void emit(std::string type, const folly::dynamic &payload) const {
19
- this->dispatchEvent(type, payload);
20
- }
21
- };
22
-
23
- class RNGestureHandlerRootViewEventEmitRequestHandler : public rnoh::EventEmitRequestHandler {
24
- void handleEvent(rnoh::EventEmitRequestHandler::Context const &ctx) override {
25
- std::string prefix = "RNGestureHandlerRootView";
26
- size_t prefixPos = ctx.eventName.find(prefix);
27
- if (prefixPos != std::string::npos) {
28
- ArkJS arkJs(ctx.env);
29
- auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<RNGestureHandlerRootViewEventEmitter>(ctx.tag);
30
- if (eventEmitter != nullptr) {
31
- auto payload = arkJs.getDynamic(ctx.payload);
32
- std::string eventName = ctx.eventName.substr(prefixPos + prefix.length());
33
- eventEmitter->emit(eventName, payload);
34
- }
35
- }
36
- }
37
- };
38
-
39
- class RNGestureHandlerRootViewProps : public ViewProps {
40
- public:
41
- RNGestureHandlerRootViewProps() = default;
42
-
43
- RNGestureHandlerRootViewProps(const PropsParserContext &context, const RNGestureHandlerRootViewProps &sourceProps, const RawProps &rawProps)
44
- : ViewProps(context, sourceProps, rawProps) {}
45
- };
46
-
47
- using RNGestureHandlerRootViewShadowNode = ConcreteViewShadowNode<
48
- RNGestureHandlerRootViewComponentName,
49
- RNGestureHandlerRootViewProps,
50
- RNGestureHandlerRootViewEventEmitter>;
51
-
52
- class RNGestureHandlerRootViewComponentDescriptor final
53
- : public ConcreteComponentDescriptor<RNGestureHandlerRootViewShadowNode> {
54
- public:
55
- RNGestureHandlerRootViewComponentDescriptor(ComponentDescriptorParameters const &parameters)
56
- : ConcreteComponentDescriptor(parameters) {}
57
- };
58
-
59
- } // namespace react
60
- } // namespace facebook
1
+
2
+ #pragma once
3
+
4
+ // This file was generated.
5
+
6
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
7
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
8
+ #include <react/renderer/components/view/ViewShadowNode.h>
9
+
10
+ namespace facebook {
11
+ namespace react {
12
+
13
+ extern const char RNGestureHandlerRootViewComponentName[] = "RNGestureHandlerRootView";
14
+
15
+ class RNGestureHandlerRootViewProps : public ViewProps {
16
+ public:
17
+ RNGestureHandlerRootViewProps() = default;
18
+
19
+ RNGestureHandlerRootViewProps(const PropsParserContext &context, const RNGestureHandlerRootViewProps &sourceProps, const RawProps &rawProps)
20
+ : ViewProps(context, sourceProps, rawProps) {}
21
+ };
22
+
23
+ using RNGestureHandlerRootViewShadowNode = ConcreteViewShadowNode<
24
+ RNGestureHandlerRootViewComponentName,
25
+ RNGestureHandlerRootViewProps,
26
+ ViewEventEmitter>;
27
+
28
+ class RNGestureHandlerRootViewComponentDescriptor final
29
+ : public ConcreteComponentDescriptor<RNGestureHandlerRootViewShadowNode> {
30
+ public:
31
+ RNGestureHandlerRootViewComponentDescriptor(ComponentDescriptorParameters const &parameters)
32
+ : ConcreteComponentDescriptor(parameters) {}
33
+ };
34
+
35
+ } // namespace react
36
+ } // namespace facebook
@@ -0,0 +1,123 @@
1
+ #pragma once
2
+ #import "RNOH/CppComponentInstance.h"
3
+ #import "RNOH/arkui/StackNode.h"
4
+ #import "RNOH/arkui/ArkUINodeRegistry.h"
5
+ #import "RNOH/arkui/NativeNodeApi.h"
6
+ #import "RNGestureHandlerRootViewComponentDescriptor.h"
7
+ #include "RNOH/arkui/TouchEventDispatcher.h"
8
+
9
+ namespace rnoh {
10
+ class RNGestureHandlerRootViewComponentInstance
11
+ : public CppComponentInstance<facebook::react::RNGestureHandlerRootViewShadowNode>,
12
+ public TouchEventHandler {
13
+ private:
14
+ StackNode m_stackNode;
15
+
16
+ public:
17
+ RNGestureHandlerRootViewComponentInstance(Context context) : CppComponentInstance(std::move(context)) {
18
+ ArkUINodeRegistry::getInstance().registerTouchHandler(&m_stackNode, this);
19
+ NativeNodeApi::getInstance()->registerNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT, 0, nullptr);
20
+ m_deps->arkTSChannel->postMessage("RNGH::ROOT_CREATED", m_tag);
21
+ };
22
+
23
+ ~RNGestureHandlerRootViewComponentInstance() {
24
+ ArkUINodeRegistry::getInstance().unregisterTouchHandler(&m_stackNode);
25
+ NativeNodeApi::getInstance()->unregisterNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT);
26
+ }
27
+
28
+ StackNode &getLocalRootArkUINode() override { return m_stackNode; };
29
+
30
+ void onTouchEvent(ArkUI_UIInputEvent *e) override {
31
+ folly::dynamic payload = folly::dynamic::object;
32
+ payload["action"] = static_cast<int>(OH_ArkUI_UIInputEvent_GetAction(e));
33
+ payload["actionTouch"] = this->convertNodeTouchPointToDynamic(getActiveTouchFromEvent(e));
34
+ folly::dynamic touchPoints = folly::dynamic::array();
35
+ touchPoints.push_back(this->convertNodeTouchPointToDynamic(getActiveTouchFromEvent(e)));
36
+ payload["touchPoints"] = touchPoints;
37
+ payload["sourceType"] = static_cast<int>(OH_ArkUI_UIInputEvent_GetSourceType(e));
38
+ payload["timestamp"] = OH_ArkUI_UIInputEvent_GetEventTime(e);
39
+ payload["rootTag"] = m_tag;
40
+ m_deps->arkTSChannel->postMessage("RNGH::TOUCH_EVENT", payload);
41
+ }
42
+
43
+ private:
44
+ struct TouchPoint {
45
+ int32_t contactAreaHeight;
46
+ int32_t contactAreaWidth;
47
+ int32_t id;
48
+ int32_t nodeX;
49
+ int32_t nodeY;
50
+ int64_t pressedTime;
51
+ double pressure;
52
+ int32_t rawX;
53
+ int32_t rawY;
54
+ int32_t screenX;
55
+ int32_t screenY;
56
+ double tiltX;
57
+ double tiltY;
58
+ int32_t toolHeight;
59
+ int32_t toolWidth;
60
+ int32_t toolX;
61
+ int32_t toolY;
62
+ int32_t toolType;
63
+ int32_t windowX;
64
+ int32_t windowY;
65
+ };
66
+
67
+ TouchPoint getActiveTouchFromEvent(ArkUI_UIInputEvent *event) {
68
+ TouchPoint actionTouch{};
69
+ actionTouch = TouchPoint{
70
+ .contactAreaHeight = int32_t(OH_ArkUI_PointerEvent_GetTouchAreaHeight(event, 0)),
71
+ .contactAreaWidth = int32_t(OH_ArkUI_PointerEvent_GetTouchAreaWidth(event, 0)),
72
+ .id = OH_ArkUI_PointerEvent_GetPointerId(event, 0),
73
+ .nodeX = int32_t(OH_ArkUI_PointerEvent_GetX(event)),
74
+ .nodeY = int32_t(OH_ArkUI_PointerEvent_GetY(event)),
75
+ .pressure = double(OH_ArkUI_PointerEvent_GetPressure(event, 0)),
76
+ .screenX = int32_t(OH_ArkUI_PointerEvent_GetDisplayX(event)),
77
+ .screenY = int32_t(OH_ArkUI_PointerEvent_GetDisplayY(event)),
78
+ .tiltX = double(OH_ArkUI_PointerEvent_GetTiltX(event, 0)),
79
+ .tiltY = double(OH_ArkUI_PointerEvent_GetTiltX(event, 0)),
80
+ .toolType = int32_t(OH_ArkUI_UIInputEvent_GetToolType(event)),
81
+ .windowX = int32_t(OH_ArkUI_PointerEvent_GetWindowX(event)),
82
+ .windowY = int32_t(OH_ArkUI_PointerEvent_GetWindowY(event)),
83
+ };
84
+ return actionTouch;
85
+ }
86
+
87
+ folly::dynamic convertNodeTouchPointToDynamic(TouchPoint actionTouch) {
88
+ folly::dynamic result = folly::dynamic::object;
89
+ result["contactAreaHeight"] = actionTouch.contactAreaHeight;
90
+ result["contactAreaWidth"] = actionTouch.contactAreaWidth;
91
+ result["id"] = actionTouch.id;
92
+ result["nodeX"] = actionTouch.nodeX;
93
+ result["nodeY"] = actionTouch.nodeY;
94
+ // result["pressedTime"] = actionTouch.pressedTime;
95
+ result["pressure"] = actionTouch.pressure;
96
+ // result["rawX"] = actionTouch.rawX;
97
+ // result["rawY"] = actionTouch.rawY;
98
+ result["screenX"] = actionTouch.screenX;
99
+ result["screenY"] = actionTouch.screenY;
100
+ result["tiltX"] = actionTouch.tiltX;
101
+ result["tiltY"] = actionTouch.tiltY;
102
+ // result["toolHeight"] = actionTouch.toolHeight;
103
+ // result["toolWidth"] = actionTouch.toolWidth;
104
+ // result["toolX"] = actionTouch.toolX;
105
+ // result["toolY"] = actionTouch.toolY;
106
+ result["toolType"] = static_cast<int>(actionTouch.toolType);
107
+ result["windowX"] = actionTouch.windowX;
108
+ result["windowY"] = actionTouch.windowY;
109
+ return result;
110
+ }
111
+
112
+ protected:
113
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
114
+ CppComponentInstance::onChildInserted(childComponentInstance, index);
115
+ m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
116
+ };
117
+
118
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
119
+ CppComponentInstance::onChildRemoved(childComponentInstance);
120
+ m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
121
+ };
122
+ };
123
+ } // namespace rnoh
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ // This file was generated.
4
+
5
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
6
+
7
+ namespace rnoh {
8
+ class RNGestureHandlerRootViewJSIBinder : public ViewComponentJSIBinder {
9
+ protected:
10
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
11
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
12
+ return object;
13
+ }
14
+
15
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
16
+ facebook::jsi::Object events(rt);
17
+ return events;
18
+ }
19
+
20
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
21
+ facebook::jsi::Object events(rt);
22
+ return events;
23
+ }
24
+ };
25
+ } // namespace rnoh
@@ -1,42 +1,42 @@
1
- export class CircularBuffer<T> {
2
- private bufferSize: number;
3
- private buffer: T[];
4
- private index: number;
5
- private actualSize: number;
6
-
7
- constructor(size: number) {
8
- this.bufferSize = size;
9
- this.buffer = new Array<T>(size);
10
- this.index = 0;
11
- this.actualSize = 0;
12
- }
13
-
14
- public get size(): number {
15
- return this.actualSize;
16
- }
17
-
18
- public push(element: T): void {
19
- this.buffer[this.index] = element;
20
- this.index = (this.index + 1) % this.bufferSize;
21
- this.actualSize = Math.min(this.actualSize + 1, this.bufferSize);
22
- }
23
-
24
- public get(at: number): T {
25
- if (this.actualSize === this.bufferSize) {
26
- let index = (this.index + at) % this.bufferSize;
27
- if (index < 0) {
28
- index += this.bufferSize;
29
- }
30
-
31
- return this.buffer[index];
32
- } else {
33
- return this.buffer[at];
34
- }
35
- }
36
-
37
- public clear(): void {
38
- this.buffer = new Array<T>(this.bufferSize);
39
- this.index = 0;
40
- this.actualSize = 0;
41
- }
42
- }
1
+ export class CircularBuffer<T> {
2
+ private bufferSize: number;
3
+ private buffer: T[];
4
+ private index: number;
5
+ private actualSize: number;
6
+
7
+ constructor(size: number) {
8
+ this.bufferSize = size;
9
+ this.buffer = new Array<T>(size);
10
+ this.index = 0;
11
+ this.actualSize = 0;
12
+ }
13
+
14
+ public get size(): number {
15
+ return this.actualSize;
16
+ }
17
+
18
+ public push(element: T): void {
19
+ this.buffer[this.index] = element;
20
+ this.index = (this.index + 1) % this.bufferSize;
21
+ this.actualSize = Math.min(this.actualSize + 1, this.bufferSize);
22
+ }
23
+
24
+ public get(at: number): T {
25
+ if (this.actualSize === this.bufferSize) {
26
+ let index = (this.index + at) % this.bufferSize;
27
+ if (index < 0) {
28
+ index += this.bufferSize;
29
+ }
30
+
31
+ return this.buffer[index];
32
+ } else {
33
+ return this.buffer[at];
34
+ }
35
+ }
36
+
37
+ public clear(): void {
38
+ this.buffer = new Array<T>(this.bufferSize);
39
+ this.index = 0;
40
+ this.actualSize = 0;
41
+ }
42
+ }
@@ -1,68 +1,68 @@
1
- export interface HitSlop {
2
- left?: number;
3
- right?: number;
4
- top?: number;
5
- bottom?: number;
6
- horizontal?: number;
7
- vertical?: number;
8
- width?: number;
9
- height?: number;
10
- }
11
-
12
- export const Directions = {
13
- RIGHT: 1,
14
- LEFT: 2,
15
- UP: 4,
16
- DOWN: 8,
17
- } as const;
18
-
19
- export enum PointerType {
20
- NONE = 'none',
21
- MOUSE = 'mouse',
22
- TOUCH = 'touch',
23
- PEN = 'pen',
24
- }
25
-
26
- export enum EventType {
27
- DOWN,
28
- ADDITIONAL_POINTER_DOWN,
29
- UP,
30
- ADDITIONAL_POINTER_UP,
31
- MOVE,
32
- ENTER,
33
- OUT,
34
- CANCEL,
35
- }
36
-
37
- export type Touch = {id: number, x: number, y: number, absoluteX: number, absoluteY: number}
38
-
39
- export enum TouchEventType {
40
- UNDETERMINED = 0,
41
- DOWN = 1,
42
- MOVE = 2,
43
- UP = 3,
44
- CANCELLED = 4,
45
- }
46
-
47
- export interface AdaptedEvent {
48
- x: number;
49
- y: number;
50
- offsetX: number;
51
- offsetY: number;
52
- pointerId: number;
53
- eventType: EventType;
54
- pointerType: PointerType;
55
- buttons: number;
56
- time: number;
57
- allTouches?: Touch[];
58
- changedTouches?: Touch[];
59
- touchEventType?: TouchEventType;
60
- }
61
-
62
- export interface TrackerElement {
63
- lastX: number;
64
- lastY: number;
65
- timeStamp: number;
66
- velocityX: number;
67
- velocityY: number;
1
+ export interface HitSlop {
2
+ left?: number;
3
+ right?: number;
4
+ top?: number;
5
+ bottom?: number;
6
+ horizontal?: number;
7
+ vertical?: number;
8
+ width?: number;
9
+ height?: number;
10
+ }
11
+
12
+ export const Directions = {
13
+ RIGHT: 1,
14
+ LEFT: 2,
15
+ UP: 4,
16
+ DOWN: 8,
17
+ } as const;
18
+
19
+ export enum PointerType {
20
+ NONE = 'none',
21
+ MOUSE = 'mouse',
22
+ TOUCH = 'touch',
23
+ PEN = 'pen',
24
+ }
25
+
26
+ export enum EventType {
27
+ DOWN,
28
+ ADDITIONAL_POINTER_DOWN,
29
+ UP,
30
+ ADDITIONAL_POINTER_UP,
31
+ MOVE,
32
+ ENTER,
33
+ OUT,
34
+ CANCEL,
35
+ }
36
+
37
+ export type Touch = {id: number, x: number, y: number, absoluteX: number, absoluteY: number}
38
+
39
+ export enum TouchEventType {
40
+ UNDETERMINED = 0,
41
+ DOWN = 1,
42
+ MOVE = 2,
43
+ UP = 3,
44
+ CANCELLED = 4,
45
+ }
46
+
47
+ export interface AdaptedEvent {
48
+ x: number;
49
+ y: number;
50
+ offsetX: number;
51
+ offsetY: number;
52
+ pointerId: number;
53
+ eventType: EventType;
54
+ pointerType: PointerType;
55
+ buttons: number;
56
+ time: number;
57
+ allTouches?: Touch[];
58
+ changedTouches?: Touch[];
59
+ touchEventType?: TouchEventType;
60
+ }
61
+
62
+ export interface TrackerElement {
63
+ lastX: number;
64
+ lastY: number;
65
+ timeStamp: number;
66
+ velocityX: number;
67
+ velocityY: number;
68
68
  }
@@ -1,38 +1,53 @@
1
- import { RNInstance } from "rnoh/ts"
2
- import { GestureStateChangeEvent, GestureUpdateEvent, GestureTouchEvent } from "./OutgoingEvent"
3
- import { RNGHLogger } from './RNGHLogger'
4
-
5
- export interface EventDispatcher {
6
- onGestureHandlerStateChange(event: GestureStateChangeEvent): void
7
- onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent): void
8
- }
9
-
10
- export class JSEventDispatcher implements EventDispatcher {
11
- constructor(private rnInstance: RNInstance, private logger: RNGHLogger) {
12
- }
13
-
14
- public onGestureHandlerStateChange(event: GestureStateChangeEvent) {
15
- this.logger.info(`onGestureHandlerStateChange`)
16
- this.rnInstance.emitDeviceEvent("onGestureHandlerStateChange", event)
17
- }
18
-
19
- public onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent) {
20
- this.logger.info(`onGestureHandlerEvent`)
21
- this.rnInstance.emitDeviceEvent("onGestureHandlerEvent", event)
22
- }
23
- }
24
-
25
- export class AnimatedEventDispatcher implements EventDispatcher {
26
- constructor(private rnInstance: RNInstance, private logger: RNGHLogger, private viewTag: number) {
27
- }
28
-
29
- public onGestureHandlerStateChange(event: GestureStateChangeEvent) {
30
- this.logger.info(`onGestureHandlerStateChange`)
31
- this.rnInstance.emitDeviceEvent("onGestureHandlerStateChange", event)
32
- }
33
-
34
- public onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent) {
35
- this.logger.info(`onGestureHandlerEvent`)
36
- this.rnInstance.emitComponentEvent(this.viewTag, "onGestureHandlerEvent", event)
37
- }
1
+ import { RNInstance } from "@rnoh/react-native-openharmony/ts"
2
+ import { GestureStateChangeEvent, GestureUpdateEvent, GestureTouchEvent } from "./OutgoingEvent"
3
+ import { RNGHLogger } from './RNGHLogger'
4
+
5
+ export interface EventDispatcher {
6
+ onGestureHandlerStateChange(event: GestureStateChangeEvent): void
7
+ onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent): void
8
+ }
9
+
10
+ export class JSEventDispatcher implements EventDispatcher {
11
+ constructor(private rnInstance: RNInstance, private logger: RNGHLogger) {
12
+ }
13
+
14
+ public onGestureHandlerStateChange(event: GestureStateChangeEvent) {
15
+ this.logger.info(`onGestureHandlerStateChange`)
16
+ this.rnInstance.emitDeviceEvent("onGestureHandlerStateChange", event)
17
+ }
18
+
19
+ public onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent) {
20
+ this.logger.info(`onGestureHandlerEvent`)
21
+ this.rnInstance.emitDeviceEvent("onGestureHandlerEvent", event)
22
+ }
23
+ }
24
+
25
+ export class AnimatedEventDispatcher implements EventDispatcher {
26
+ constructor(private rnInstance: RNInstance, private logger: RNGHLogger, private viewTag: number) {
27
+ }
28
+
29
+ public onGestureHandlerStateChange(event: GestureStateChangeEvent) {
30
+ this.logger.info(`onGestureHandlerStateChange`)
31
+ this.rnInstance.emitDeviceEvent("onGestureHandlerStateChange", event)
32
+ }
33
+
34
+ public onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent) {
35
+ this.logger.info(`onGestureHandlerEvent`)
36
+ this.rnInstance.emitComponentEvent(this.viewTag, "onGestureHandlerEvent", event)
37
+ }
38
+ }
39
+
40
+ export class ReanimatedEventDispatcher implements EventDispatcher {
41
+ constructor(private rnInstance: RNInstance, private logger: RNGHLogger, private viewTag: number) {
42
+ }
43
+
44
+ public onGestureHandlerStateChange(event: GestureStateChangeEvent) {
45
+ this.logger.info(`onGestureHandlerStateChange`)
46
+ this.rnInstance.emitComponentEvent(this.viewTag, "onGestureHandlerStateChange", event)
47
+ }
48
+
49
+ public onGestureHandlerEvent(event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent) {
50
+ this.logger.info(`onGestureHandlerEvent`)
51
+ this.rnInstance.emitComponentEvent(this.viewTag, "onGestureHandlerEvent", event)
52
+ }
38
53
  }