@react-native-oh-tpl/react-native-gesture-handler 2.12.6-1 → 2.12.6-2
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/LICENSE +21 -0
- package/harmony/gesture_handler/OAT.xml +44 -0
- package/harmony/gesture_handler/README.OpenSource +11 -0
- package/harmony/gesture_handler/README.md +1 -0
- package/harmony/gesture_handler/build-profile.json5 +7 -7
- package/harmony/gesture_handler/hvigorfile.ts +2 -2
- package/harmony/gesture_handler/index.ets +2 -2
- package/harmony/gesture_handler/oh-package.json5 +13 -11
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +33 -33
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +14 -14
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +60 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +17 -17
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +11 -11
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +60 -60
- 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 +37 -37
- package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
- package/harmony/gesture_handler/src/main/ets/GestureHandlerArkUIAdapter.ets +201 -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 +28 -28
- package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandler.ets +57 -57
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +36 -36
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +125 -125
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +56 -55
- package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +10 -10
- 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/pages/Index.ets +16 -16
- package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
- package/harmony/gesture_handler/src/main/module.json5 +6 -6
- 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.har +0 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +9 -9
- package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -2
- package/lib/commonjs/handlers/createNativeWrapper.js +6 -6
- package/lib/commonjs/handlers/gestures/GestureDetector.js +3 -3
- package/lib/module/components/touchables/GenericTouchable.js +9 -9
- package/lib/module/components/touchables/TouchableOpacity.js +2 -2
- package/lib/module/handlers/createNativeWrapper.js +6 -6
- package/lib/module/handlers/gestures/GestureDetector.js +3 -3
- package/package.json +70 -70
- package/src/RNGestureHandlerModule.ts +6 -6
- package/src/components/GestureButtons.tsx +334 -334
- package/src/components/GestureHandlerButton.tsx +5 -5
- package/src/components/GestureHandlerRootView.tsx +34 -34
- package/src/components/RNGestureHandlerButton.tsx +23 -23
- package/src/components/touchables/GenericTouchable.tsx +301 -301
- package/src/components/touchables/TouchableOpacity.tsx +76 -76
- package/src/components/touchables/TouchableWithoutFeedback.tsx +14 -14
- package/src/components/touchables/index.ts +7 -7
- package/src/handlers/NativeViewGestureHandler.ts +55 -55
- package/src/handlers/PanGestureHandler.ts +327 -327
- package/src/handlers/TapGestureHandler.ts +95 -95
- package/src/handlers/createHandler.tsx +535 -535
- package/src/handlers/createNativeWrapper.tsx +81 -81
- package/src/handlers/gestureHandlerCommon.ts +15 -15
- package/src/handlers/gestures/GestureDetector.tsx +823 -823
- package/src/index.ts +172 -172
- package/src/init.ts +18 -18
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
|
|
2
|
-
|
|
3
|
-
export type RNGestureHandlerButtonDescriptor = Descriptor<"RNGestureHandlerButton">
|
|
4
|
-
|
|
5
|
-
@Component
|
|
6
|
-
export struct RNGestureHandlerButton {
|
|
7
|
-
static readonly DESCRIPTOR_TYPE = "RNGestureHandlerButton"
|
|
8
|
-
public ctx!: RNOHContext
|
|
9
|
-
public tag: number = -1
|
|
10
|
-
@BuilderParam public buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
|
11
|
-
|
|
12
|
-
@State private descriptor: RNGestureHandlerButtonDescriptor = {} as RNGestureHandlerButtonDescriptor
|
|
13
|
-
private unsubscribes: (() => void)[] = []
|
|
14
|
-
|
|
15
|
-
aboutToAppear() {
|
|
16
|
-
this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerButtonDescriptor>(this.tag))
|
|
17
|
-
this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
|
|
18
|
-
this.handleDescriptorChange(d as RNGestureHandlerButtonDescriptor)
|
|
19
|
-
}))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
aboutToDisappear() {
|
|
23
|
-
this.unsubscribes.forEach(unsubscribe => unsubscribe())
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
handleDescriptorChange(newDescriptor: RNGestureHandlerButtonDescriptor) {
|
|
27
|
-
this.descriptor = newDescriptor
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
build() {
|
|
31
|
-
RNViewBase({ ctx: this.ctx, tag: this.tag }) {
|
|
32
|
-
ForEach(this.descriptor.childrenTags, (childrenTag: Tag) => {
|
|
33
|
-
RNComponentFactory({ ctx: this.ctx, tag: childrenTag, buildCustomComponent: this.buildCustomComponent })
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
|
|
2
|
+
|
|
3
|
+
export type RNGestureHandlerButtonDescriptor = Descriptor<"RNGestureHandlerButton">
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export struct RNGestureHandlerButton {
|
|
7
|
+
static readonly DESCRIPTOR_TYPE = "RNGestureHandlerButton"
|
|
8
|
+
public ctx!: RNOHContext
|
|
9
|
+
public tag: number = -1
|
|
10
|
+
@BuilderParam public buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
|
11
|
+
|
|
12
|
+
@State private descriptor: RNGestureHandlerButtonDescriptor = {} as RNGestureHandlerButtonDescriptor
|
|
13
|
+
private unsubscribes: (() => void)[] = []
|
|
14
|
+
|
|
15
|
+
aboutToAppear() {
|
|
16
|
+
this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerButtonDescriptor>(this.tag))
|
|
17
|
+
this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
|
|
18
|
+
this.handleDescriptorChange(d as RNGestureHandlerButtonDescriptor)
|
|
19
|
+
}))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
aboutToDisappear() {
|
|
23
|
+
this.unsubscribes.forEach(unsubscribe => unsubscribe())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
handleDescriptorChange(newDescriptor: RNGestureHandlerButtonDescriptor) {
|
|
27
|
+
this.descriptor = newDescriptor
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
build() {
|
|
31
|
+
RNViewBase({ ctx: this.ctx, tag: this.tag }) {
|
|
32
|
+
ForEach(this.descriptor.childrenTags, (childrenTag: Tag) => {
|
|
33
|
+
RNComponentFactory({ ctx: this.ctx, tag: childrenTag, buildCustomComponent: this.buildCustomComponent })
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
37
|
}
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
|
2
|
-
import { GestureHandlerRegistry } from './GestureHandlerRegistry';
|
|
3
|
-
import { GestureHandlerFactory } from "./GestureHandlerFactory"
|
|
4
|
-
import { ViewRegistry } from './ViewRegistry';
|
|
5
|
-
import { RNGHLogger, StandardRNGHLogger, FakeRNGHLogger } from './RNGHLogger';
|
|
6
|
-
import { EventDispatcher, JSEventDispatcher, AnimatedEventDispatcher } from './EventDispatcher'
|
|
7
|
-
import { RNOHScrollLocker } from "./RNOHScrollLocker"
|
|
8
|
-
|
|
9
|
-
export enum ActionType {
|
|
10
|
-
REANIMATED_WORKLET = 1,
|
|
11
|
-
NATIVE_ANIMATED_EVENT = 2,
|
|
12
|
-
JS_FUNCTION_OLD_API = 3,
|
|
13
|
-
JS_FUNCTION_NEW_API = 4,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export class RNGestureHandlerModule extends TurboModule {
|
|
18
|
-
static NAME = "RNGestureHandlerModule"
|
|
19
|
-
|
|
20
|
-
private gestureHandlerRegistry = new GestureHandlerRegistry()
|
|
21
|
-
private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
|
|
22
|
-
private viewRegistry: ViewRegistry | undefined = undefined
|
|
23
|
-
private logger: RNGHLogger
|
|
24
|
-
|
|
25
|
-
constructor(ctx: TurboModuleContext) {
|
|
26
|
-
super(ctx)
|
|
27
|
-
const debug = false
|
|
28
|
-
this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public install() {
|
|
32
|
-
this.viewRegistry = new ViewRegistry(this.ctx.descriptorRegistry, this.ctx.componentManagerRegistry)
|
|
33
|
-
this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, new RNOHScrollLocker(this.ctx.rnInstance))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public createGestureHandler(
|
|
37
|
-
handlerName: string,
|
|
38
|
-
handlerTag: number,
|
|
39
|
-
config: Readonly<Record<string, unknown>>
|
|
40
|
-
) {
|
|
41
|
-
if (!this.gestureHandlerFactory) {
|
|
42
|
-
this.ctx.logger.error("Trying to create a gesture handler before creating gesture handler factory")
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag)
|
|
46
|
-
this.gestureHandlerRegistry.addGestureHandler(gestureHandler)
|
|
47
|
-
gestureHandler.updateGestureConfig(config)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public attachGestureHandler(
|
|
51
|
-
handlerTag: number,
|
|
52
|
-
viewTag: number,
|
|
53
|
-
actionType: ActionType
|
|
54
|
-
) {
|
|
55
|
-
const eventDispatcher = this.createEventDispatcher(actionType, viewTag)
|
|
56
|
-
if (!eventDispatcher) {
|
|
57
|
-
this.ctx.logger.error("RNGH: Couldn't create EventDispatcher")
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
const view = this.viewRegistry.getViewByTag(viewTag)
|
|
61
|
-
if (!view) {
|
|
62
|
-
this.ctx.logger.error(`RNGH: Couldn't attachGestureHandler to view ${viewTag}`)
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view)
|
|
66
|
-
this.gestureHandlerRegistry
|
|
67
|
-
.getGestureHandlerByHandlerTag(handlerTag)
|
|
68
|
-
.setEventDispatcher(eventDispatcher)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private createEventDispatcher(actionType: ActionType, viewTag: number): EventDispatcher | null {
|
|
72
|
-
switch (actionType) {
|
|
73
|
-
case ActionType.REANIMATED_WORKLET:
|
|
74
|
-
this.ctx.logger.error("RNGH: Reanimated Worklets are not supported")
|
|
75
|
-
break;
|
|
76
|
-
case ActionType.NATIVE_ANIMATED_EVENT:
|
|
77
|
-
return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
|
|
78
|
-
case ActionType.JS_FUNCTION_OLD_API:
|
|
79
|
-
case ActionType.JS_FUNCTION_NEW_API:
|
|
80
|
-
return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
|
|
81
|
-
}
|
|
82
|
-
return null
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public updateGestureHandler(
|
|
86
|
-
handlerTag: number,
|
|
87
|
-
newConfig: Readonly<Record<string, unknown>>
|
|
88
|
-
) {
|
|
89
|
-
const gestureHandler = this.gestureHandlerRegistry.getGestureHandlerByHandlerTag(handlerTag)
|
|
90
|
-
gestureHandler.updateGestureConfig(newConfig)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public dropGestureHandler(handlerTag: number) {
|
|
94
|
-
this.warn("dropGestureHandler is not implemented")
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
|
|
98
|
-
this.warn("handleSetJSResponder is not implemented")
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public handleClearJSResponder() {
|
|
102
|
-
this.warn("handleClearJSResponder is not implemented")
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public flushOperations() {
|
|
106
|
-
this.warn("flushOperations is not implemented")
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// -------------------------------------------------------------------------------------------------------------------
|
|
110
|
-
protected warn(message: string) {
|
|
111
|
-
this.ctx.logger.warn("RNGH: " + message)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public getGestureHandlerRegistry() {
|
|
115
|
-
return this.gestureHandlerRegistry
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public getLogger() {
|
|
119
|
-
return this.logger
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public getViewRegistry() {
|
|
123
|
-
return this.viewRegistry
|
|
124
|
-
}
|
|
125
|
-
}
|
|
1
|
+
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
|
2
|
+
import { GestureHandlerRegistry } from './GestureHandlerRegistry';
|
|
3
|
+
import { GestureHandlerFactory } from "./GestureHandlerFactory"
|
|
4
|
+
import { ViewRegistry } from './ViewRegistry';
|
|
5
|
+
import { RNGHLogger, StandardRNGHLogger, FakeRNGHLogger } from './RNGHLogger';
|
|
6
|
+
import { EventDispatcher, JSEventDispatcher, AnimatedEventDispatcher } from './EventDispatcher'
|
|
7
|
+
import { RNOHScrollLocker } from "./RNOHScrollLocker"
|
|
8
|
+
|
|
9
|
+
export enum ActionType {
|
|
10
|
+
REANIMATED_WORKLET = 1,
|
|
11
|
+
NATIVE_ANIMATED_EVENT = 2,
|
|
12
|
+
JS_FUNCTION_OLD_API = 3,
|
|
13
|
+
JS_FUNCTION_NEW_API = 4,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export class RNGestureHandlerModule extends TurboModule {
|
|
18
|
+
static NAME = "RNGestureHandlerModule"
|
|
19
|
+
|
|
20
|
+
private gestureHandlerRegistry = new GestureHandlerRegistry()
|
|
21
|
+
private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
|
|
22
|
+
private viewRegistry: ViewRegistry | undefined = undefined
|
|
23
|
+
private logger: RNGHLogger
|
|
24
|
+
|
|
25
|
+
constructor(ctx: TurboModuleContext) {
|
|
26
|
+
super(ctx)
|
|
27
|
+
const debug = false
|
|
28
|
+
this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public install() {
|
|
32
|
+
this.viewRegistry = new ViewRegistry(this.ctx.descriptorRegistry, this.ctx.componentManagerRegistry)
|
|
33
|
+
this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, new RNOHScrollLocker(this.ctx.rnInstance))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public createGestureHandler(
|
|
37
|
+
handlerName: string,
|
|
38
|
+
handlerTag: number,
|
|
39
|
+
config: Readonly<Record<string, unknown>>
|
|
40
|
+
) {
|
|
41
|
+
if (!this.gestureHandlerFactory) {
|
|
42
|
+
this.ctx.logger.error("Trying to create a gesture handler before creating gesture handler factory")
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag)
|
|
46
|
+
this.gestureHandlerRegistry.addGestureHandler(gestureHandler)
|
|
47
|
+
gestureHandler.updateGestureConfig(config)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public attachGestureHandler(
|
|
51
|
+
handlerTag: number,
|
|
52
|
+
viewTag: number,
|
|
53
|
+
actionType: ActionType
|
|
54
|
+
) {
|
|
55
|
+
const eventDispatcher = this.createEventDispatcher(actionType, viewTag)
|
|
56
|
+
if (!eventDispatcher) {
|
|
57
|
+
this.ctx.logger.error("RNGH: Couldn't create EventDispatcher")
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
const view = this.viewRegistry.getViewByTag(viewTag)
|
|
61
|
+
if (!view) {
|
|
62
|
+
this.ctx.logger.error(`RNGH: Couldn't attachGestureHandler to view ${viewTag}`)
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view)
|
|
66
|
+
this.gestureHandlerRegistry
|
|
67
|
+
.getGestureHandlerByHandlerTag(handlerTag)
|
|
68
|
+
.setEventDispatcher(eventDispatcher)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private createEventDispatcher(actionType: ActionType, viewTag: number): EventDispatcher | null {
|
|
72
|
+
switch (actionType) {
|
|
73
|
+
case ActionType.REANIMATED_WORKLET:
|
|
74
|
+
this.ctx.logger.error("RNGH: Reanimated Worklets are not supported")
|
|
75
|
+
break;
|
|
76
|
+
case ActionType.NATIVE_ANIMATED_EVENT:
|
|
77
|
+
return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
|
|
78
|
+
case ActionType.JS_FUNCTION_OLD_API:
|
|
79
|
+
case ActionType.JS_FUNCTION_NEW_API:
|
|
80
|
+
return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
|
|
81
|
+
}
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public updateGestureHandler(
|
|
86
|
+
handlerTag: number,
|
|
87
|
+
newConfig: Readonly<Record<string, unknown>>
|
|
88
|
+
) {
|
|
89
|
+
const gestureHandler = this.gestureHandlerRegistry.getGestureHandlerByHandlerTag(handlerTag)
|
|
90
|
+
gestureHandler.updateGestureConfig(newConfig)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public dropGestureHandler(handlerTag: number) {
|
|
94
|
+
this.warn("dropGestureHandler is not implemented")
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
|
|
98
|
+
this.warn("handleSetJSResponder is not implemented")
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public handleClearJSResponder() {
|
|
102
|
+
this.warn("handleClearJSResponder is not implemented")
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public flushOperations() {
|
|
106
|
+
this.warn("flushOperations is not implemented")
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// -------------------------------------------------------------------------------------------------------------------
|
|
110
|
+
protected warn(message: string) {
|
|
111
|
+
this.ctx.logger.warn("RNGH: " + message)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public getGestureHandlerRegistry() {
|
|
115
|
+
return this.gestureHandlerRegistry
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public getLogger() {
|
|
119
|
+
return this.logger
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public getViewRegistry() {
|
|
123
|
+
return this.viewRegistry
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
|
|
2
|
-
import { RNGHRootTouchHandler } from "./RNGHRootTouchHandler"
|
|
3
|
-
import { RNGestureHandlerModule } from "./RNGestureHandlerModule"
|
|
4
|
-
import { Vector2D } from "./Vector2D"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
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
|
-
|
|
1
|
+
import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
|
|
2
|
+
import { RNGHRootTouchHandler } from "./RNGHRootTouchHandler"
|
|
3
|
+
import { RNGestureHandlerModule } from "./RNGestureHandlerModule"
|
|
4
|
+
import { Vector2D } from "./Vector2D"
|
|
5
|
+
import { ViewRegistry } from './ViewRegistry'
|
|
6
|
+
|
|
7
|
+
export type RNGestureHandlerRootViewDescriptor = Descriptor<"RNGestureHandlerRootView">
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export struct RNGestureHandlerRootView {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated: Use RNGestureHandlerRootView.NAME instead
|
|
13
|
+
*/
|
|
14
|
+
static readonly DESCRIPTOR_TYPE = "RNGestureHandlerRootView"
|
|
15
|
+
static readonly NAME = "RNGestureHandlerRootView"
|
|
16
|
+
ctx!: RNOHContext
|
|
17
|
+
tag: number = -1
|
|
18
|
+
@BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
|
|
19
|
+
@State descriptor: RNGestureHandlerRootViewDescriptor = {} as RNGestureHandlerRootViewDescriptor
|
|
20
|
+
private unsubscribes: (() => void)[] = []
|
|
21
|
+
private touchHandler: RNGHRootTouchHandler | undefined = undefined
|
|
22
|
+
|
|
23
|
+
aboutToAppear() {
|
|
24
|
+
const rnGestureHandlerModule = this.ctx.rnInstance.getTurboModule<RNGestureHandlerModule>(RNGestureHandlerModule.NAME)
|
|
25
|
+
const rootTag = this.ctx.descriptorRegistry.getDescriptorLineage(this.tag)[0].tag
|
|
26
|
+
this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry() as ViewRegistry, rnGestureHandlerModule.getGestureHandlerRegistry(), rnGestureHandlerModule.getLogger())
|
|
27
|
+
this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerRootViewDescriptor>(this.tag))
|
|
28
|
+
this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
|
|
29
|
+
this.handleDescriptorChange(d as RNGestureHandlerRootViewDescriptor)
|
|
30
|
+
}))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
aboutToDisappear() {
|
|
34
|
+
this.unsubscribes.forEach(unsubscribe => unsubscribe())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleDescriptorChange(newDescriptor: RNGestureHandlerRootViewDescriptor) {
|
|
38
|
+
this.descriptor = newDescriptor
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
build() {
|
|
42
|
+
RNViewBase({ ctx: this.ctx, tag: this.tag }) {
|
|
43
|
+
ForEach(this.descriptor.childrenTags, (childrenTag: Tag) => {
|
|
44
|
+
RNComponentFactory({ ctx: this.ctx, tag: childrenTag, buildCustomComponent: this.buildCustomComponent })
|
|
45
|
+
})
|
|
46
|
+
Stack() {
|
|
47
|
+
}
|
|
48
|
+
.width("100%")
|
|
49
|
+
.height("100%")
|
|
50
|
+
.onTouch((e) => {
|
|
51
|
+
this.touchHandler?.handleTouch(e)
|
|
52
|
+
})
|
|
53
|
+
.hitTestBehavior(HitTestMode.Transparent)
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
}
|
|
56
57
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { RNInstance } from "rnoh/ts"
|
|
2
|
-
import { ScrollLocker } from "./GestureHandler"
|
|
3
|
-
|
|
4
|
-
export class RNOHScrollLocker implements ScrollLocker {
|
|
5
|
-
public constructor(private rnInstance: RNInstance) {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
public lockScrollContainingViewTag(viewTag: number) {
|
|
9
|
-
return this.rnInstance.blockComponentsGestures(viewTag)
|
|
10
|
-
}
|
|
1
|
+
import { RNInstance } from "rnoh/ts"
|
|
2
|
+
import { ScrollLocker } from "./GestureHandler"
|
|
3
|
+
|
|
4
|
+
export class RNOHScrollLocker implements ScrollLocker {
|
|
5
|
+
public constructor(private rnInstance: RNInstance) {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public lockScrollContainingViewTag(viewTag: number) {
|
|
9
|
+
return this.rnInstance.blockComponentsGestures(viewTag)
|
|
10
|
+
}
|
|
11
11
|
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
export enum State {
|
|
2
|
-
/** This is the initial state of each handler and it goes into this state after it's done recognizing a gesture. */
|
|
3
|
-
UNDETERMINED,
|
|
4
|
-
|
|
5
|
-
/** A handler received some touches but for some reason didn't recognize them. For example, if a finger travels more
|
|
6
|
-
* distance than a defined maxDist property allows, then the handler won't become active but will fail instead.
|
|
7
|
-
* Afterwards, it's state will be reset to UNDETERMINED. */
|
|
8
|
-
FAILED,
|
|
9
|
-
|
|
10
|
-
/** Handler has started receiving touch stream but hasn't yet received enough data to either fail or activate. */
|
|
11
|
-
BEGAN,
|
|
12
|
-
|
|
13
|
-
/** The gesture recognizer has received a signal (possibly new touches or a command from the touch system controller)
|
|
14
|
-
* resulting in the cancellation of a continuous gesture. The gesture's state will become CANCELLED until it is
|
|
15
|
-
* finally reset to the initial state, UNDETERMINED. */
|
|
16
|
-
CANCELLED,
|
|
17
|
-
|
|
18
|
-
/** Handler has recognized a gesture. It will become and stay in the ACTIVE state until the gesture finishes
|
|
19
|
-
* (e.g. when user lifts the finger) or gets cancelled by the touch system. Under normal circumstances the state will
|
|
20
|
-
* then turn into END. In the case that a gesture is cancelled by the touch system, its state would then become
|
|
21
|
-
* CANCELLED. Learn about discrete and continuous handlers here to understand how long a handler can be kept in the
|
|
22
|
-
* ACTIVE state.
|
|
23
|
-
* */
|
|
24
|
-
ACTIVE,
|
|
25
|
-
|
|
26
|
-
/** The gesture recognizer has received touches signalling the end of a gesture. Its state will become END until it is
|
|
27
|
-
* reset to UNDETERMINED.
|
|
28
|
-
* */
|
|
29
|
-
END,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getStateName(state: State): string {
|
|
33
|
-
switch (state) {
|
|
34
|
-
case State.UNDETERMINED:
|
|
35
|
-
return "UNDETERMINED"
|
|
36
|
-
case State.FAILED:
|
|
37
|
-
return "FAILED"
|
|
38
|
-
case State.BEGAN:
|
|
39
|
-
return "BEGAN"
|
|
40
|
-
case State.CANCELLED:
|
|
41
|
-
return "CANCELLED"
|
|
42
|
-
case State.ACTIVE:
|
|
43
|
-
return "ACTIVE"
|
|
44
|
-
case State.END:
|
|
45
|
-
return "END"
|
|
46
|
-
}
|
|
1
|
+
export enum State {
|
|
2
|
+
/** This is the initial state of each handler and it goes into this state after it's done recognizing a gesture. */
|
|
3
|
+
UNDETERMINED,
|
|
4
|
+
|
|
5
|
+
/** A handler received some touches but for some reason didn't recognize them. For example, if a finger travels more
|
|
6
|
+
* distance than a defined maxDist property allows, then the handler won't become active but will fail instead.
|
|
7
|
+
* Afterwards, it's state will be reset to UNDETERMINED. */
|
|
8
|
+
FAILED,
|
|
9
|
+
|
|
10
|
+
/** Handler has started receiving touch stream but hasn't yet received enough data to either fail or activate. */
|
|
11
|
+
BEGAN,
|
|
12
|
+
|
|
13
|
+
/** The gesture recognizer has received a signal (possibly new touches or a command from the touch system controller)
|
|
14
|
+
* resulting in the cancellation of a continuous gesture. The gesture's state will become CANCELLED until it is
|
|
15
|
+
* finally reset to the initial state, UNDETERMINED. */
|
|
16
|
+
CANCELLED,
|
|
17
|
+
|
|
18
|
+
/** Handler has recognized a gesture. It will become and stay in the ACTIVE state until the gesture finishes
|
|
19
|
+
* (e.g. when user lifts the finger) or gets cancelled by the touch system. Under normal circumstances the state will
|
|
20
|
+
* then turn into END. In the case that a gesture is cancelled by the touch system, its state would then become
|
|
21
|
+
* CANCELLED. Learn about discrete and continuous handlers here to understand how long a handler can be kept in the
|
|
22
|
+
* ACTIVE state.
|
|
23
|
+
* */
|
|
24
|
+
ACTIVE,
|
|
25
|
+
|
|
26
|
+
/** The gesture recognizer has received touches signalling the end of a gesture. Its state will become END until it is
|
|
27
|
+
* reset to UNDETERMINED.
|
|
28
|
+
* */
|
|
29
|
+
END,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getStateName(state: State): string {
|
|
33
|
+
switch (state) {
|
|
34
|
+
case State.UNDETERMINED:
|
|
35
|
+
return "UNDETERMINED"
|
|
36
|
+
case State.FAILED:
|
|
37
|
+
return "FAILED"
|
|
38
|
+
case State.BEGAN:
|
|
39
|
+
return "BEGAN"
|
|
40
|
+
case State.CANCELLED:
|
|
41
|
+
return "CANCELLED"
|
|
42
|
+
case State.ACTIVE:
|
|
43
|
+
return "ACTIVE"
|
|
44
|
+
case State.END:
|
|
45
|
+
return "END"
|
|
46
|
+
}
|
|
47
47
|
}
|