@react-native-oh-tpl/react-native-gesture-handler 2.14.15 → 2.14.17-rc.0
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/DrawerLayout/index.ts +2 -2
- package/Swipeable/index.ts +2 -2
- package/harmony/gesture_handler.har +0 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +2 -2
- package/lib/typescript/components/GestureHandlerRootView.d.ts +6 -6
- package/lib/typescript/handlers/createHandler.d.ts +11 -11
- package/lib/typescript/index.d.ts +47 -47
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +14 -14
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +14 -14
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +6 -6
- package/package.json +83 -78
- package/src/RNGestureHandlerModule.ts +4 -4
- package/src/components/GestureHandlerRootView.tsx +23 -23
- package/src/handlers/createHandler.tsx +534 -534
- package/src/index.ts +172 -172
- package/src/specs/NativeRNGestureHandlerModule.ts +26 -26
- package/src/specs/RNGestureHandlerButtonNativeComponent.ts +18 -18
- package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -6
- package/harmony/gesture_handler/BuildProfile.ets +0 -17
- package/harmony/gesture_handler/build-profile.json5 +0 -12
- package/harmony/gesture_handler/hvigorfile.ts +0 -2
- package/harmony/gesture_handler/index.ets +0 -2
- package/harmony/gesture_handler/oh-package-lock.json5 +0 -18
- package/harmony/gesture_handler/oh-package.json5 +0 -12
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +0 -8
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +0 -12
- 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/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +0 -157
- package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +0 -21
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +0 -27
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +0 -245
- package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +0 -17
- package/harmony/gesture_handler/src/main/ets/core/CircularBuffer.ts +0 -42
- package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +0 -739
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +0 -344
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +0 -63
- package/harmony/gesture_handler/src/main/ets/core/IncomingEvent.ts +0 -78
- package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +0 -144
- package/harmony/gesture_handler/src/main/ets/core/LeastSquareSolver.ts +0 -182
- package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +0 -26
- package/harmony/gesture_handler/src/main/ets/core/OutgoingEvent.ts +0 -34
- package/harmony/gesture_handler/src/main/ets/core/OutgoingEventDispatcher.ts +0 -12
- package/harmony/gesture_handler/src/main/ets/core/PointerTracker.ts +0 -239
- package/harmony/gesture_handler/src/main/ets/core/RNGHError.ts +0 -5
- package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +0 -16
- package/harmony/gesture_handler/src/main/ets/core/State.ts +0 -47
- package/harmony/gesture_handler/src/main/ets/core/Vector2D.ts +0 -80
- package/harmony/gesture_handler/src/main/ets/core/VelocityTracker.ts +0 -106
- package/harmony/gesture_handler/src/main/ets/core/View.ts +0 -21
- package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +0 -7
- package/harmony/gesture_handler/src/main/ets/core/index.ts +0 -15
- package/harmony/gesture_handler/src/main/ets/detectors/ScaleGestureDetector.ts +0 -169
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +0 -219
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +0 -67
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +0 -139
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +0 -50
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +0 -124
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +0 -375
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +0 -174
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +0 -172
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +0 -216
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/detectors/RotationGestureDetector.ts +0 -167
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/index.ts +0 -1
- 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/GestureHandlerPackage.ts +0 -25
- package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +0 -107
- package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +0 -94
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +0 -196
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +0 -85
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewController.ts +0 -255
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +0 -19
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +0 -267
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -15
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +0 -25
- package/harmony/gesture_handler/src/main/ets/rnoh/types.ts +0 -25
- package/harmony/gesture_handler/src/main/module.json5 +0 -9
- package/harmony/gesture_handler/src/main/resources/base/element/color.json +0 -8
- package/harmony/gesture_handler/src/main/resources/base/element/string.json +0 -16
- package/harmony/gesture_handler/src/main/resources/base/media/icon.png +0 -0
- package/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json +0 -5
- package/harmony/gesture_handler/src/main/resources/en_US/element/string.json +0 -16
- package/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json +0 -16
- package/harmony/gesture_handler/ts.ts +0 -2
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
#pragma once
|
3
|
-
|
4
|
-
// This file was generated.
|
5
|
-
|
6
|
-
#include "RNOH/ArkTSTurboModule.h"
|
7
|
-
|
8
|
-
namespace rnoh {
|
9
|
-
|
10
|
-
class JSI_EXPORT RNGestureHandlerModule : public ArkTSTurboModule {
|
11
|
-
public:
|
12
|
-
RNGestureHandlerModule(const ArkTSTurboModule::Context ctx, const std::string name);
|
13
|
-
};
|
14
|
-
|
15
|
-
} // namespace rnoh
|
@@ -1,36 +0,0 @@
|
|
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 ¶meters)
|
32
|
-
: ConcreteComponentDescriptor(parameters) {}
|
33
|
-
};
|
34
|
-
|
35
|
-
} // namespace react
|
36
|
-
} // namespace facebook
|
@@ -1,25 +0,0 @@
|
|
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 createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
16
|
-
facebook::jsi::Object events(rt);
|
17
|
-
return events;
|
18
|
-
}
|
19
|
-
|
20
|
-
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
21
|
-
facebook::jsi::Object events(rt);
|
22
|
-
return events;
|
23
|
-
}
|
24
|
-
};
|
25
|
-
} // namespace rnoh
|
package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include "RnohReactNativeHarmonyGestureHandlerPackage.h"
|
3
|
-
#include "RNOH/RNInstanceCAPI.h"
|
4
|
-
#include "componentInstances/RNGestureHandlerButtonComponentInstance.h"
|
5
|
-
#include "componentInstances/RNGestureHandlerRootViewComponentInstance.h"
|
6
|
-
#include "RNOH/ArkTSTurboModule.h"
|
7
|
-
#include "RNGestureHandlerModule.h"
|
8
|
-
#include "RNGestureHandlerButtonComponentDescriptor.h"
|
9
|
-
#include "RNGestureHandlerRootViewComponentDescriptor.h"
|
10
|
-
#include "RNGestureHandlerButtonJSIBinder.h"
|
11
|
-
#include "RNGestureHandlerRootViewJSIBinder.h"
|
12
|
-
#include <glog/logging.h>
|
13
|
-
#include <react/renderer/debug/SystraceSection.h>
|
14
|
-
|
15
|
-
using namespace rnoh;
|
16
|
-
using namespace facebook;
|
17
|
-
|
18
|
-
class GestureHandlerTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
19
|
-
public:
|
20
|
-
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
21
|
-
if (name == "RNGestureHandlerModule") {
|
22
|
-
return std::make_shared<RNGestureHandlerModule>(ctx, name);
|
23
|
-
}
|
24
|
-
return nullptr;
|
25
|
-
};
|
26
|
-
};
|
27
|
-
|
28
|
-
|
29
|
-
class RNGHEventEmitRequestHandler : public EventEmitRequestHandler {
|
30
|
-
void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
|
31
|
-
facebook::react::SystraceSection s("RNGH::RNGHEventEmitRequestHandler::handleEvent");
|
32
|
-
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::ViewEventEmitter>(ctx.tag);
|
33
|
-
if (eventEmitter == nullptr) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
if (ctx.eventName == "onGestureHandlerEvent") {
|
37
|
-
eventEmitter->dispatchUniqueEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
38
|
-
} else if (ctx.eventName == "onGestureHandlerStateChange") {
|
39
|
-
eventEmitter->dispatchEvent("onGestureHandlerStateChange", ArkJS(ctx.env).getDynamic(ctx.payload));
|
40
|
-
}
|
41
|
-
}
|
42
|
-
};
|
43
|
-
|
44
|
-
class RNOHCorePackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
|
45
|
-
public:
|
46
|
-
using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
|
47
|
-
|
48
|
-
ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
|
49
|
-
if (ctx.componentName == "RNGestureHandlerButton") {
|
50
|
-
return std::make_shared<RNGestureHandlerButtonComponentInstance>(ctx);
|
51
|
-
} else if (ctx.componentName == "RNGestureHandlerRootView") {
|
52
|
-
return std::make_shared<RNGestureHandlerRootViewComponentInstance>(ctx);
|
53
|
-
}
|
54
|
-
return nullptr;
|
55
|
-
}
|
56
|
-
};
|
57
|
-
|
58
|
-
std::unique_ptr<TurboModuleFactoryDelegate> RnohReactNativeHarmonyGestureHandlerPackage::createTurboModuleFactoryDelegate() {
|
59
|
-
return std::make_unique<GestureHandlerTurboModuleFactoryDelegate>();
|
60
|
-
}
|
61
|
-
|
62
|
-
std::vector<react::ComponentDescriptorProvider> RnohReactNativeHarmonyGestureHandlerPackage::createComponentDescriptorProviders() {
|
63
|
-
return {
|
64
|
-
react::concreteComponentDescriptorProvider<react::RNGestureHandlerRootViewComponentDescriptor>(),
|
65
|
-
react::concreteComponentDescriptorProvider<react::RNGestureHandlerButtonComponentDescriptor>(),
|
66
|
-
};
|
67
|
-
}
|
68
|
-
|
69
|
-
ComponentJSIBinderByString RnohReactNativeHarmonyGestureHandlerPackage::createComponentJSIBinderByName() {
|
70
|
-
return {
|
71
|
-
{"RNGestureHandlerButton", std::make_shared<RNGestureHandlerButtonJSIBinder>()},
|
72
|
-
{"RNGestureHandlerRootView", std::make_shared<RNGestureHandlerRootViewJSIBinder>()},
|
73
|
-
};
|
74
|
-
};
|
75
|
-
|
76
|
-
EventEmitRequestHandlers RnohReactNativeHarmonyGestureHandlerPackage::createEventEmitRequestHandlers() {
|
77
|
-
return {
|
78
|
-
std::make_shared<RNGHEventEmitRequestHandler>(),
|
79
|
-
};
|
80
|
-
}
|
81
|
-
|
82
|
-
ComponentInstanceFactoryDelegate::Shared
|
83
|
-
RnohReactNativeHarmonyGestureHandlerPackage::createComponentInstanceFactoryDelegate() {
|
84
|
-
return std::make_shared<RNOHCorePackageComponentInstanceFactoryDelegate>();
|
85
|
-
}
|
86
|
-
|
87
|
-
class ScrollLockerArkTSMessageHandler : public ArkTSMessageHandler {
|
88
|
-
public:
|
89
|
-
void handleArkTSMessage(const Context &ctx) override {
|
90
|
-
facebook::react::SystraceSection s("RNGH::ScrollLockerArkTSMessageHandler::handleArkTSMessage");
|
91
|
-
if (ctx.messageName == "RNGH::SET_NATIVE_RESPONDERS_BLOCK") {
|
92
|
-
auto targetComponentInstanceTag = ctx.messagePayload["targetTag"].asDouble();
|
93
|
-
auto shouldBlock = ctx.messagePayload["shouldBlock"].asBool();
|
94
|
-
auto rnInstance = ctx.rnInstance.lock();
|
95
|
-
if (rnInstance != nullptr) {
|
96
|
-
auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
|
97
|
-
if (rnInstanceCAPI != nullptr) {
|
98
|
-
|
99
|
-
std::vector<ComponentInstance::Shared> ancestors;
|
100
|
-
auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(targetComponentInstanceTag);
|
101
|
-
while (tmpComponentInstance != nullptr) {
|
102
|
-
ancestors.push_back(tmpComponentInstance);
|
103
|
-
tmpComponentInstance = tmpComponentInstance->getParent().lock();
|
104
|
-
}
|
105
|
-
if (ancestors.size() == 0) {
|
106
|
-
return;
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* Ensure consistent behavior with Android by not blocking
|
110
|
-
* scrolls above the GestureHandlerRootView handling the
|
111
|
-
* touch. If there are multiple nested
|
112
|
-
* GestureHandlerRootViews, the one nearest to the actual
|
113
|
-
* root will handle the touch.
|
114
|
-
*/
|
115
|
-
auto isChangingResponderStatusAllowed = false;
|
116
|
-
for (size_t i = ancestors.size() - 1; i > 0; i--) {
|
117
|
-
auto ancestor = ancestors[i];
|
118
|
-
if (!isChangingResponderStatusAllowed) {
|
119
|
-
auto rootView =
|
120
|
-
std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor);
|
121
|
-
if (rootView != nullptr) {
|
122
|
-
isChangingResponderStatusAllowed = true;
|
123
|
-
}
|
124
|
-
} else {
|
125
|
-
ancestor->setNativeResponderBlocked(shouldBlock, "RNGH");
|
126
|
-
}
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}
|
130
|
-
} else if (ctx.messageName == "RNGH::ROOT_VIEW_IS_HANDLING_TOUCHES") {
|
131
|
-
auto descendantViewTag = ctx.messagePayload["descendantViewTag"].asDouble();
|
132
|
-
auto isHandlingTouches = ctx.messagePayload["isHandlingTouches"].asBool();
|
133
|
-
auto rnInstance = ctx.rnInstance.lock();
|
134
|
-
if (rnInstance != nullptr) {
|
135
|
-
auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
|
136
|
-
if (rnInstanceCAPI != nullptr) {
|
137
|
-
auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(descendantViewTag);
|
138
|
-
while (tmpComponentInstance != nullptr) {
|
139
|
-
tmpComponentInstance = tmpComponentInstance->getParent().lock();
|
140
|
-
if (tmpComponentInstance) {
|
141
|
-
auto rnghRootViewComponentInstance =
|
142
|
-
std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(
|
143
|
-
tmpComponentInstance);
|
144
|
-
if (rnghRootViewComponentInstance) {
|
145
|
-
rnghRootViewComponentInstance->setIsHandlingTouches(isHandlingTouches);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
};
|
153
|
-
};
|
154
|
-
|
155
|
-
std::vector<ArkTSMessageHandler::Shared> RnohReactNativeHarmonyGestureHandlerPackage::createArkTSMessageHandlers() {
|
156
|
-
return {std::make_shared<ScrollLockerArkTSMessageHandler>()};
|
157
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include "RNOH/Package.h"
|
3
|
-
|
4
|
-
namespace rnoh {
|
5
|
-
class RnohReactNativeHarmonyGestureHandlerPackage : public Package {
|
6
|
-
public:
|
7
|
-
RnohReactNativeHarmonyGestureHandlerPackage(Package::Context ctx) : Package(ctx) {}
|
8
|
-
|
9
|
-
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
|
10
|
-
|
11
|
-
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override;
|
12
|
-
|
13
|
-
ComponentJSIBinderByString createComponentJSIBinderByName() override;
|
14
|
-
|
15
|
-
EventEmitRequestHandlers createEventEmitRequestHandlers();
|
16
|
-
|
17
|
-
ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate();
|
18
|
-
|
19
|
-
std::vector<ArkTSMessageHandler::Shared> createArkTSMessageHandlers() override;
|
20
|
-
};
|
21
|
-
} // namespace rnoh
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#import "RNOH/CppComponentInstance.h"
|
3
|
-
#import "RNOH/arkui/StackNode.h"
|
4
|
-
#import "../RNGestureHandlerButtonComponentDescriptor.h"
|
5
|
-
|
6
|
-
namespace rnoh {
|
7
|
-
class RNGestureHandlerButtonComponentInstance
|
8
|
-
: public CppComponentInstance<facebook::react::RNGestureHandlerButtonShadowNode> {
|
9
|
-
private:
|
10
|
-
StackNode m_stackNode;
|
11
|
-
|
12
|
-
public:
|
13
|
-
RNGestureHandlerButtonComponentInstance(Context context) : CppComponentInstance(std::move(context)){};
|
14
|
-
|
15
|
-
StackNode &getLocalRootArkUINode() override { return m_stackNode; };
|
16
|
-
|
17
|
-
void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
|
18
|
-
CppComponentInstance::onChildInserted(childComponentInstance, index);
|
19
|
-
m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
|
20
|
-
};
|
21
|
-
|
22
|
-
void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
|
23
|
-
CppComponentInstance::onChildRemoved(childComponentInstance);
|
24
|
-
m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
|
25
|
-
};
|
26
|
-
};
|
27
|
-
} // namespace rnoh
|
@@ -1,245 +0,0 @@
|
|
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 "RNOH/RNInstanceCAPI.h"
|
7
|
-
#import "../RNGestureHandlerRootViewComponentDescriptor.h"
|
8
|
-
#import "RNGestureHandlerButtonComponentInstance.h"
|
9
|
-
|
10
|
-
namespace rnoh {
|
11
|
-
class RNGestureHandlerRootViewComponentInstance
|
12
|
-
: public CppComponentInstance<facebook::react::RNGestureHandlerRootViewShadowNode>,
|
13
|
-
public TouchEventHandler {
|
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;
|
42
|
-
}
|
43
|
-
|
44
|
-
private:
|
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
|
-
};
|
56
|
-
|
57
|
-
public:
|
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
|
-
};
|
67
|
-
|
68
|
-
~RNGestureHandlerRootViewComponentInstance() override {
|
69
|
-
NativeNodeApi::getInstance()->unregisterNodeEvent(m_stackNode.getArkUINodeHandle(), NODE_TOUCH_EVENT);
|
70
|
-
ArkUINodeRegistry::getInstance().unregisterTouchHandler(&m_stackNode);
|
71
|
-
}
|
72
|
-
|
73
|
-
StackNode &getLocalRootArkUINode() override { return m_stackNode; };
|
74
|
-
|
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
|
-
}
|
86
|
-
|
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
|
-
}
|
96
|
-
|
97
|
-
folly::dynamic payload = folly::dynamic::object;
|
98
|
-
folly::dynamic touchPoints = folly::dynamic::array();
|
99
|
-
std::vector<TouchableView> touchableViews;
|
100
|
-
|
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
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
void setIsHandlingTouches(bool isHandlingTouches) { m_isHandlingTouches = isHandlingTouches; }
|
136
|
-
|
137
|
-
bool isHandlingTouches() const override { return m_isHandlingTouches; }
|
138
|
-
|
139
|
-
private:
|
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;
|
180
|
-
}
|
181
|
-
|
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;
|
195
|
-
}
|
196
|
-
|
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
|
-
}
|
204
|
-
|
205
|
-
protected:
|
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
|
-
};
|
210
|
-
|
211
|
-
void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
|
212
|
-
CppComponentInstance::onChildRemoved(childComponentInstance);
|
213
|
-
m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
|
214
|
-
};
|
215
|
-
|
216
|
-
private:
|
217
|
-
Surface::Weak m_surface;
|
218
|
-
|
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;
|
243
|
-
}
|
244
|
-
};
|
245
|
-
} // namespace rnoh
|
@@ -1,17 +0,0 @@
|
|
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
|
-
}
|
@@ -1,42 +0,0 @@
|
|
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
|
-
}
|