react-native-gesture-handler 1.10.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -8
- package/android/build.gradle +49 -1
- package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- package/android/gradle.properties +19 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +744 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +596 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +292 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +90 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +81 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
- package/ios/Handlers/RNFlingHandler.m +78 -5
- package/ios/Handlers/RNForceTouchHandler.m +29 -4
- package/ios/Handlers/RNLongPressHandler.m +105 -3
- package/ios/Handlers/RNManualHandler.h +4 -0
- package/ios/Handlers/RNManualHandler.m +73 -0
- package/ios/Handlers/RNNativeViewHandler.m +30 -2
- package/ios/Handlers/RNPanHandler.m +64 -4
- package/ios/Handlers/RNPinchHandler.m +61 -2
- package/ios/Handlers/RNRotationHandler.m +60 -1
- package/ios/Handlers/RNTapHandler.m +55 -8
- package/ios/RNGestureHandler.h +18 -4
- package/ios/RNGestureHandler.m +123 -13
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/RNGestureHandlerEvents.h +9 -0
- package/ios/RNGestureHandlerEvents.m +34 -0
- package/ios/RNGestureHandlerManager.h +7 -0
- package/ios/RNGestureHandlerManager.m +62 -34
- package/ios/RNGestureHandlerModule.m +39 -3
- package/ios/RNGestureHandlerPointerTracker.h +25 -0
- package/ios/RNGestureHandlerPointerTracker.m +237 -0
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/RNManualActivationRecognizer.h +10 -0
- package/ios/RNManualActivationRecognizer.m +80 -0
- package/ios/RNRootViewGestureRecognizer.m +1 -1
- package/ios/RNTouchEventType.h +9 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +11 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +41 -37
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +31 -12
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +10 -6
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +65 -84
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +193 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +31 -0
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
- package/lib/commonjs/index.js +40 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +31 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/Errors.js +1 -1
- package/lib/commonjs/web/Errors.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -6
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/NodeManager.js +8 -2
- package/lib/commonjs/web/NodeManager.js.map +1 -1
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +2 -14
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -1
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -1
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +2 -2
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +43 -40
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js +29 -11
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/Swipeable.js +9 -6
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -1
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/gestureHandlerRootHOC.js +1 -1
- package/lib/module/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js +10 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js +10 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +106 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -0
- package/lib/module/handlers/PinchGestureHandler.js +9 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/module/handlers/RotationGestureHandler.js +9 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/module/handlers/TapGestureHandler.js +10 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +55 -77
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +402 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +120 -0
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/module/handlers/gestures/flingGesture.js +24 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +175 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +79 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/module/handlers/gestures/longPressGesture.js +24 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/module/handlers/gestures/manualGesture.js +22 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/module/handlers/gestures/nativeGesture.js +24 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/handlers/gestures/panGesture.js +135 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +36 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/module/handlers/gestures/rotationGesture.js +36 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/module/handlers/gestures/tapGesture.js +49 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +16 -0
- package/lib/module/handlers/handlersRegistry.js.map +1 -0
- package/lib/module/index.js +11 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +31 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/Errors.js +1 -1
- package/lib/module/web/Errors.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -6
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/module/web/NodeManager.js +8 -2
- package/lib/module/web/NodeManager.js.map +1 -1
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +50 -1
- package/lib/typescript/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +8 -35
- package/lib/typescript/components/Swipeable.d.ts +73 -6
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
- package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
- package/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
- package/lib/typescript/index.d.ts +29 -2
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +21 -2
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
- package/package.json +8 -5
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/RNGestureHandlerModule.ts +5 -1
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +114 -41
- package/src/components/GestureButtons.tsx +45 -5
- package/src/components/GestureComponents.tsx +47 -41
- package/src/components/Swipeable.tsx +108 -21
- package/src/components/touchables/GenericTouchable.tsx +2 -1
- package/src/components/touchables/TouchableOpacity.tsx +1 -1
- package/src/handlers/FlingGestureHandler.ts +57 -0
- package/src/handlers/ForceTouchGestureHandler.ts +83 -0
- package/src/handlers/LongPressGestureHandler.ts +84 -0
- package/src/handlers/NativeViewGestureHandler.ts +31 -7
- package/src/handlers/PanGestureHandler.ts +321 -0
- package/src/handlers/PinchGestureHandler.ts +46 -0
- package/src/handlers/RotationGestureHandler.ts +46 -0
- package/src/handlers/TapGestureHandler.ts +90 -0
- package/src/handlers/createHandler.ts +67 -79
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +519 -0
- package/src/handlers/gestures/eventReceiver.ts +151 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +74 -0
- package/src/handlers/gestures/gesture.ts +292 -0
- package/src/handlers/gestures/gestureComposition.ts +109 -0
- package/src/handlers/gestures/gestureObjects.ts +79 -0
- package/src/handlers/gestures/gestureStateManager.ts +60 -0
- package/src/handlers/gestures/longPressGesture.ts +27 -0
- package/src/handlers/gestures/manualGesture.ts +31 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +147 -0
- package/src/handlers/gestures/pinchGesture.ts +51 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +51 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +57 -17
- package/src/init.ts +5 -0
- package/src/mocks.ts +42 -2
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +1 -2
- package/src/web/NodeManager.ts +5 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
- package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
- package/lib/commonjs/handlers/gestureHandlers.js +0 -236
- package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
- package/lib/module/handlers/gestureHandlers.js +0 -216
- package/lib/module/handlers/gestureHandlers.js.map +0 -1
- package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
- package/src/handlers/gestureHandlers.ts +0 -511
@@ -1,10 +1,10 @@
|
|
1
1
|
// This component is based on RN's DrawerLayoutAndroid API
|
2
2
|
//
|
3
|
-
// It perhaps deserves to be put in a separate repo, but since it relies
|
4
|
-
//
|
5
|
-
//
|
6
|
-
//
|
7
|
-
//
|
3
|
+
// It perhaps deserves to be put in a separate repo, but since it relies on
|
4
|
+
// react-native-gesture-handler library which isn't very popular at the moment I
|
5
|
+
// decided to keep it here for the time being. It will allow us to move faster
|
6
|
+
// and fix issues that may arise in gesture handler library that could be found
|
7
|
+
// when using the drawer component
|
8
8
|
|
9
9
|
import * as React from 'react';
|
10
10
|
import { Component } from 'react';
|
@@ -25,12 +25,16 @@ import {
|
|
25
25
|
|
26
26
|
import {
|
27
27
|
GestureEvent,
|
28
|
+
HandlerStateChangeEvent,
|
29
|
+
} from '../handlers/gestureHandlerCommon';
|
30
|
+
import {
|
28
31
|
PanGestureHandler,
|
29
32
|
PanGestureHandlerEventPayload,
|
33
|
+
} from '../handlers/PanGestureHandler';
|
34
|
+
import {
|
30
35
|
TapGestureHandler,
|
31
|
-
HandlerStateChangeEvent,
|
32
36
|
TapGestureHandlerEventPayload,
|
33
|
-
} from '../handlers/
|
37
|
+
} from '../handlers/TapGestureHandler';
|
34
38
|
import { State } from '../State';
|
35
39
|
|
36
40
|
const DRAG_TOSS = 0.05;
|
@@ -50,16 +54,42 @@ export type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
|
|
50
54
|
export type DrawerKeyboardDismissMode = 'none' | 'on-drag';
|
51
55
|
|
52
56
|
export interface DrawerLayoutProps {
|
57
|
+
/**
|
58
|
+
* This attribute is present in the standard implementation already and is one
|
59
|
+
* of the required params. Gesture handler version of DrawerLayout make it
|
60
|
+
* possible for the function passed as `renderNavigationView` to take an
|
61
|
+
* Animated value as a parameter that indicates the progress of drawer
|
62
|
+
* opening/closing animation (progress value is 0 when closed and 1 when
|
63
|
+
* opened). This can be used by the drawer component to animated its children
|
64
|
+
* while the drawer is opening or closing.
|
65
|
+
*/
|
53
66
|
renderNavigationView: (
|
54
67
|
progressAnimatedValue: Animated.Value
|
55
68
|
) => React.ReactNode;
|
69
|
+
|
56
70
|
drawerPosition?: DrawerPosition;
|
71
|
+
|
57
72
|
drawerWidth?: number;
|
73
|
+
|
58
74
|
drawerBackgroundColor?: string;
|
75
|
+
|
59
76
|
drawerLockMode?: DrawerLockMode;
|
77
|
+
|
60
78
|
keyboardDismissMode?: DrawerKeyboardDismissMode;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Called when the drawer is closed.
|
82
|
+
*/
|
61
83
|
onDrawerClose?: () => void;
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Called when the drawer is opened.
|
87
|
+
*/
|
62
88
|
onDrawerOpen?: () => void;
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Called when the status of the drawer changes.
|
92
|
+
*/
|
63
93
|
onDrawerStateChanged?: (
|
64
94
|
newState: DrawerState,
|
65
95
|
drawerWillShow: boolean
|
@@ -67,15 +97,56 @@ export interface DrawerLayoutProps {
|
|
67
97
|
useNativeAnimations?: boolean;
|
68
98
|
|
69
99
|
drawerType?: DrawerType;
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Defines how far from the edge of the content view the gesture should
|
103
|
+
* activate.
|
104
|
+
*/
|
70
105
|
edgeWidth?: number;
|
106
|
+
|
71
107
|
minSwipeDistance?: number;
|
108
|
+
|
109
|
+
/**
|
110
|
+
* When set to true Drawer component will use
|
111
|
+
* {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS
|
112
|
+
* status bar whenever the drawer is pulled or when its in an "open" state.
|
113
|
+
*/
|
72
114
|
hideStatusBar?: boolean;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @default 'slide'
|
118
|
+
*
|
119
|
+
* Can be used when hideStatusBar is set to true and will select the animation
|
120
|
+
* used for hiding/showing the status bar. See
|
121
|
+
* {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for
|
122
|
+
* more details
|
123
|
+
*/
|
73
124
|
statusBarAnimation?: StatusBarAnimation;
|
125
|
+
|
126
|
+
/**
|
127
|
+
* @default black
|
128
|
+
*
|
129
|
+
* Color of a semi-transparent overlay to be displayed on top of the content
|
130
|
+
* view when drawer gets open. A solid color should be used as the opacity is
|
131
|
+
* added by the Drawer itself and the opacity of the overlay is animated (from
|
132
|
+
* 0% to 70%).
|
133
|
+
*/
|
74
134
|
overlayColor?: string;
|
135
|
+
|
75
136
|
contentContainerStyle?: StyleProp<ViewStyle>;
|
137
|
+
|
76
138
|
drawerContainerStyle?: StyleProp<ViewStyle>;
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Enables two-finger gestures on supported devices, for example iPads with
|
142
|
+
* trackpads. If not enabled the gesture will require click + drag, with
|
143
|
+
* `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger
|
144
|
+
* the gesture.
|
145
|
+
*/
|
77
146
|
enableTrackpadTwoFingerGesture?: boolean;
|
147
|
+
|
78
148
|
onDrawerSlide?: (position: number) => void;
|
149
|
+
|
79
150
|
onGestureRef?: (ref: PanGestureHandler) => void;
|
80
151
|
}
|
81
152
|
|
@@ -168,13 +239,12 @@ export default class DrawerLayout extends Component<
|
|
168
239
|
let touchX = touchXValue;
|
169
240
|
|
170
241
|
if (drawerPosition !== 'left') {
|
171
|
-
// Most of the code is written in a way to handle left-side drawer.
|
172
|
-
//
|
173
|
-
//
|
174
|
-
//
|
175
|
-
//
|
176
|
-
//
|
177
|
-
// is simply 0)
|
242
|
+
// Most of the code is written in a way to handle left-side drawer. In
|
243
|
+
// order to handle right-side drawer the only thing we need to do is to
|
244
|
+
// reverse events coming from gesture handler in a way they emulate
|
245
|
+
// left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is
|
246
|
+
// calulcated by subtracing real touchX from the width of the container
|
247
|
+
// (such that when touch happens at the right edge the value is simply 0)
|
178
248
|
dragX = Animated.multiply(
|
179
249
|
new Animated.Value(-1),
|
180
250
|
dragXValue
|
@@ -204,11 +274,12 @@ export default class DrawerLayout extends Component<
|
|
204
274
|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
205
275
|
// +---------------+ +---------------+ +---------------+ +---------------+
|
206
276
|
//
|
207
|
-
// For the above to work properly we define animated value that will keep
|
208
|
-
// of the gesture. Then we use that value to calculate how
|
209
|
-
// the dragX. If the gesture started on the
|
210
|
-
//
|
211
|
-
//
|
277
|
+
// For the above to work properly we define animated value that will keep
|
278
|
+
// start position of the gesture. Then we use that value to calculate how
|
279
|
+
// much we need to subtract from the dragX. If the gesture started on the
|
280
|
+
// greyed out area we take the distance from the edge of the drawer to the
|
281
|
+
// start position. Otherwise we don't subtract at all and the drawer be
|
282
|
+
// pulled back as soon as you start the pan.
|
212
283
|
//
|
213
284
|
// This is used only when drawerType is "front"
|
214
285
|
//
|
@@ -345,14 +416,14 @@ export default class DrawerLayout extends Component<
|
|
345
416
|
});
|
346
417
|
const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;
|
347
418
|
const fromLeft = drawerPosition === 'left';
|
348
|
-
// gestureOrientation is 1 if the expected gesture is from left to right and
|
349
|
-
// e.g. when drawer is on the left and is closed we expect left
|
350
|
-
// orientation will be 1.
|
419
|
+
// gestureOrientation is 1 if the expected gesture is from left to right and
|
420
|
+
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
|
421
|
+
// to right gesture, thus orientation will be 1.
|
351
422
|
const gestureOrientation =
|
352
423
|
(fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);
|
353
|
-
// When drawer is closed we want the hitSlop to be horizontally shorter
|
354
|
-
//
|
355
|
-
//
|
424
|
+
// When drawer is closed we want the hitSlop to be horizontally shorter than
|
425
|
+
// the container size by the value of SLOP. This will make it only activate
|
426
|
+
// when gesture happens not further than SLOP away from the edge
|
356
427
|
const hitSlop = fromLeft
|
357
428
|
? { left: 0, width: showing ? undefined : edgeWidth }
|
358
429
|
: { right: 0, width: showing ? undefined : edgeWidth };
|
@@ -377,10 +448,10 @@ export default class DrawerLayout extends Component<
|
|
377
448
|
if (fromValue != null) {
|
378
449
|
let nextFramePosition = fromValue;
|
379
450
|
if (this.props.useNativeAnimations) {
|
380
|
-
// When using native driver, we predict the next position of the
|
381
|
-
// because it takes one frame of a roundtrip to pass RELEASE
|
382
|
-
// native driver to JS before we can start animating. Without
|
383
|
-
// noticable that the frame is dropped.
|
451
|
+
// When using native driver, we predict the next position of the
|
452
|
+
// animation because it takes one frame of a roundtrip to pass RELEASE
|
453
|
+
// event from native driver to JS before we can start animating. Without
|
454
|
+
// it, it is more noticable that the frame is dropped.
|
384
455
|
if (fromValue < toValue && velocity > 0) {
|
385
456
|
nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);
|
386
457
|
} else if (fromValue > toValue && velocity < 0) {
|
@@ -422,7 +493,8 @@ export default class DrawerLayout extends Component<
|
|
422
493
|
options.velocity ? options.velocity : 0
|
423
494
|
);
|
424
495
|
|
425
|
-
// We need to force the update, otherwise the overlay is not rerendered and
|
496
|
+
// We need to force the update, otherwise the overlay is not rerendered and
|
497
|
+
// it would not be clickable
|
426
498
|
this.forceUpdate();
|
427
499
|
};
|
428
500
|
|
@@ -430,7 +502,8 @@ export default class DrawerLayout extends Component<
|
|
430
502
|
// TODO: decide if it should be null or undefined is the proper value
|
431
503
|
this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0);
|
432
504
|
|
433
|
-
// We need to force the update, otherwise the overlay is not rerendered and
|
505
|
+
// We need to force the update, otherwise the overlay is not rerendered and
|
506
|
+
// it would be still clickable
|
434
507
|
this.forceUpdate();
|
435
508
|
};
|
436
509
|
|
@@ -474,8 +547,8 @@ export default class DrawerLayout extends Component<
|
|
474
547
|
|
475
548
|
// we rely on row and row-reverse flex directions to position the drawer
|
476
549
|
// properly. Apparently for RTL these are flipped which requires us to use
|
477
|
-
// the opposite setting for the drawer to appear from left or right
|
478
|
-
// to the drawerPosition prop
|
550
|
+
// the opposite setting for the drawer to appear from left or right
|
551
|
+
// according to the drawerPosition prop
|
479
552
|
const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;
|
480
553
|
|
481
554
|
const dynamicDrawerStyles = {
|
@@ -546,8 +619,8 @@ export default class DrawerLayout extends Component<
|
|
546
619
|
};
|
547
620
|
|
548
621
|
private setPanGestureRef = (ref: PanGestureHandler) => {
|
549
|
-
// TODO(TS): make sure it is OK
|
550
|
-
//
|
622
|
+
// TODO(TS): make sure it is OK taken from
|
623
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842
|
551
624
|
(this
|
552
625
|
.panGestureHandler as React.MutableRefObject<PanGestureHandler>).current = ref;
|
553
626
|
this.props.onGestureRef?.(ref);
|
@@ -563,15 +636,15 @@ export default class DrawerLayout extends Component<
|
|
563
636
|
|
564
637
|
const fromLeft = drawerPosition === 'left';
|
565
638
|
|
566
|
-
// gestureOrientation is 1 if the expected gesture is from left to right and
|
567
|
-
// e.g. when drawer is on the left and is closed we expect left
|
568
|
-
// orientation will be 1.
|
639
|
+
// gestureOrientation is 1 if the expected gesture is from left to right and
|
640
|
+
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
|
641
|
+
// to right gesture, thus orientation will be 1.
|
569
642
|
const gestureOrientation =
|
570
643
|
(fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);
|
571
644
|
|
572
|
-
// When drawer is closed we want the hitSlop to be horizontally shorter
|
573
|
-
//
|
574
|
-
//
|
645
|
+
// When drawer is closed we want the hitSlop to be horizontally shorter than
|
646
|
+
// the container size by the value of SLOP. This will make it only activate
|
647
|
+
// when gesture happens not further than SLOP away from the edge
|
575
648
|
const hitSlop = fromLeft
|
576
649
|
? { left: 0, width: this.drawerShown ? undefined : edgeWidth }
|
577
650
|
: { right: 0, width: this.drawerShown ? undefined : edgeWidth };
|
@@ -15,32 +15,72 @@ import { State } from '../State';
|
|
15
15
|
import {
|
16
16
|
GestureEvent,
|
17
17
|
HandlerStateChangeEvent,
|
18
|
-
} from '../handlers/
|
18
|
+
} from '../handlers/gestureHandlerCommon';
|
19
19
|
import {
|
20
20
|
NativeViewGestureHandlerPayload,
|
21
21
|
NativeViewGestureHandlerProps,
|
22
22
|
} from '../handlers/NativeViewGestureHandler';
|
23
23
|
|
24
24
|
export interface RawButtonProps extends NativeViewGestureHandlerProps {
|
25
|
+
/**
|
26
|
+
* Defines if more than one button could be pressed simultaneously. By default
|
27
|
+
* set true.
|
28
|
+
*/
|
25
29
|
exclusive?: boolean;
|
26
30
|
// TODO: we should transform props in `createNativeWrapper`
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Android only.
|
34
|
+
*
|
35
|
+
* Defines color of native ripple animation used since API level 21.
|
36
|
+
*/
|
27
37
|
rippleColor?: any; // it was present in BaseButtonProps before but is used here in code
|
28
38
|
}
|
29
39
|
|
30
40
|
export interface BaseButtonProps extends RawButtonProps {
|
41
|
+
/**
|
42
|
+
* Called when the button gets pressed (analogous to `onPress` in
|
43
|
+
* `TouchableHighlight` from RN core).
|
44
|
+
*/
|
31
45
|
onPress?: (pointerInside: boolean) => void;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Called when button changes from inactive to active and vice versa. It
|
49
|
+
* passes active state as a boolean variable as a first parameter for that
|
50
|
+
* method.
|
51
|
+
*/
|
32
52
|
onActiveStateChange?: (active: boolean) => void;
|
33
53
|
style?: StyleProp<ViewStyle>;
|
34
54
|
testID?: string;
|
35
55
|
}
|
36
56
|
|
37
57
|
export interface RectButtonProps extends BaseButtonProps {
|
58
|
+
/**
|
59
|
+
* Background color that will be dimmed when button is in active state.
|
60
|
+
*/
|
38
61
|
underlayColor?: string;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* iOS only.
|
65
|
+
*
|
66
|
+
* Opacity applied to the underlay when button is in active state.
|
67
|
+
*/
|
39
68
|
activeOpacity?: number;
|
40
69
|
}
|
41
70
|
|
42
71
|
export interface BorderlessButtonProps extends BaseButtonProps {
|
72
|
+
/**
|
73
|
+
* Android only.
|
74
|
+
*
|
75
|
+
* Set this to false if you want the ripple animation to render only within view bounds.
|
76
|
+
*/
|
43
77
|
borderless?: boolean;
|
78
|
+
|
79
|
+
/**
|
80
|
+
* iOS only.
|
81
|
+
*
|
82
|
+
* Opacity applied to the button when it is in an active state.
|
83
|
+
*/
|
44
84
|
activeOpacity?: number;
|
45
85
|
}
|
46
86
|
|
@@ -79,10 +119,10 @@ export class BaseButton extends React.Component<BaseButtonProps> {
|
|
79
119
|
this.lastActive = active;
|
80
120
|
};
|
81
121
|
|
82
|
-
// Normally, the parent would execute it's handler first,
|
83
|
-
//
|
84
|
-
//
|
85
|
-
//
|
122
|
+
// Normally, the parent would execute it's handler first, then forward the
|
123
|
+
// event to listeners. However, here our handler is virtually only forwarding
|
124
|
+
// events to listeners, so we reverse the order to keep the proper order of
|
125
|
+
// the callbacks (from "raw" ones to "processed").
|
86
126
|
private onHandlerStateChange = (
|
87
127
|
e: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>
|
88
128
|
) => {
|
@@ -1,5 +1,10 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
PropsWithChildren,
|
4
|
+
ForwardedRef,
|
5
|
+
RefAttributes,
|
6
|
+
ReactElement,
|
7
|
+
} from 'react';
|
3
8
|
import {
|
4
9
|
ScrollView as RNScrollView,
|
5
10
|
ScrollViewProps as RNScrollViewProps,
|
@@ -15,7 +20,10 @@ import {
|
|
15
20
|
|
16
21
|
import createNativeWrapper from '../handlers/createNativeWrapper';
|
17
22
|
|
18
|
-
import {
|
23
|
+
import {
|
24
|
+
NativeViewGestureHandlerProps,
|
25
|
+
nativeViewProps,
|
26
|
+
} from '../handlers/NativeViewGestureHandler';
|
19
27
|
|
20
28
|
export const ScrollView = createNativeWrapper<
|
21
29
|
PropsWithChildren<RNScrollViewProps>
|
@@ -24,15 +32,9 @@ export const ScrollView = createNativeWrapper<
|
|
24
32
|
shouldCancelWhenOutside: false,
|
25
33
|
});
|
26
34
|
// backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457
|
35
|
+
// include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them.
|
27
36
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
28
|
-
export type ScrollView = typeof ScrollView &
|
29
|
-
scrollTo(
|
30
|
-
y?: number | { x?: number; y?: number; animated?: boolean },
|
31
|
-
x?: number,
|
32
|
-
animated?: boolean
|
33
|
-
): void;
|
34
|
-
scrollToEnd(options?: { animated: boolean }): void;
|
35
|
-
};
|
37
|
+
export type ScrollView = typeof ScrollView & RNScrollView;
|
36
38
|
|
37
39
|
export const Switch = createNativeWrapper<RNSwitchProps>(RNSwitch, {
|
38
40
|
shouldCancelWhenOutside: false,
|
@@ -40,47 +42,51 @@ export const Switch = createNativeWrapper<RNSwitchProps>(RNSwitch, {
|
|
40
42
|
disallowInterruption: true,
|
41
43
|
});
|
42
44
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
43
|
-
export type Switch = typeof Switch;
|
45
|
+
export type Switch = typeof Switch & RNSwitch;
|
44
46
|
|
45
47
|
export const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);
|
46
48
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
47
|
-
export type TextInput = typeof TextInput;
|
49
|
+
export type TextInput = typeof TextInput & RNTextInput;
|
48
50
|
|
49
51
|
export const DrawerLayoutAndroid = createNativeWrapper<
|
50
52
|
PropsWithChildren<RNDrawerLayoutAndroidProps>
|
51
53
|
>(RNDrawerLayoutAndroid, { disallowInterruption: true });
|
52
|
-
// we use literal object since TS gives error when using RN's `positions`
|
53
|
-
// @ts-ignore FIXME(TS) maybe this should be removed?
|
54
|
-
DrawerLayoutAndroid.positions = { Left: 'left', Right: 'right' };
|
55
54
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
56
|
-
export type DrawerLayoutAndroid = typeof DrawerLayoutAndroid
|
55
|
+
export type DrawerLayoutAndroid = typeof DrawerLayoutAndroid &
|
56
|
+
RNDrawerLayoutAndroid;
|
57
57
|
|
58
|
-
export const FlatList = React.forwardRef
|
59
|
-
|
58
|
+
export const FlatList = React.forwardRef((props, ref) => {
|
59
|
+
const flatListProps = {};
|
60
|
+
const scrollViewProps = {};
|
61
|
+
for (const [propName, value] of Object.entries(props)) {
|
62
|
+
// https://github.com/microsoft/TypeScript/issues/26255
|
63
|
+
if ((nativeViewProps as readonly string[]).includes(propName)) {
|
64
|
+
// @ts-ignore - this function cannot have generic type so we have to ignore this error
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
66
|
+
scrollViewProps[propName] = value;
|
67
|
+
} else {
|
68
|
+
// @ts-ignore - this function cannot have generic type so we have to ignore this error
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
70
|
+
flatListProps[propName] = value;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return (
|
74
|
+
// @ts-ignore - this function cannot have generic type so we have to ignore this error
|
60
75
|
<RNFlatList
|
61
76
|
ref={ref}
|
62
|
-
{...
|
63
|
-
renderScrollComponent={(scrollProps) =>
|
77
|
+
{...flatListProps}
|
78
|
+
renderScrollComponent={(scrollProps) => (
|
79
|
+
<ScrollView {...{ ...scrollProps, ...scrollViewProps }} />
|
80
|
+
)}
|
64
81
|
/>
|
65
|
-
)
|
66
|
-
)
|
82
|
+
);
|
83
|
+
}) as <ItemT = any>(
|
84
|
+
props: PropsWithChildren<
|
85
|
+
RNFlatListProps<ItemT> &
|
86
|
+
RefAttributes<FlatList<ItemT>> &
|
87
|
+
NativeViewGestureHandlerProps
|
88
|
+
>,
|
89
|
+
ref: ForwardedRef<FlatList<ItemT>>
|
90
|
+
) => ReactElement | null;
|
67
91
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
68
|
-
export type FlatList<ItemT> =
|
69
|
-
RNFlatListProps<ItemT> &
|
70
|
-
NativeViewGestureHandlerProps &
|
71
|
-
React.RefAttributes<any>
|
72
|
-
> & {
|
73
|
-
scrollToEnd: (params?: { animated?: boolean }) => void;
|
74
|
-
scrollToIndex: (params: {
|
75
|
-
animated?: boolean;
|
76
|
-
index: number;
|
77
|
-
viewOffset?: number;
|
78
|
-
viewPosition?: number;
|
79
|
-
}) => void;
|
80
|
-
scrollToItem: (params: {
|
81
|
-
animated?: boolean;
|
82
|
-
item: ItemT;
|
83
|
-
viewPosition?: number;
|
84
|
-
}) => void;
|
85
|
-
scrollToOffset: (params: { animated?: boolean; offset: number }) => void;
|
86
|
-
};
|
92
|
+
export type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Similarily to the DrawerLayout component this deserves to be put in a
|
2
|
-
// separate repo. Although, keeping it here for the time being will allow us
|
3
|
-
//
|
2
|
+
// separate repo. Although, keeping it here for the time being will allow us to
|
3
|
+
// move faster and fix possible issues quicker
|
4
4
|
|
5
5
|
import * as React from 'react';
|
6
6
|
import { Component } from 'react';
|
@@ -15,14 +15,18 @@ import {
|
|
15
15
|
} from 'react-native';
|
16
16
|
|
17
17
|
import {
|
18
|
-
PanGestureHandler,
|
19
|
-
TapGestureHandler,
|
20
|
-
PanGestureHandlerProps,
|
21
18
|
GestureEvent,
|
22
|
-
PanGestureHandlerEventPayload,
|
23
19
|
HandlerStateChangeEvent,
|
20
|
+
} from '../handlers/gestureHandlerCommon';
|
21
|
+
import {
|
22
|
+
PanGestureHandler,
|
23
|
+
PanGestureHandlerEventPayload,
|
24
|
+
PanGestureHandlerProps,
|
25
|
+
} from '../handlers/PanGestureHandler';
|
26
|
+
import {
|
27
|
+
TapGestureHandler,
|
24
28
|
TapGestureHandlerEventPayload,
|
25
|
-
} from '../handlers/
|
29
|
+
} from '../handlers/TapGestureHandler';
|
26
30
|
import { State } from '../State';
|
27
31
|
|
28
32
|
const DRAG_TOSS = 0.05;
|
@@ -32,30 +36,105 @@ type SwipeableExcludes = Exclude<
|
|
32
36
|
'onGestureEvent' | 'onHandlerStateChange'
|
33
37
|
>;
|
34
38
|
|
35
|
-
interface SwipeableProps
|
39
|
+
export interface SwipeableProps
|
36
40
|
extends Pick<PanGestureHandlerProps, SwipeableExcludes> {
|
41
|
+
/**
|
42
|
+
* Enables two-finger gestures on supported devices, for example iPads with
|
43
|
+
* trackpads. If not enabled the gesture will require click + drag, with
|
44
|
+
* `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger
|
45
|
+
* the gesture.
|
46
|
+
*/
|
37
47
|
enableTrackpadTwoFingerGesture?: boolean;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Specifies how much the visual interaction will be delayed compared to the
|
51
|
+
* gesture distance. e.g. value of 1 will indicate that the swipeable panel
|
52
|
+
* should exactly follow the gesture, 2 means it is going to be two times
|
53
|
+
* "slower".
|
54
|
+
*/
|
38
55
|
friction?: number;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Distance from the left edge at which released panel will animate to the
|
59
|
+
* open state (or the open panel will animate into the closed state). By
|
60
|
+
* default it's a half of the panel's width.
|
61
|
+
*/
|
39
62
|
leftThreshold?: number;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Distance from the right edge at which released panel will animate to the
|
66
|
+
* open state (or the open panel will animate into the closed state). By
|
67
|
+
* default it's a half of the panel's width.
|
68
|
+
*/
|
40
69
|
rightThreshold?: number;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Value indicating if the swipeable panel can be pulled further than the left
|
73
|
+
* actions panel's width. It is set to true by default as long as the left
|
74
|
+
* panel render method is present.
|
75
|
+
*/
|
41
76
|
overshootLeft?: boolean;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Value indicating if the swipeable panel can be pulled further than the
|
80
|
+
* right actions panel's width. It is set to true by default as long as the
|
81
|
+
* right panel render method is present.
|
82
|
+
*/
|
42
83
|
overshootRight?: boolean;
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Specifies how much the visual interaction will be delayed compared to the
|
87
|
+
* gesture distance at overshoot. Default value is 1, it mean no friction, for
|
88
|
+
* a native feel, try 8 or above.
|
89
|
+
*/
|
43
90
|
overshootFriction?: number;
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Called when left action panel gets open.
|
94
|
+
*/
|
44
95
|
onSwipeableLeftOpen?: () => void;
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Called when right action panel gets open.
|
99
|
+
*/
|
45
100
|
onSwipeableRightOpen?: () => void;
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Called when action panel gets open (either right or left).
|
104
|
+
*/
|
46
105
|
onSwipeableOpen?: () => void;
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Called when action panel is closed.
|
109
|
+
*/
|
47
110
|
onSwipeableClose?: () => void;
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Called when left action panel starts animating on open.
|
114
|
+
*/
|
48
115
|
onSwipeableLeftWillOpen?: () => void;
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Called when right action panel starts animating on open.
|
119
|
+
*/
|
49
120
|
onSwipeableRightWillOpen?: () => void;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Called when action panel starts animating on open (either right or left).
|
124
|
+
*/
|
50
125
|
onSwipeableWillOpen?: () => void;
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Called when action panel starts animating on close.
|
129
|
+
*/
|
51
130
|
onSwipeableWillClose?: () => void;
|
131
|
+
|
52
132
|
/**
|
53
133
|
*
|
54
134
|
* This map describes the values to use as inputRange for extra interpolation:
|
55
135
|
* AnimatedValue: [startValue, endValue]
|
56
136
|
*
|
57
|
-
* progressAnimatedValue: [0, 1]
|
58
|
-
* dragAnimatedValue: [0, +]
|
137
|
+
* progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]
|
59
138
|
*
|
60
139
|
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
61
140
|
* */
|
@@ -68,8 +147,7 @@ interface SwipeableProps
|
|
68
147
|
* This map describes the values to use as inputRange for extra interpolation:
|
69
148
|
* AnimatedValue: [startValue, endValue]
|
70
149
|
*
|
71
|
-
* progressAnimatedValue: [0, 1]
|
72
|
-
* dragAnimatedValue: [0, -]
|
150
|
+
* progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]
|
73
151
|
*
|
74
152
|
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
75
153
|
* */
|
@@ -77,9 +155,21 @@ interface SwipeableProps
|
|
77
155
|
progressAnimatedValue: Animated.AnimatedInterpolation,
|
78
156
|
dragAnimatedValue: Animated.AnimatedInterpolation
|
79
157
|
) => React.ReactNode;
|
158
|
+
|
80
159
|
useNativeAnimations?: boolean;
|
160
|
+
|
81
161
|
animationOptions?: Record<string, unknown>;
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Style object for the container (`Animated.View`), for example to override
|
165
|
+
* `overflow: 'hidden'`.
|
166
|
+
*/
|
82
167
|
containerStyle?: StyleProp<ViewStyle>;
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Style object for the children container (`Animated.View`), for example to
|
171
|
+
* apply `flex: 1`
|
172
|
+
*/
|
83
173
|
childrenContainerStyle?: StyleProp<ViewStyle>;
|
84
174
|
}
|
85
175
|
|
@@ -165,17 +255,12 @@ export default class Swipeable extends Component<
|
|
165
255
|
outputRange: [0, 1],
|
166
256
|
})
|
167
257
|
).interpolate({
|
168
|
-
inputRange: [
|
169
|
-
-rightWidth - (overshootRight ? 1 : overshootFriction!),
|
170
|
-
-rightWidth,
|
171
|
-
leftWidth,
|
172
|
-
leftWidth + (overshootLeft ? 1 : overshootFriction!),
|
173
|
-
],
|
258
|
+
inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],
|
174
259
|
outputRange: [
|
175
|
-
-rightWidth - (overshootRight
|
260
|
+
-rightWidth - (overshootRight ? 1 / overshootFriction! : 0),
|
176
261
|
-rightWidth,
|
177
262
|
leftWidth,
|
178
|
-
leftWidth + (overshootLeft
|
263
|
+
leftWidth + (overshootLeft ? 1 / overshootFriction! : 0),
|
179
264
|
],
|
180
265
|
});
|
181
266
|
this.transX = transX;
|
@@ -350,7 +435,9 @@ export default class Swipeable extends Component<
|
|
350
435
|
<Animated.View
|
351
436
|
style={[
|
352
437
|
styles.leftActions,
|
353
|
-
// all those and below parameters can have ! since they are all
|
438
|
+
// all those and below parameters can have ! since they are all
|
439
|
+
// asigned in constructor in `updateAnimatedEvent` but TS cannot spot
|
440
|
+
// it for some reason
|
354
441
|
{ transform: [{ translateX: this.leftActionTranslate! }] },
|
355
442
|
]}>
|
356
443
|
{renderLeftActions(this.showLeftAction!, this.transX!)}
|