@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.
- package/harmony/gesture_handler/BuildProfile.ets +6 -0
- package/harmony/gesture_handler/build-profile.json5 +18 -7
- package/harmony/gesture_handler/hvigorfile.ts +2 -2
- package/harmony/gesture_handler/index.ets +3 -3
- package/harmony/gesture_handler/oh-package-lock.json5 +18 -0
- package/harmony/gesture_handler/oh-package.json5 +12 -11
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +103 -34
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +21 -15
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +36 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentInstance.h +27 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +32 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +22 -17
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +15 -12
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerPackage.h +72 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +36 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentInstance.h +123 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
- package/harmony/gesture_handler/src/main/ets/CircularBuffer.ts +42 -42
- package/harmony/gesture_handler/src/main/ets/Event.ts +67 -67
- package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +52 -37
- package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
- package/harmony/gesture_handler/src/main/ets/{GestureHandlerArkUIAdapter.ets → GestureHandlerArkUIAdapter.ts} +202 -201
- package/harmony/gesture_handler/src/main/ets/GestureHandlerFactory.ts +44 -44
- package/harmony/gesture_handler/src/main/ets/GestureHandlerOrchestrator.ts +280 -280
- package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +22 -22
- package/harmony/gesture_handler/src/main/ets/GestureHandlerRegistry.ts +27 -27
- package/harmony/gesture_handler/src/main/ets/InteractionManager.ts +108 -108
- package/harmony/gesture_handler/src/main/ets/LeastSquareSolver.ts +182 -182
- package/harmony/gesture_handler/src/main/ets/NativeViewGestureHandler.ts +114 -114
- package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +33 -33
- package/harmony/gesture_handler/src/main/ets/PanGestureHandler.ts +327 -327
- package/harmony/gesture_handler/src/main/ets/PointerTracker.ts +239 -239
- package/harmony/gesture_handler/src/main/ets/RNGHError.ts +4 -4
- package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +47 -28
- package/harmony/gesture_handler/src/main/ets/{RNGHRootTouchHandler.ets → RNGHRootTouchHandlerArkTS.ts} +59 -57
- package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandlerCAPI.ts +87 -0
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +37 -36
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +183 -125
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +52 -55
- package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +23 -11
- package/harmony/gesture_handler/src/main/ets/State.ts +46 -46
- package/harmony/gesture_handler/src/main/ets/TapGestureHandler.ts +205 -205
- package/harmony/gesture_handler/src/main/ets/Vector2D.ts +36 -36
- package/harmony/gesture_handler/src/main/ets/VelocityTracker.ts +98 -98
- package/harmony/gesture_handler/src/main/ets/View.ts +70 -70
- package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +42 -42
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerButton.ts +140 -0
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +25 -0
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerRootView.ts +101 -0
- package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +3 -0
- package/harmony/gesture_handler/src/main/ets/pages/Index.ets +16 -16
- package/harmony/gesture_handler/src/main/ets/types.ts +25 -0
- package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
- package/harmony/gesture_handler/src/main/module.json5 +7 -7
- package/harmony/gesture_handler/src/main/resources/base/element/color.json +7 -7
- package/harmony/gesture_handler/src/main/resources/base/element/string.json +15 -15
- package/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/gesture_handler/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/gesture_handler/ts.ts +2 -1
- package/harmony/gesture_handler.har +0 -0
- package/lib/commonjs/RNGestureHandlerModule.js +6 -3
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js +5 -13
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +31 -28
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/index.js +42 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +10 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js +11 -0
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +3 -2
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js +3 -11
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/handlers/createHandler.js +20 -19
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/index.js +6 -14
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js +3 -0
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js +3 -0
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +2 -6
- package/lib/typescript/RNGestureHandlerModule.d.ts.map +1 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +6 -6
- package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
- package/lib/typescript/handlers/createHandler.d.ts +11 -11
- package/lib/typescript/handlers/createHandler.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +9 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +15 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +15 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +7 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -0
- package/package.json +66 -70
- package/src/RNGestureHandlerModule.ts +5 -6
- package/src/components/GestureHandlerRootView.tsx +23 -34
- package/src/handlers/createHandler.tsx +534 -535
- package/src/index.ts +172 -172
- package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
- package/src/specs/RNGestureHandlerButtonNativeComponent.ts +18 -0
- package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -0
- package/README.md +0 -1
- package/lib/commonjs/components/GestureButtons.js +0 -186
- package/lib/commonjs/components/GestureButtons.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerButton.js +0 -9
- package/lib/commonjs/components/GestureHandlerButton.js.map +0 -1
- package/lib/commonjs/components/RNGestureHandlerButton.js +0 -23
- package/lib/commonjs/components/RNGestureHandlerButton.js.map +0 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +0 -247
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +0 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +0 -58
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +0 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +0 -18
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +0 -1
- package/lib/commonjs/components/touchables/index.js +0 -21
- package/lib/commonjs/components/touchables/index.js.map +0 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +0 -19
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +0 -103
- package/lib/commonjs/handlers/PanGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/TapGestureHandler.js +0 -22
- package/lib/commonjs/handlers/TapGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +0 -64
- package/lib/commonjs/handlers/createNativeWrapper.js.map +0 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -22
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +0 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -554
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/commonjs/init.js +0 -24
- package/lib/commonjs/init.js.map +0 -1
- package/lib/module/components/GestureButtons.js +0 -168
- package/lib/module/components/GestureButtons.js.map +0 -1
- package/lib/module/components/GestureHandlerButton.js +0 -3
- package/lib/module/components/GestureHandlerButton.js.map +0 -1
- package/lib/module/components/RNGestureHandlerButton.js +0 -17
- package/lib/module/components/RNGestureHandlerButton.js.map +0 -1
- package/lib/module/components/touchables/GenericTouchable.js +0 -238
- package/lib/module/components/touchables/GenericTouchable.js.map +0 -1
- package/lib/module/components/touchables/TouchableOpacity.js +0 -49
- package/lib/module/components/touchables/TouchableOpacity.js.map +0 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +0 -9
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +0 -1
- package/lib/module/components/touchables/index.js +0 -8
- package/lib/module/components/touchables/index.js.map +0 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +0 -12
- package/lib/module/handlers/NativeViewGestureHandler.js.map +0 -1
- package/lib/module/handlers/PanGestureHandler.js +0 -92
- package/lib/module/handlers/PanGestureHandler.js.map +0 -1
- package/lib/module/handlers/TapGestureHandler.js +0 -14
- package/lib/module/handlers/TapGestureHandler.js.map +0 -1
- package/lib/module/handlers/createNativeWrapper.js +0 -57
- package/lib/module/handlers/createNativeWrapper.js.map +0 -1
- package/lib/module/handlers/gestureHandlerCommon.js +0 -15
- package/lib/module/handlers/gestureHandlerCommon.js.map +0 -1
- package/lib/module/handlers/gestures/GestureDetector.js +0 -543
- package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/module/init.js +0 -17
- package/lib/module/init.js.map +0 -1
- package/lib/typescript/components/GestureButtons.d.ts +0 -122
- package/lib/typescript/components/GestureButtons.d.ts.map +0 -1
- package/lib/typescript/components/GestureHandlerButton.d.ts +0 -5
- package/lib/typescript/components/GestureHandlerButton.d.ts.map +0 -1
- package/lib/typescript/components/RNGestureHandlerButton.d.ts +0 -2
- package/lib/typescript/components/RNGestureHandlerButton.d.ts.map +0 -1
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -68
- package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +0 -1
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -26
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts.map +0 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -8
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts.map +0 -1
- package/lib/typescript/components/touchables/index.d.ts +0 -4
- package/lib/typescript/components/touchables/index.d.ts.map +0 -1
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -29
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -140
- package/lib/typescript/handlers/PanGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -58
- package/lib/typescript/handlers/TapGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -4
- package/lib/typescript/handlers/createNativeWrapper.d.ts.map +0 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -2
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts.map +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -24
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts.map +0 -1
- package/lib/typescript/init.d.ts +0 -3
- package/lib/typescript/init.d.ts.map +0 -1
- package/src/components/GestureButtons.tsx +0 -334
- package/src/components/GestureHandlerButton.tsx +0 -5
- package/src/components/RNGestureHandlerButton.tsx +0 -23
- package/src/components/touchables/GenericTouchable.tsx +0 -301
- package/src/components/touchables/TouchableOpacity.tsx +0 -76
- package/src/components/touchables/TouchableWithoutFeedback.tsx +0 -14
- package/src/components/touchables/index.ts +0 -7
- package/src/handlers/NativeViewGestureHandler.ts +0 -55
- package/src/handlers/PanGestureHandler.ts +0 -327
- package/src/handlers/TapGestureHandler.ts +0 -95
- package/src/handlers/createNativeWrapper.tsx +0 -81
- package/src/handlers/gestureHandlerCommon.ts +0 -15
- package/src/handlers/gestures/GestureDetector.tsx +0 -823
- package/src/init.ts +0 -18
@@ -1,58 +1,60 @@
|
|
1
|
-
import { Tag } from "rnoh"
|
2
|
-
import { GestureHandlerRegistry } from "./GestureHandlerRegistry"
|
3
|
-
import { GestureHandlerArkUIAdapter } from "./GestureHandlerArkUIAdapter"
|
4
|
-
import { ViewRegistry } from "./ViewRegistry"
|
5
|
-
import { RNGHLogger } from './RNGHLogger'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
private
|
11
|
-
private
|
12
|
-
private
|
13
|
-
private
|
14
|
-
private
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
this.
|
19
|
-
this.
|
20
|
-
this.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if (!this.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
1
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
2
|
+
import { GestureHandlerRegistry } from "./GestureHandlerRegistry"
|
3
|
+
import { GestureHandlerArkUIAdapter } from "./GestureHandlerArkUIAdapter"
|
4
|
+
import { ViewRegistry } from "./ViewRegistry"
|
5
|
+
import { RNGHLogger } from './RNGHLogger'
|
6
|
+
import { TouchEvent, TouchType } from "./types"
|
7
|
+
|
8
|
+
|
9
|
+
export class RNGHRootTouchHandlerArkTS {
|
10
|
+
private adapterByViewTag: Map<number, GestureHandlerArkUIAdapter> = new Map() // TODO: remove an adapter when a view or gesture handler is removed
|
11
|
+
private activeViewTags: number[] = []
|
12
|
+
private viewRegistry: ViewRegistry
|
13
|
+
private gestureHandlerRegistry: GestureHandlerRegistry
|
14
|
+
private logger: RNGHLogger
|
15
|
+
private rootTag: Tag
|
16
|
+
|
17
|
+
constructor(rootTag: Tag, viewRegistry: ViewRegistry, gestureHandlerRegistry: GestureHandlerRegistry, logger: RNGHLogger) {
|
18
|
+
this.rootTag = rootTag
|
19
|
+
this.viewRegistry = viewRegistry
|
20
|
+
this.gestureHandlerRegistry = gestureHandlerRegistry
|
21
|
+
this.logger = logger
|
22
|
+
}
|
23
|
+
|
24
|
+
public handleTouch(touchEvent: any) {
|
25
|
+
const e = touchEvent as TouchEvent
|
26
|
+
if (e.type === TouchType.Down) {
|
27
|
+
this.activeViewTags = []
|
28
|
+
}
|
29
|
+
for (const changedTouch of e.changedTouches) {
|
30
|
+
const views = this.viewRegistry.getTouchableViewsAt({
|
31
|
+
x: changedTouch.windowX,
|
32
|
+
y: changedTouch.windowY
|
33
|
+
}, this.rootTag)
|
34
|
+
for (const view of views) {
|
35
|
+
for (const handler of this.gestureHandlerRegistry.getGestureHandlersByViewTag(view.getTag())) {
|
36
|
+
this.logger.info(`Found GestureHandler ${handler.getTag()} for view ${view.getTag()}`)
|
37
|
+
if (!this.adapterByViewTag.has(view.getTag()))
|
38
|
+
this.adapterByViewTag.set(view.getTag(), new GestureHandlerArkUIAdapter(handler, view, this.logger.cloneWithPrefix("ArkUIAdapter")))
|
39
|
+
if (!this.activeViewTags.includes(view.getTag())) {
|
40
|
+
const adapter = this.adapterByViewTag.get(view.getTag())
|
41
|
+
if (adapter) {
|
42
|
+
adapter.handleTouch(e)
|
43
|
+
} else {
|
44
|
+
console.warn("RNGH: Couldn't find adapter")
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (e.type === TouchType.Down) {
|
48
|
+
this.activeViewTags.push(view.getTag())
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
for (const viewTag of this.activeViewTags) {
|
53
|
+
const adapter = this.adapterByViewTag.get(viewTag)
|
54
|
+
if (adapter) {
|
55
|
+
adapter.handleTouch(e)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
58
60
|
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { RNGHRootTouchHandlerArkTS } from "./RNGHRootTouchHandlerArkTS"
|
2
|
+
import { TouchEvent as TouchEventArkTS, TouchType, TouchObject } from "./types"
|
3
|
+
import { RNGHLogger } from "./RNGHLogger"
|
4
|
+
|
5
|
+
type RawTouchPoint = {
|
6
|
+
contactAreaHeight: number
|
7
|
+
contactAreaWidth: number
|
8
|
+
id: number
|
9
|
+
nodeX: number
|
10
|
+
nodeY: number
|
11
|
+
pressedTime: number
|
12
|
+
pressure: number
|
13
|
+
rawX: number
|
14
|
+
rawY: number
|
15
|
+
screenX: number
|
16
|
+
screenY: number
|
17
|
+
tiltX: number
|
18
|
+
tiltY: number
|
19
|
+
toolHeight: number
|
20
|
+
toolType: number
|
21
|
+
toolWidth: number
|
22
|
+
toolX: number
|
23
|
+
toolY: number
|
24
|
+
windowX: number
|
25
|
+
windowY: number
|
26
|
+
}
|
27
|
+
|
28
|
+
export type RawTouchEvent = {
|
29
|
+
action: number,
|
30
|
+
actionTouch: RawTouchPoint,
|
31
|
+
touchPoints: RawTouchPoint[],
|
32
|
+
sourceType: number,
|
33
|
+
timestamp: number
|
34
|
+
}
|
35
|
+
|
36
|
+
class TouchEvent {
|
37
|
+
constructor(private raw: RawTouchEvent) {
|
38
|
+
}
|
39
|
+
|
40
|
+
asTouchEventArkTS(): TouchEventArkTS {
|
41
|
+
const touchType = this.touchTypeFromAction(this.raw.action)
|
42
|
+
return {
|
43
|
+
type: this.touchTypeFromAction(this.raw.action),
|
44
|
+
touches: this.raw.touchPoints.map(tp => this.touchObjectFromTouchPoint(tp, touchType)),
|
45
|
+
changedTouches: [this.touchObjectFromTouchPoint(this.raw.actionTouch, touchType)],
|
46
|
+
timestamp: this.raw.timestamp
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
private touchTypeFromAction(action: number): TouchType {
|
51
|
+
switch (action) {
|
52
|
+
case 1:
|
53
|
+
return TouchType.Down
|
54
|
+
case 2:
|
55
|
+
return TouchType.Move
|
56
|
+
case 3:
|
57
|
+
return TouchType.Up
|
58
|
+
default:
|
59
|
+
return TouchType.Cancel
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
private touchObjectFromTouchPoint(touchPoint: RawTouchPoint, touchType: TouchType): TouchObject {
|
64
|
+
return {
|
65
|
+
id: touchPoint.id,
|
66
|
+
windowX: touchPoint.windowX,
|
67
|
+
windowY: touchPoint.windowY,
|
68
|
+
x: touchPoint.windowX,
|
69
|
+
y: touchPoint.windowY,
|
70
|
+
type: touchType
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
export class RNGHRootTouchHandlerCAPI {
|
76
|
+
private logger: RNGHLogger
|
77
|
+
|
78
|
+
constructor(logger: RNGHLogger, private touchHandlerArkTS: RNGHRootTouchHandlerArkTS) {
|
79
|
+
this.logger = logger.cloneWithPrefix("RNGHRootTouchHandlerCAPI")
|
80
|
+
}
|
81
|
+
|
82
|
+
handleTouch(rawTouchEvent: RawTouchEvent) {
|
83
|
+
this.logger.cloneWithPrefix("handleTouch").debug(JSON.stringify(rawTouchEvent))
|
84
|
+
this.touchHandlerArkTS.handleTouch(new TouchEvent(rawTouchEvent).asTouchEventArkTS())
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
@@ -1,37 +1,38 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
public
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
this.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
import { RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "@rnoh/react-native-openharmony"
|
2
|
+
import { RNGestureHandlerButton as RNC } from "./namespace/RNGestureHandlerButton"
|
3
|
+
|
4
|
+
export type RNGestureHandlerButtonDescriptor = RNC.Descriptor
|
5
|
+
|
6
|
+
@Component
|
7
|
+
export struct RNGestureHandlerButton {
|
8
|
+
static readonly NAME = RNC.NAME
|
9
|
+
public ctx!: RNOHContext
|
10
|
+
public tag: number = -1
|
11
|
+
@BuilderParam public buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
12
|
+
|
13
|
+
@State private descriptor: RNGestureHandlerButtonDescriptor = {} as RNGestureHandlerButtonDescriptor
|
14
|
+
private unsubscribes: (() => void)[] = []
|
15
|
+
|
16
|
+
aboutToAppear() {
|
17
|
+
this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerButtonDescriptor>(this.tag))
|
18
|
+
this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
|
19
|
+
this.handleDescriptorChange(d as RNGestureHandlerButtonDescriptor)
|
20
|
+
}))
|
21
|
+
}
|
22
|
+
|
23
|
+
aboutToDisappear() {
|
24
|
+
this.unsubscribes.forEach(unsubscribe => unsubscribe())
|
25
|
+
}
|
26
|
+
|
27
|
+
handleDescriptorChange(newDescriptor: RNGestureHandlerButtonDescriptor) {
|
28
|
+
this.descriptor = newDescriptor
|
29
|
+
}
|
30
|
+
|
31
|
+
build() {
|
32
|
+
RNViewBase({ ctx: this.ctx, tag: this.tag }) {
|
33
|
+
ForEach(this.descriptor.childrenTags, (childrenTag: Tag) => {
|
34
|
+
RNComponentFactory({ ctx: this.ctx, tag: childrenTag, buildCustomComponent: this.buildCustomComponent })
|
35
|
+
})
|
36
|
+
}
|
37
|
+
}
|
37
38
|
}
|
@@ -1,125 +1,183 @@
|
|
1
|
-
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
) {
|
55
|
-
const
|
56
|
-
if (
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
this.
|
66
|
-
this.
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
public
|
86
|
-
handlerTag: number,
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
public
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
}
|
125
|
-
|
1
|
+
import { TurboModule, TurboModuleContext, Tag } from '@rnoh/react-native-openharmony/ts';
|
2
|
+
// import { TM } from "rnoh/generated/ts"
|
3
|
+
import { GestureHandlerRegistry } from './GestureHandlerRegistry';
|
4
|
+
import { GestureHandlerFactory } from "./GestureHandlerFactory"
|
5
|
+
import { ViewRegistry } from './ViewRegistry';
|
6
|
+
import { RNGHLogger, StandardRNGHLogger, FakeRNGHLogger } from './RNGHLogger';
|
7
|
+
import {
|
8
|
+
EventDispatcher,
|
9
|
+
JSEventDispatcher,
|
10
|
+
AnimatedEventDispatcher,
|
11
|
+
ReanimatedEventDispatcher
|
12
|
+
} from './EventDispatcher'
|
13
|
+
import { RNOHScrollLockerArkTS, RNOHScrollLockerCAPI } from "./RNOHScrollLocker"
|
14
|
+
import { State } from './State';
|
15
|
+
import { RNGHRootTouchHandlerCAPI, RawTouchEvent } from "./RNGHRootTouchHandlerCAPI"
|
16
|
+
import { RNGHRootTouchHandlerArkTS } from './RNGHRootTouchHandlerArkTS';
|
17
|
+
|
18
|
+
export enum ActionType {
|
19
|
+
REANIMATED_WORKLET = 1,
|
20
|
+
NATIVE_ANIMATED_EVENT = 2,
|
21
|
+
JS_FUNCTION_OLD_API = 3,
|
22
|
+
JS_FUNCTION_NEW_API = 4,
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
export class RNGestureHandlerModule extends TurboModule {
|
27
|
+
// implements TM.RNGestureHandlerModule.Spec {
|
28
|
+
static NAME = "RNGestureHandlerModule"
|
29
|
+
|
30
|
+
private gestureHandlerRegistry = new GestureHandlerRegistry()
|
31
|
+
private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
|
32
|
+
private viewRegistry: ViewRegistry | undefined = undefined
|
33
|
+
private logger: RNGHLogger
|
34
|
+
private touchHandlerByRootTag = new Map<Tag, RNGHRootTouchHandlerCAPI>()
|
35
|
+
|
36
|
+
constructor(ctx: TurboModuleContext) {
|
37
|
+
super(ctx)
|
38
|
+
const debug = false
|
39
|
+
this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
|
40
|
+
if (this.ctx.rnInstance.getArchitecture() === "C_API") {
|
41
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: any) => {
|
42
|
+
this.onTouch(e)
|
43
|
+
})
|
44
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::ROOT_CREATED", (rootTag: any) => {
|
45
|
+
this.onGHRootCreated(rootTag)
|
46
|
+
})
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
private onGHRootCreated(rootTag: Tag) {
|
51
|
+
this.touchHandlerByRootTag.set(rootTag, new RNGHRootTouchHandlerCAPI(this.logger, new RNGHRootTouchHandlerArkTS(rootTag, this.viewRegistry, this.gestureHandlerRegistry, this.logger)));
|
52
|
+
}
|
53
|
+
|
54
|
+
private onTouch(e: RawTouchEvent & { rootTag: Tag }) {
|
55
|
+
const touchHandler = this.touchHandlerByRootTag.get(e.rootTag)
|
56
|
+
if (touchHandler) {
|
57
|
+
touchHandler.handleTouch(e);
|
58
|
+
} else {
|
59
|
+
this.logger.info(`Couldn't find touch handler for root tag: ${e.rootTag}`)
|
60
|
+
}
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
public install() {
|
65
|
+
this.viewRegistry = new ViewRegistry(this.ctx.descriptorRegistry, this.ctx.componentManagerRegistry)
|
66
|
+
const scrollLocker = this.ctx.rnInstance.getArchitecture() === "ARK_TS" ? new RNOHScrollLockerArkTS(this.ctx.rnInstance) : new RNOHScrollLockerCAPI(this.ctx.rnInstance);
|
67
|
+
this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, scrollLocker)
|
68
|
+
return true
|
69
|
+
}
|
70
|
+
|
71
|
+
public createGestureHandler(
|
72
|
+
handlerName: string,
|
73
|
+
handlerTag: number,
|
74
|
+
config: Readonly<Record<string, unknown>>
|
75
|
+
) {
|
76
|
+
if (!this.gestureHandlerFactory) {
|
77
|
+
this.ctx.logger.error("Trying to create a gesture handler before creating gesture handler factory")
|
78
|
+
return
|
79
|
+
}
|
80
|
+
const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag)
|
81
|
+
this.gestureHandlerRegistry.addGestureHandler(gestureHandler)
|
82
|
+
gestureHandler.updateGestureConfig(config)
|
83
|
+
}
|
84
|
+
|
85
|
+
public attachGestureHandler(
|
86
|
+
handlerTag: number,
|
87
|
+
viewTag: number,
|
88
|
+
actionType: ActionType
|
89
|
+
) {
|
90
|
+
const eventDispatcher = this.createEventDispatcher(actionType, viewTag)
|
91
|
+
if (!eventDispatcher) {
|
92
|
+
this.ctx.logger.error("RNGH: Couldn't create EventDispatcher")
|
93
|
+
return
|
94
|
+
}
|
95
|
+
const view = this.viewRegistry.getViewByTag(viewTag)
|
96
|
+
if (!view) {
|
97
|
+
this.ctx.logger.error(`RNGH: Couldn't attachGestureHandler to view ${viewTag}`)
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view)
|
101
|
+
this.gestureHandlerRegistry
|
102
|
+
.getGestureHandlerByHandlerTag(handlerTag)
|
103
|
+
.setEventDispatcher(eventDispatcher)
|
104
|
+
}
|
105
|
+
|
106
|
+
private createEventDispatcher(actionType: ActionType, viewTag: number): EventDispatcher | null {
|
107
|
+
switch (actionType) {
|
108
|
+
case ActionType.REANIMATED_WORKLET:
|
109
|
+
return new ReanimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('ReanimatedEventDispatcher'), viewTag)
|
110
|
+
case ActionType.NATIVE_ANIMATED_EVENT:
|
111
|
+
return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
|
112
|
+
case ActionType.JS_FUNCTION_OLD_API:
|
113
|
+
case ActionType.JS_FUNCTION_NEW_API:
|
114
|
+
return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
public updateGestureHandler(
|
119
|
+
handlerTag: number,
|
120
|
+
newConfig: Readonly<Record<string, unknown>>
|
121
|
+
) {
|
122
|
+
const gestureHandler = this.gestureHandlerRegistry.getGestureHandlerByHandlerTag(handlerTag)
|
123
|
+
gestureHandler.updateGestureConfig(newConfig)
|
124
|
+
}
|
125
|
+
|
126
|
+
public dropGestureHandler(handlerTag: number) {
|
127
|
+
this.warn("dropGestureHandler is not implemented")
|
128
|
+
}
|
129
|
+
|
130
|
+
public handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
|
131
|
+
this.warn("handleSetJSResponder is not implemented")
|
132
|
+
}
|
133
|
+
|
134
|
+
public handleClearJSResponder() {
|
135
|
+
this.warn("handleClearJSResponder is not implemented")
|
136
|
+
}
|
137
|
+
|
138
|
+
public flushOperations() {
|
139
|
+
this.warn("flushOperations is not implemented")
|
140
|
+
}
|
141
|
+
|
142
|
+
// -------------------------------------------------------------------------------------------------------------------
|
143
|
+
protected warn(message: string) {
|
144
|
+
this.ctx.logger.warn("RNGH: " + message)
|
145
|
+
}
|
146
|
+
|
147
|
+
public getGestureHandlerRegistry() {
|
148
|
+
return this.gestureHandlerRegistry
|
149
|
+
}
|
150
|
+
|
151
|
+
public getLogger() {
|
152
|
+
return this.logger
|
153
|
+
}
|
154
|
+
|
155
|
+
public getViewRegistry() {
|
156
|
+
if (!this.viewRegistry) {
|
157
|
+
this.logger.info("Tried to get viewRegistry before it was initialized")
|
158
|
+
throw new Error("Tried to get viewRegistry before it was initialized")
|
159
|
+
}
|
160
|
+
return this.viewRegistry
|
161
|
+
}
|
162
|
+
|
163
|
+
public setGestureHandlerState(handlerTag: number, newState: State) {
|
164
|
+
const handler = this.getGestureHandlerRegistry().getGestureHandlerByHandlerTag(handlerTag);
|
165
|
+
switch (newState) {
|
166
|
+
case State.ACTIVE:
|
167
|
+
handler.activate();
|
168
|
+
break;
|
169
|
+
case State.BEGAN:
|
170
|
+
handler.begin();
|
171
|
+
break;
|
172
|
+
case State.END:
|
173
|
+
handler.end();
|
174
|
+
break;
|
175
|
+
case State.FAILED:
|
176
|
+
handler.fail();
|
177
|
+
break;
|
178
|
+
case State.CANCELLED:
|
179
|
+
handler.cancel();
|
180
|
+
break;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|