@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.
Files changed (79) hide show
  1. package/harmony/gesture_handler/LICENSE +21 -0
  2. package/harmony/gesture_handler/OAT.xml +44 -0
  3. package/harmony/gesture_handler/README.OpenSource +11 -0
  4. package/harmony/gesture_handler/README.md +1 -0
  5. package/harmony/gesture_handler/build-profile.json5 +7 -7
  6. package/harmony/gesture_handler/hvigorfile.ts +2 -2
  7. package/harmony/gesture_handler/index.ets +2 -2
  8. package/harmony/gesture_handler/oh-package.json5 +13 -11
  9. package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
  10. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +33 -33
  11. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +14 -14
  12. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +60 -60
  13. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +17 -17
  14. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +11 -11
  15. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +60 -60
  16. package/harmony/gesture_handler/src/main/ets/CircularBuffer.ts +42 -42
  17. package/harmony/gesture_handler/src/main/ets/Event.ts +67 -67
  18. package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +37 -37
  19. package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
  20. package/harmony/gesture_handler/src/main/ets/GestureHandlerArkUIAdapter.ets +201 -201
  21. package/harmony/gesture_handler/src/main/ets/GestureHandlerFactory.ts +44 -44
  22. package/harmony/gesture_handler/src/main/ets/GestureHandlerOrchestrator.ts +280 -280
  23. package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +22 -22
  24. package/harmony/gesture_handler/src/main/ets/GestureHandlerRegistry.ts +27 -27
  25. package/harmony/gesture_handler/src/main/ets/InteractionManager.ts +108 -108
  26. package/harmony/gesture_handler/src/main/ets/LeastSquareSolver.ts +182 -182
  27. package/harmony/gesture_handler/src/main/ets/NativeViewGestureHandler.ts +114 -114
  28. package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +33 -33
  29. package/harmony/gesture_handler/src/main/ets/PanGestureHandler.ts +327 -327
  30. package/harmony/gesture_handler/src/main/ets/PointerTracker.ts +239 -239
  31. package/harmony/gesture_handler/src/main/ets/RNGHError.ts +4 -4
  32. package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +28 -28
  33. package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandler.ets +57 -57
  34. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +36 -36
  35. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +125 -125
  36. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +56 -55
  37. package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +10 -10
  38. package/harmony/gesture_handler/src/main/ets/State.ts +46 -46
  39. package/harmony/gesture_handler/src/main/ets/TapGestureHandler.ts +205 -205
  40. package/harmony/gesture_handler/src/main/ets/Vector2D.ts +36 -36
  41. package/harmony/gesture_handler/src/main/ets/VelocityTracker.ts +98 -98
  42. package/harmony/gesture_handler/src/main/ets/View.ts +70 -70
  43. package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +42 -42
  44. package/harmony/gesture_handler/src/main/ets/pages/Index.ets +16 -16
  45. package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
  46. package/harmony/gesture_handler/src/main/module.json5 +6 -6
  47. package/harmony/gesture_handler/src/main/resources/base/element/color.json +7 -7
  48. package/harmony/gesture_handler/src/main/resources/base/element/string.json +15 -15
  49. package/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json +5 -5
  50. package/harmony/gesture_handler/src/main/resources/en_US/element/string.json +15 -15
  51. package/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json +15 -15
  52. package/harmony/gesture_handler.har +0 -0
  53. package/lib/commonjs/components/touchables/GenericTouchable.js +9 -9
  54. package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -2
  55. package/lib/commonjs/handlers/createNativeWrapper.js +6 -6
  56. package/lib/commonjs/handlers/gestures/GestureDetector.js +3 -3
  57. package/lib/module/components/touchables/GenericTouchable.js +9 -9
  58. package/lib/module/components/touchables/TouchableOpacity.js +2 -2
  59. package/lib/module/handlers/createNativeWrapper.js +6 -6
  60. package/lib/module/handlers/gestures/GestureDetector.js +3 -3
  61. package/package.json +70 -70
  62. package/src/RNGestureHandlerModule.ts +6 -6
  63. package/src/components/GestureButtons.tsx +334 -334
  64. package/src/components/GestureHandlerButton.tsx +5 -5
  65. package/src/components/GestureHandlerRootView.tsx +34 -34
  66. package/src/components/RNGestureHandlerButton.tsx +23 -23
  67. package/src/components/touchables/GenericTouchable.tsx +301 -301
  68. package/src/components/touchables/TouchableOpacity.tsx +76 -76
  69. package/src/components/touchables/TouchableWithoutFeedback.tsx +14 -14
  70. package/src/components/touchables/index.ts +7 -7
  71. package/src/handlers/NativeViewGestureHandler.ts +55 -55
  72. package/src/handlers/PanGestureHandler.ts +327 -327
  73. package/src/handlers/TapGestureHandler.ts +95 -95
  74. package/src/handlers/createHandler.tsx +535 -535
  75. package/src/handlers/createNativeWrapper.tsx +81 -81
  76. package/src/handlers/gestureHandlerCommon.ts +15 -15
  77. package/src/handlers/gestures/GestureDetector.tsx +823 -823
  78. package/src/index.ts +172 -172
  79. 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
- export type RNGestureHandlerRootViewDescriptor = Descriptor<"RNGestureHandlerRootView">
7
-
8
- @Component
9
- export struct RNGestureHandlerRootView {
10
- /**
11
- * @deprecated: Use RNGestureHandlerRootView.NAME instead
12
- */
13
- static readonly DESCRIPTOR_TYPE = "RNGestureHandlerRootView"
14
- static readonly NAME = "RNGestureHandlerRootView"
15
- ctx!: RNOHContext
16
- tag: number = -1
17
- @BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
18
- @State descriptor: RNGestureHandlerRootViewDescriptor = {} as RNGestureHandlerRootViewDescriptor
19
- private unsubscribes: (() => void)[] = []
20
- private touchHandler: RNGHRootTouchHandler | undefined = undefined
21
-
22
- aboutToAppear() {
23
- const rnGestureHandlerModule = this.ctx.rnInstance.getTurboModule<RNGestureHandlerModule>(RNGestureHandlerModule.NAME)
24
- const rootTag = this.ctx.descriptorRegistry.getDescriptorLineage(this.tag)[0].tag
25
- this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry(), rnGestureHandlerModule.getGestureHandlerRegistry(), rnGestureHandlerModule.getLogger())
26
- this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerRootViewDescriptor>(this.tag))
27
- this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
28
- this.handleDescriptorChange(d as RNGestureHandlerRootViewDescriptor)
29
- }))
30
- }
31
-
32
- aboutToDisappear() {
33
- this.unsubscribes.forEach(unsubscribe => unsubscribe())
34
- }
35
-
36
- handleDescriptorChange(newDescriptor: RNGestureHandlerRootViewDescriptor) {
37
- this.descriptor = newDescriptor
38
- }
39
-
40
- build() {
41
- RNViewBase({ ctx: this.ctx, tag: this.tag }) {
42
- ForEach(this.descriptor.childrenTags, (childrenTag: Tag) => {
43
- RNComponentFactory({ ctx: this.ctx, tag: childrenTag, buildCustomComponent: this.buildCustomComponent })
44
- })
45
- Stack() {
46
- }
47
- .width("100%")
48
- .height("100%")
49
- .onTouch((e) => {
50
- this.touchHandler?.handleTouch(e)
51
- })
52
- .hitTestBehavior(HitTestMode.Transparent)
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
  }