@react-native-oh-tpl/react-native-gesture-handler 2.12.6-2 → 2.12.9
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/harmony/gesture_handler/BuildProfile.ets +5 -0
- package/harmony/gesture_handler/build-profile.json5 +13 -2
- package/harmony/gesture_handler/hvigorfile.ts +1 -1
- package/harmony/gesture_handler/index.ets +1 -1
- package/harmony/gesture_handler/oh-package-lock.json5 +17 -0
- package/harmony/gesture_handler/oh-package.json5 +10 -11
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +75 -6
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +14 -8
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +4 -28
- 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 +17 -12
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +5 -2
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerPackage.h +72 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +4 -28
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentInstance.h +78 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
- package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +16 -1
- package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/{GestureHandlerArkUIAdapter.ets → GestureHandlerArkUIAdapter.ts} +2 -1
- package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +5 -5
- package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +20 -1
- package/harmony/gesture_handler/src/main/ets/{RNGHRootTouchHandler.ets → RNGHRootTouchHandlerArkTS.ts} +5 -3
- package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandlerCAPI.ts +87 -0
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +4 -3
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +65 -7
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +7 -11
- package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +17 -5
- package/harmony/gesture_handler/src/main/ets/View.ts +1 -1
- package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +1 -1
- 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/types.ts +25 -0
- package/harmony/gesture_handler/src/main/module.json5 +6 -6
- 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 +9 -13
- package/src/RNGestureHandlerModule.ts +3 -4
- package/src/components/GestureHandlerRootView.tsx +4 -15
- package/src/handlers/createHandler.tsx +4 -5
- package/src/index.ts +13 -13
- 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/harmony/gesture_handler/LICENSE +0 -21
- package/harmony/gesture_handler/OAT.xml +0 -44
- package/harmony/gesture_handler/README.OpenSource +0 -11
- package/harmony/gesture_handler/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
|
@@ -324,7 +324,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
|
|
|
324
324
|
return this.view
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
public begin(): void {
|
|
328
328
|
this.logger.info("begin")
|
|
329
329
|
if (!this.isWithinHitSlop()) return;
|
|
330
330
|
if (this.currentState === State.UNDETERMINED) {
|
|
@@ -401,7 +401,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
|
|
|
401
401
|
return false;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
public activate(): void {
|
|
405
405
|
this.logger.info("activate")
|
|
406
406
|
if (this.currentState === State.UNDETERMINED || this.currentState === State.BEGAN) {
|
|
407
407
|
this.moveToState(State.ACTIVE)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Point } from "rnoh"
|
|
1
|
+
import { Point } from "@rnoh/react-native-openharmony/ts"
|
|
2
2
|
import { GestureHandler } from "./GestureHandler"
|
|
3
3
|
import { AdaptedEvent, EventType, PointerType, TouchEventType, Touch } from "./Event"
|
|
4
4
|
import { View } from "./View"
|
|
5
5
|
import { RNGHLogger } from "./RNGHLogger"
|
|
6
|
+
import { TouchEvent, TouchType, TouchObject } from "./types"
|
|
6
7
|
|
|
7
8
|
export class GestureHandlerArkUIAdapter {
|
|
8
9
|
private activePointerIds = new Set<number>()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {RNPackage, TurboModuleContext, TurboModulesFactory} from 'rnoh/ts';
|
|
2
|
-
import type {TurboModule} from 'rnoh/ts';
|
|
1
|
+
import {RNPackage, TurboModuleContext, TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
|
|
2
|
+
import type {TurboModule} from '@rnoh/react-native-openharmony/ts';
|
|
3
3
|
import {RNGestureHandlerModule} from './RNGestureHandlerModule';
|
|
4
4
|
|
|
5
5
|
class GestureHandlerTurboModulesFactory extends TurboModulesFactory {
|
|
@@ -17,17 +17,17 @@ export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =
|
|
|
17
17
|
export type GestureStateChangeEvent<GestureStateChangeEventPayloadT = Record<string, unknown>> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT
|
|
18
18
|
|
|
19
19
|
export type TouchData = {
|
|
20
|
-
|
|
21
|
-
absoluteY: number;
|
|
20
|
+
id: number;
|
|
22
21
|
x: number;
|
|
23
22
|
y: number;
|
|
24
|
-
|
|
23
|
+
absoluteX: number;
|
|
24
|
+
absoluteY: number;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export type GestureTouchEvent = {
|
|
28
|
-
state: State;
|
|
29
|
-
numberOfTouches: number;
|
|
30
28
|
handlerTag: number;
|
|
29
|
+
numberOfTouches: number;
|
|
30
|
+
state: State;
|
|
31
31
|
eventType: TouchEventType;
|
|
32
32
|
allTouches: TouchData[];
|
|
33
33
|
changedTouches: TouchData[];
|
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import { RNOHContext } from "rnoh/ts"
|
|
1
|
+
import { RNOHContext } from "@rnoh/react-native-openharmony/ts"
|
|
2
2
|
|
|
3
3
|
export interface RNGHLogger {
|
|
4
4
|
info(msg: string): void
|
|
5
5
|
|
|
6
6
|
cloneWithPrefix(prefix: string): RNGHLogger
|
|
7
|
+
|
|
8
|
+
debug(msg: string)
|
|
9
|
+
|
|
10
|
+
error(msg: string)
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export class StandardRNGHLogger implements RNGHLogger {
|
|
10
14
|
constructor(private rnohLogger: RNOHContext["logger"], private prefix: string) {
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
error(msg: string) {
|
|
18
|
+
this.rnohLogger.error(`${this.prefix}::${msg}`)
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
info(msg: string) {
|
|
14
22
|
this.rnohLogger.info(`${this.prefix}::${msg}`)
|
|
15
23
|
}
|
|
16
24
|
|
|
25
|
+
debug(msg: string) {
|
|
26
|
+
this.rnohLogger.debug(`${this.prefix}::${msg}`)
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
cloneWithPrefix(prefix: string) {
|
|
18
30
|
return new StandardRNGHLogger(this.rnohLogger, `${this.prefix}::${prefix}`)
|
|
19
31
|
}
|
|
@@ -23,6 +35,13 @@ export class FakeRNGHLogger implements RNGHLogger {
|
|
|
23
35
|
info(msg: string) {
|
|
24
36
|
}
|
|
25
37
|
|
|
38
|
+
debug(msg: string) {
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
error(msg: string): void {
|
|
43
|
+
}
|
|
44
|
+
|
|
26
45
|
cloneWithPrefix(prefix: string) {
|
|
27
46
|
return new FakeRNGHLogger()
|
|
28
47
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Tag } from "rnoh"
|
|
1
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
2
2
|
import { GestureHandlerRegistry } from "./GestureHandlerRegistry"
|
|
3
3
|
import { GestureHandlerArkUIAdapter } from "./GestureHandlerArkUIAdapter"
|
|
4
4
|
import { ViewRegistry } from "./ViewRegistry"
|
|
5
5
|
import { RNGHLogger } from './RNGHLogger'
|
|
6
|
+
import { TouchEvent, TouchType } from "./types"
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
export class
|
|
9
|
+
export class RNGHRootTouchHandlerArkTS {
|
|
9
10
|
private adapterByViewTag: Map<number, GestureHandlerArkUIAdapter> = new Map() // TODO: remove an adapter when a view or gesture handler is removed
|
|
10
11
|
private activeViewTags: number[] = []
|
|
11
12
|
private viewRegistry: ViewRegistry
|
|
@@ -20,7 +21,8 @@ export class RNGHRootTouchHandler {
|
|
|
20
21
|
this.logger = logger
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
public handleTouch(
|
|
24
|
+
public handleTouch(touchEvent: any) {
|
|
25
|
+
const e = touchEvent as TouchEvent
|
|
24
26
|
if (e.type === TouchType.Down) {
|
|
25
27
|
this.activeViewTags = []
|
|
26
28
|
}
|
|
@@ -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,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "@rnoh/react-native-openharmony"
|
|
2
|
+
import { RNGestureHandlerButton as RNC } from "./namespace/RNGestureHandlerButton"
|
|
2
3
|
|
|
3
|
-
export type RNGestureHandlerButtonDescriptor = Descriptor
|
|
4
|
+
export type RNGestureHandlerButtonDescriptor = RNC.Descriptor
|
|
4
5
|
|
|
5
6
|
@Component
|
|
6
7
|
export struct RNGestureHandlerButton {
|
|
7
|
-
static readonly
|
|
8
|
+
static readonly NAME = RNC.NAME
|
|
8
9
|
public ctx!: RNOHContext
|
|
9
10
|
public tag: number = -1
|
|
10
11
|
@BuilderParam public buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
|
1
|
+
import { TurboModule, TurboModuleContext, Tag } from '@rnoh/react-native-openharmony/ts';
|
|
2
|
+
// import { TM } from "rnoh/generated/ts"
|
|
2
3
|
import { GestureHandlerRegistry } from './GestureHandlerRegistry';
|
|
3
4
|
import { GestureHandlerFactory } from "./GestureHandlerFactory"
|
|
4
5
|
import { ViewRegistry } from './ViewRegistry';
|
|
5
6
|
import { RNGHLogger, StandardRNGHLogger, FakeRNGHLogger } from './RNGHLogger';
|
|
6
|
-
import {
|
|
7
|
-
|
|
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';
|
|
8
17
|
|
|
9
18
|
export enum ActionType {
|
|
10
19
|
REANIMATED_WORKLET = 1,
|
|
@@ -15,22 +24,48 @@ export enum ActionType {
|
|
|
15
24
|
|
|
16
25
|
|
|
17
26
|
export class RNGestureHandlerModule extends TurboModule {
|
|
27
|
+
// implements TM.RNGestureHandlerModule.Spec {
|
|
18
28
|
static NAME = "RNGestureHandlerModule"
|
|
19
29
|
|
|
20
30
|
private gestureHandlerRegistry = new GestureHandlerRegistry()
|
|
21
31
|
private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
|
|
22
32
|
private viewRegistry: ViewRegistry | undefined = undefined
|
|
23
33
|
private logger: RNGHLogger
|
|
34
|
+
private touchHandlerByRootTag = new Map<Tag, RNGHRootTouchHandlerCAPI>()
|
|
24
35
|
|
|
25
36
|
constructor(ctx: TurboModuleContext) {
|
|
26
37
|
super(ctx)
|
|
27
38
|
const debug = false
|
|
28
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
|
+
|
|
29
62
|
}
|
|
30
63
|
|
|
31
64
|
public install() {
|
|
32
65
|
this.viewRegistry = new ViewRegistry(this.ctx.descriptorRegistry, this.ctx.componentManagerRegistry)
|
|
33
|
-
this.
|
|
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
|
|
34
69
|
}
|
|
35
70
|
|
|
36
71
|
public createGestureHandler(
|
|
@@ -71,15 +106,13 @@ export class RNGestureHandlerModule extends TurboModule {
|
|
|
71
106
|
private createEventDispatcher(actionType: ActionType, viewTag: number): EventDispatcher | null {
|
|
72
107
|
switch (actionType) {
|
|
73
108
|
case ActionType.REANIMATED_WORKLET:
|
|
74
|
-
this.ctx.logger.
|
|
75
|
-
break;
|
|
109
|
+
return new ReanimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('ReanimatedEventDispatcher'), viewTag)
|
|
76
110
|
case ActionType.NATIVE_ANIMATED_EVENT:
|
|
77
111
|
return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
|
|
78
112
|
case ActionType.JS_FUNCTION_OLD_API:
|
|
79
113
|
case ActionType.JS_FUNCTION_NEW_API:
|
|
80
114
|
return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
|
|
81
115
|
}
|
|
82
|
-
return null
|
|
83
116
|
}
|
|
84
117
|
|
|
85
118
|
public updateGestureHandler(
|
|
@@ -120,6 +153,31 @@ export class RNGestureHandlerModule extends TurboModule {
|
|
|
120
153
|
}
|
|
121
154
|
|
|
122
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
|
+
}
|
|
123
160
|
return this.viewRegistry
|
|
124
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
|
+
}
|
|
125
183
|
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "@rnoh/react-native-openharmony"
|
|
2
|
+
import { RNGestureHandlerRootView as RNC } from "./namespace/RNGestureHandlerRootView"
|
|
3
|
+
import { RNGHRootTouchHandlerArkTS as RNGHRootTouchHandler } from "./RNGHRootTouchHandlerArkTS"
|
|
3
4
|
import { RNGestureHandlerModule } from "./RNGestureHandlerModule"
|
|
4
|
-
import { Vector2D } from "./Vector2D"
|
|
5
|
-
import { ViewRegistry } from './ViewRegistry'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
export type RNGestureHandlerRootViewDescriptor = RNC.Descriptor
|
|
8
8
|
|
|
9
9
|
@Component
|
|
10
10
|
export struct RNGestureHandlerRootView {
|
|
11
|
-
|
|
12
|
-
* @deprecated: Use RNGestureHandlerRootView.NAME instead
|
|
13
|
-
*/
|
|
14
|
-
static readonly DESCRIPTOR_TYPE = "RNGestureHandlerRootView"
|
|
15
|
-
static readonly NAME = "RNGestureHandlerRootView"
|
|
11
|
+
static readonly NAME = RNC.NAME
|
|
16
12
|
ctx!: RNOHContext
|
|
17
13
|
tag: number = -1
|
|
18
14
|
@BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
|
@@ -23,7 +19,7 @@ export struct RNGestureHandlerRootView {
|
|
|
23
19
|
aboutToAppear() {
|
|
24
20
|
const rnGestureHandlerModule = this.ctx.rnInstance.getTurboModule<RNGestureHandlerModule>(RNGestureHandlerModule.NAME)
|
|
25
21
|
const rootTag = this.ctx.descriptorRegistry.getDescriptorLineage(this.tag)[0].tag
|
|
26
|
-
this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry()
|
|
22
|
+
this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry(), rnGestureHandlerModule.getGestureHandlerRegistry(), rnGestureHandlerModule.getLogger())
|
|
27
23
|
this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerRootViewDescriptor>(this.tag))
|
|
28
24
|
this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
|
|
29
25
|
this.handleDescriptorChange(d as RNGestureHandlerRootViewDescriptor)
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import { RNInstance } from "rnoh/ts"
|
|
1
|
+
import { RNInstance } from "@rnoh/react-native-openharmony/ts"
|
|
2
2
|
import { ScrollLocker } from "./GestureHandler"
|
|
3
3
|
|
|
4
|
-
export class
|
|
5
|
-
|
|
4
|
+
export class RNOHScrollLockerArkTS implements ScrollLocker {
|
|
5
|
+
constructor(private rnInstance: RNInstance) {
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
lockScrollContainingViewTag(viewTag: number) {
|
|
9
9
|
return this.rnInstance.blockComponentsGestures(viewTag)
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class RNOHScrollLockerCAPI implements ScrollLocker {
|
|
14
|
+
constructor(private rnInstance: RNInstance) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
lockScrollContainingViewTag(viewTag: number) {
|
|
18
|
+
this.rnInstance.postMessageToCpp("RNGH::SET_NATIVE_RESPONDERS_BLOCK", { targetTag: viewTag, shouldBlock: true });
|
|
19
|
+
return () => {
|
|
20
|
+
this.rnInstance.postMessageToCpp("RNGH::SET_NATIVE_RESPONDERS_BLOCK", { targetTag: viewTag, shouldBlock: false });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// This file was generated.
|
|
2
|
+
import {
|
|
3
|
+
Descriptor as ComponentDescriptor,
|
|
4
|
+
ViewBaseProps,
|
|
5
|
+
ViewRawProps,
|
|
6
|
+
ViewDescriptorWrapperBase,
|
|
7
|
+
ColorValue,
|
|
8
|
+
Color,
|
|
9
|
+
RNInstance,
|
|
10
|
+
Tag,
|
|
11
|
+
RNComponentCommandReceiver,
|
|
12
|
+
ViewPropsSelector,
|
|
13
|
+
} from '@rnoh/react-native-openharmony/ts';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export namespace RNGestureHandlerButton {
|
|
17
|
+
export const NAME = "RNGestureHandlerButton" as const
|
|
18
|
+
|
|
19
|
+
export interface DirectRawProps {
|
|
20
|
+
exclusive?: boolean;
|
|
21
|
+
foreground?: boolean;
|
|
22
|
+
borderless?: boolean;
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
rippleColor?: ColorValue;
|
|
25
|
+
rippleRadius?: number;
|
|
26
|
+
touchSoundDisabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Props extends ViewBaseProps {}
|
|
30
|
+
|
|
31
|
+
export interface State {}
|
|
32
|
+
|
|
33
|
+
export interface RawProps extends ViewRawProps, DirectRawProps {}
|
|
34
|
+
|
|
35
|
+
export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
|
|
36
|
+
get exclusive() {
|
|
37
|
+
return this.rawProps.exclusive ?? true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get foreground() {
|
|
41
|
+
return this.rawProps.foreground ?? false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get borderless() {
|
|
45
|
+
return this.rawProps.borderless ?? false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get enabled() {
|
|
49
|
+
return this.rawProps.enabled ?? true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get rippleRadius() {
|
|
53
|
+
return this.rawProps.rippleRadius ?? 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get touchSoundDisabled() {
|
|
57
|
+
return this.rawProps.touchSoundDisabled ?? false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
get rippleColor() {
|
|
62
|
+
if (this.rawProps.rippleColor) {
|
|
63
|
+
return Color.fromColorValue(this.rawProps.rippleColor)
|
|
64
|
+
} else {
|
|
65
|
+
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type Descriptor = ComponentDescriptor<
|
|
72
|
+
typeof NAME,
|
|
73
|
+
Props,
|
|
74
|
+
State,
|
|
75
|
+
RawProps
|
|
76
|
+
>;
|
|
77
|
+
|
|
78
|
+
export class DescriptorWrapper extends ViewDescriptorWrapperBase<
|
|
79
|
+
typeof NAME,
|
|
80
|
+
Props,
|
|
81
|
+
State,
|
|
82
|
+
RawProps,
|
|
83
|
+
PropsSelector
|
|
84
|
+
> {
|
|
85
|
+
protected createPropsSelector() {
|
|
86
|
+
return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface EventPayloadByName {
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class EventEmitter {
|
|
94
|
+
constructor(private rnInstance: RNInstance, private tag: Tag) {}
|
|
95
|
+
|
|
96
|
+
emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
|
|
97
|
+
this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface CommandArgvByName {
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class CommandReceiver {
|
|
105
|
+
private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
|
|
106
|
+
private cleanUp: (() => void) | undefined = undefined
|
|
107
|
+
|
|
108
|
+
constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
|
|
112
|
+
if (!this.listenersByCommandName.has(commandName)) {
|
|
113
|
+
this.listenersByCommandName.set(commandName, new Set())
|
|
114
|
+
}
|
|
115
|
+
this.listenersByCommandName.get(commandName)!.add(listener)
|
|
116
|
+
const hasRegisteredCommandReceiver = !!this.cleanUp
|
|
117
|
+
if (!hasRegisteredCommandReceiver) {
|
|
118
|
+
this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
|
|
119
|
+
if (this.listenersByCommandName.has(commandName)) {
|
|
120
|
+
const listeners = this.listenersByCommandName.get(commandName)!
|
|
121
|
+
listeners.forEach(listener => {
|
|
122
|
+
listener(argv)
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
this.listenersByCommandName.get(commandName)?.delete(listener)
|
|
130
|
+
if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
|
|
131
|
+
this.listenersByCommandName.delete(commandName)
|
|
132
|
+
}
|
|
133
|
+
if (this.listenersByCommandName.size === 0) {
|
|
134
|
+
this.cleanUp?.()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// This file was generated.
|
|
2
|
+
import { Tag } from "../../ts"
|
|
3
|
+
|
|
4
|
+
export namespace RNGestureHandlerModule {
|
|
5
|
+
export const NAME = 'RNGestureHandlerModule' as const
|
|
6
|
+
|
|
7
|
+
export interface Spec {
|
|
8
|
+
handleSetJSResponder(tag: number, blockNativeResponder: boolean): void;
|
|
9
|
+
|
|
10
|
+
handleClearJSResponder(): void;
|
|
11
|
+
|
|
12
|
+
createGestureHandler(handlerName: string, handlerTag: number, config: Object): void;
|
|
13
|
+
|
|
14
|
+
attachGestureHandler(handlerTag: number, newView: number, actionType: number): void;
|
|
15
|
+
|
|
16
|
+
updateGestureHandler(handlerTag: number, newConfig: Object): void;
|
|
17
|
+
|
|
18
|
+
dropGestureHandler(handlerTag: number): void;
|
|
19
|
+
|
|
20
|
+
install(): boolean;
|
|
21
|
+
|
|
22
|
+
flushOperations(): void;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|