react-native-gesture-handler 1.10.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/DrawerLayout/package.json +3 -3
- package/README.md +7 -6
- package/Swipeable/package.json +3 -3
- package/android/build.gradle +48 -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 +713 -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 +562 -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 +289 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +88 -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 +79 -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/jestSetup.js +7 -1
- package/lib/commonjs/Directions.js +15 -0
- package/lib/commonjs/Directions.js.map +1 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +24 -0
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.js +20 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/PlatformConstants.js +15 -0
- package/lib/commonjs/PlatformConstants.js.map +1 -0
- package/lib/commonjs/PlatformConstants.web.js +14 -0
- package/lib/commonjs/PlatformConstants.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +22 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js +80 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/commonjs/State.js +18 -0
- package/lib/commonjs/State.js.map +1 -0
- package/lib/commonjs/components/DrawerLayout.js +535 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js +207 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +76 -0
- package/lib/commonjs/components/GestureComponents.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.web.js +46 -0
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -0
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +365 -0
- package/lib/commonjs/components/Swipeable.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +278 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js +109 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +100 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +12 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js +75 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +26 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/index.js +40 -0
- package/lib/commonjs/components/touchables/index.js.map +1 -0
- package/lib/commonjs/gestureHandlerRootHOC.js +39 -0
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -0
- 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 +25 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- 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 +373 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -0
- package/lib/commonjs/handlers/createNativeWrapper.js +70 -0
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +426 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +124 -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 +39 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +185 -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 +19 -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 +116 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +19 -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 +19 -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 +338 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +64 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/typeUtils.js +2 -0
- package/lib/commonjs/typeUtils.js.map +1 -0
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js +105 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/DraggingGestureHandler.js +53 -0
- package/lib/commonjs/web/DraggingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/Errors.js +16 -0
- package/lib/commonjs/web/Errors.js.map +1 -0
- package/lib/commonjs/web/FlingGestureHandler.js +170 -0
- package/lib/commonjs/web/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/GestureHandler.js +533 -0
- package/lib/commonjs/web/GestureHandler.js.map +1 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js +54 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/LongPressGestureHandler.js +71 -0
- package/lib/commonjs/web/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js +62 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NodeManager.js +43 -0
- package/lib/commonjs/web/NodeManager.js.map +1 -0
- package/lib/commonjs/web/PanGestureHandler.js +189 -0
- package/lib/commonjs/web/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PinchGestureHandler.js +40 -0
- package/lib/commonjs/web/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PressGestureHandler.js +188 -0
- package/lib/commonjs/web/PressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/RotationGestureHandler.js +44 -0
- package/lib/commonjs/web/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/web/TapGestureHandler.js +192 -0
- package/lib/commonjs/web/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/web/constants.js +64 -0
- package/lib/commonjs/web/constants.js.map +1 -0
- package/lib/commonjs/web/utils.js +42 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/module/Directions.js +7 -0
- package/lib/module/Directions.js.map +1 -0
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +10 -0
- package/lib/module/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/GestureHandlerRootView.js +7 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -0
- package/lib/module/PlatformConstants.js +5 -0
- package/lib/module/PlatformConstants.js.map +1 -0
- package/lib/module/PlatformConstants.web.js +7 -0
- package/lib/module/PlatformConstants.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +13 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.web.js +56 -0
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/module/State.js +10 -0
- package/lib/module/State.js.map +1 -0
- package/lib/module/components/DrawerLayout.js +520 -0
- package/lib/module/components/DrawerLayout.js.map +1 -0
- package/lib/module/components/GestureButtons.js +172 -0
- package/lib/module/components/GestureButtons.js.map +1 -0
- package/lib/module/components/GestureComponents.js +53 -0
- package/lib/module/components/GestureComponents.js.map +1 -0
- package/lib/module/components/GestureComponents.web.js +25 -0
- package/lib/module/components/GestureComponents.web.js.map +1 -0
- package/{dist/src → lib/module}/components/GestureHandlerButton.js +1 -0
- package/lib/module/components/GestureHandlerButton.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.web.js +9 -0
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +347 -0
- package/lib/module/components/Swipeable.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js +262 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js +95 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +84 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/TouchableNativeFeedback.js +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js +61 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/index.js +1 -0
- package/lib/module/components/touchables/index.js.map +1 -0
- package/lib/module/gestureHandlerRootHOC.js +21 -0
- package/lib/module/gestureHandlerRootHOC.js.map +1 -0
- 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 +11 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- 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 +348 -0
- package/lib/module/handlers/createHandler.js.map +1 -0
- package/lib/module/handlers/createNativeWrapper.js +58 -0
- package/lib/module/handlers/createNativeWrapper.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +389 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +109 -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 +29 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +167 -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 +9 -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 +106 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +9 -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 +9 -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 +34 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +54 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/typeUtils.js +2 -0
- package/lib/module/typeUtils.js.map +1 -0
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/DiscreteGestureHandler.js +94 -0
- package/lib/module/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/DraggingGestureHandler.js +40 -0
- package/lib/module/web/DraggingGestureHandler.js.map +1 -0
- package/lib/module/web/Errors.js +7 -0
- package/lib/module/web/Errors.js.map +1 -0
- package/lib/module/web/FlingGestureHandler.js +156 -0
- package/lib/module/web/FlingGestureHandler.js.map +1 -0
- package/lib/module/web/GestureHandler.js +518 -0
- package/lib/module/web/GestureHandler.js.map +1 -0
- package/lib/module/web/IndiscreteGestureHandler.js +44 -0
- package/lib/module/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/LongPressGestureHandler.js +58 -0
- package/lib/module/web/LongPressGestureHandler.js.map +1 -0
- package/lib/module/web/NativeViewGestureHandler.js +45 -0
- package/lib/module/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web/NodeManager.js +30 -0
- package/lib/module/web/NodeManager.js.map +1 -0
- package/lib/module/web/PanGestureHandler.js +175 -0
- package/lib/module/web/PanGestureHandler.js.map +1 -0
- package/lib/module/web/PinchGestureHandler.js +29 -0
- package/lib/module/web/PinchGestureHandler.js.map +1 -0
- package/lib/module/web/PressGestureHandler.js +174 -0
- package/lib/module/web/PressGestureHandler.js.map +1 -0
- package/lib/module/web/RotationGestureHandler.js +32 -0
- package/lib/module/web/RotationGestureHandler.js.map +1 -0
- package/lib/module/web/TapGestureHandler.js +180 -0
- package/lib/module/web/TapGestureHandler.js.map +1 -0
- package/lib/module/web/constants.js +43 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/utils.js +19 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/typescript/Directions.d.ts +7 -0
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -0
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -0
- package/{dist/src → lib/typescript}/PlatformConstants.d.ts +0 -0
- package/{dist/src → lib/typescript}/PlatformConstants.web.d.ts +0 -0
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.d.ts +1 -8
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.web.d.ts +1 -1
- package/{dist/src → lib/typescript}/State.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/DrawerLayout.d.ts +50 -1
- package/{dist/src → lib/typescript}/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +18 -0
- package/{dist/src → lib/typescript}/components/GestureComponents.web.d.ts +4 -4
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.web.d.ts +0 -0
- package/lib/typescript/components/Swipeable.d.ts +150 -0
- package/{dist/src → lib/typescript}/components/touchables/GenericTouchable.d.ts +3 -3
- package/{dist/src → lib/typescript}/components/touchables/TouchableHighlight.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.android.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableOpacity.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableWithoutFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/index.d.ts +0 -0
- package/{dist/src → lib/typescript}/gestureHandlerRootHOC.d.ts +0 -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 +27 -0
- 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/{dist/src → lib/typescript}/handlers/createHandler.d.ts +1 -1
- package/{dist/src → lib/typescript}/handlers/createNativeWrapper.d.ts +0 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/{dist/src → 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 +10 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +93 -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 +5 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +19 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -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 +44 -0
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +43 -0
- package/{dist/src → lib/typescript}/typeUtils.d.ts +0 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/{dist/src → lib/typescript}/web/DiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/DraggingGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/Errors.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/FlingGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/GestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/IndiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/LongPressGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NativeViewGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NodeManager.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/PanGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PinchGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PressGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/RotationGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/TapGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/constants.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/utils.d.ts +0 -0
- package/package.json +38 -15
- package/src/Directions.ts +8 -2
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/PlatformConstants.ts +3 -2
- package/src/RNGestureHandlerModule.ts +15 -9
- 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 +3 -2
- 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 +60 -81
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +498 -0
- package/src/handlers/gestures/eventReceiver.ts +135 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +32 -0
- package/src/handlers/gestures/gesture.ts +279 -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 +11 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +105 -0
- package/src/handlers/gestures/pinchGesture.ts +12 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +12 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +156 -0
- package/src/init.ts +5 -0
- package/src/mocks.ts +65 -0
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +2 -3
- package/src/web/NativeViewGestureHandler.ts +1 -3
- 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/dist/index.d.ts +0 -13
- package/dist/index.js +0 -16
- package/dist/src/Directions.d.ts +0 -7
- package/dist/src/Directions.js +0 -2
- package/dist/src/GestureHandlerRootView.android.d.ts +0 -4
- package/dist/src/GestureHandlerRootView.android.expo.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.android.expo.js +0 -2
- package/dist/src/GestureHandlerRootView.android.js +0 -21
- package/dist/src/GestureHandlerRootView.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.js +0 -2
- package/dist/src/PlatformConstants.js +0 -2
- package/dist/src/PlatformConstants.web.js +0 -5
- package/dist/src/RNGestureHandlerModule.js +0 -3
- package/dist/src/RNGestureHandlerModule.web.js +0 -47
- package/dist/src/State.js +0 -9
- package/dist/src/__mocks__/RNGestureHandlerModule.d.ts +0 -23
- package/dist/src/__mocks__/RNGestureHandlerModule.js +0 -25
- package/dist/src/components/DrawerLayout.js +0 -391
- package/dist/src/components/GestureButtons.js +0 -113
- package/dist/src/components/GestureComponents.d.ts +0 -45
- package/dist/src/components/GestureComponents.js +0 -18
- package/dist/src/components/GestureComponents.web.js +0 -18
- package/dist/src/components/GestureHandlerButton.web.js +0 -3
- package/dist/src/components/Swipeable.d.ts +0 -83
- package/dist/src/components/Swipeable.js +0 -249
- package/dist/src/components/touchables/GenericTouchable.js +0 -210
- package/dist/src/components/touchables/TouchableHighlight.js +0 -73
- package/dist/src/components/touchables/TouchableNativeFeedback.android.js +0 -63
- package/dist/src/components/touchables/TouchableOpacity.js +0 -50
- package/dist/src/components/touchables/TouchableWithoutFeedback.js +0 -5
- package/dist/src/gestureHandlerRootHOC.js +0 -17
- package/dist/src/handlers/NativeViewGestureHandler.d.ts +0 -12
- package/dist/src/handlers/NativeViewGestureHandler.js +0 -13
- package/dist/src/handlers/createHandler.js +0 -292
- package/dist/src/handlers/createNativeWrapper.js +0 -51
- package/dist/src/handlers/gestureHandlerTypesCompat.js +0 -1
- package/dist/src/handlers/gestureHandlers.d.ts +0 -158
- package/dist/src/handlers/gestureHandlers.js +0 -247
- package/dist/src/typeUtils.js +0 -1
- package/dist/src/web/DiscreteGestureHandler.js +0 -48
- package/dist/src/web/DraggingGestureHandler.js +0 -25
- package/dist/src/web/Errors.js +0 -5
- package/dist/src/web/FlingGestureHandler.js +0 -119
- package/dist/src/web/GestureHandler.js +0 -413
- package/dist/src/web/IndiscreteGestureHandler.js +0 -26
- package/dist/src/web/LongPressGestureHandler.js +0 -46
- package/dist/src/web/NativeViewGestureHandler.js +0 -39
- package/dist/src/web/NodeManager.js +0 -22
- package/dist/src/web/PanGestureHandler.js +0 -145
- package/dist/src/web/PinchGestureHandler.js +0 -19
- package/dist/src/web/PressGestureHandler.js +0 -135
- package/dist/src/web/RotationGestureHandler.js +0 -20
- package/dist/src/web/TapGestureHandler.js +0 -143
- package/dist/src/web/constants.js +0 -42
- package/dist/src/web/utils.js +0 -15
- package/index.ts +0 -117
- package/src/GestureHandlerRootView.android.expo.tsx +0 -3
- package/src/__mocks__/RNGestureHandlerModule.ts +0 -27
- package/src/handlers/gestureHandlers.ts +0 -511
@@ -1,47 +0,0 @@
|
|
1
|
-
import { Direction } from './web/constants';
|
2
|
-
import FlingGestureHandler from './web/FlingGestureHandler';
|
3
|
-
import LongPressGestureHandler from './web/LongPressGestureHandler';
|
4
|
-
import NativeViewGestureHandler from './web/NativeViewGestureHandler';
|
5
|
-
import * as NodeManager from './web/NodeManager';
|
6
|
-
import PanGestureHandler from './web/PanGestureHandler';
|
7
|
-
import PinchGestureHandler from './web/PinchGestureHandler';
|
8
|
-
import RotationGestureHandler from './web/RotationGestureHandler';
|
9
|
-
import TapGestureHandler from './web/TapGestureHandler';
|
10
|
-
export const Gestures = {
|
11
|
-
PanGestureHandler,
|
12
|
-
RotationGestureHandler,
|
13
|
-
PinchGestureHandler,
|
14
|
-
TapGestureHandler,
|
15
|
-
NativeViewGestureHandler,
|
16
|
-
LongPressGestureHandler,
|
17
|
-
FlingGestureHandler,
|
18
|
-
};
|
19
|
-
export default {
|
20
|
-
Direction,
|
21
|
-
handleSetJSResponder(tag, blockNativeResponder) {
|
22
|
-
console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
|
23
|
-
},
|
24
|
-
handleClearJSResponder() {
|
25
|
-
console.warn('handleClearJSResponder: ');
|
26
|
-
},
|
27
|
-
createGestureHandler(handlerName, handlerTag, config) {
|
28
|
-
//TODO(TS) extends config
|
29
|
-
if (!(handlerName in Gestures))
|
30
|
-
throw new Error(`react-native-gesture-handler: ${handlerName} is not supported on web.`);
|
31
|
-
const GestureClass = Gestures[handlerName];
|
32
|
-
NodeManager.createGestureHandler(handlerTag, new GestureClass());
|
33
|
-
this.updateGestureHandler(handlerTag, config);
|
34
|
-
},
|
35
|
-
attachGestureHandler(handlerTag, newView, propsRef) {
|
36
|
-
NodeManager.getHandler(handlerTag).setView(newView, propsRef);
|
37
|
-
},
|
38
|
-
updateGestureHandler(handlerTag, newConfig) {
|
39
|
-
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
|
40
|
-
},
|
41
|
-
getGestureHandlerNode(handlerTag) {
|
42
|
-
return NodeManager.getHandler(handlerTag);
|
43
|
-
},
|
44
|
-
dropGestureHandler(handlerTag) {
|
45
|
-
NodeManager.dropGestureHandler(handlerTag);
|
46
|
-
},
|
47
|
-
};
|
package/dist/src/State.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import { View, ScrollView } from 'react-native';
|
2
|
-
declare const _default: {
|
3
|
-
ScrollView: typeof ScrollView;
|
4
|
-
PanGestureHandler: typeof View;
|
5
|
-
attachGestureHandler: () => void;
|
6
|
-
createGestureHandler: () => void;
|
7
|
-
dropGestureHandler: () => void;
|
8
|
-
updateGestureHandler: () => void;
|
9
|
-
Direction: {
|
10
|
-
RIGHT: number;
|
11
|
-
LEFT: number;
|
12
|
-
UP: number;
|
13
|
-
DOWN: number;
|
14
|
-
};
|
15
|
-
State: {
|
16
|
-
BEGAN: string;
|
17
|
-
FAILED: string;
|
18
|
-
ACTIVE: string;
|
19
|
-
END: string;
|
20
|
-
UNDETERMINED: string;
|
21
|
-
};
|
22
|
-
};
|
23
|
-
export default _default;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { View, ScrollView } from 'react-native';
|
2
|
-
const NOOP = () => {
|
3
|
-
// do nothing
|
4
|
-
};
|
5
|
-
export default {
|
6
|
-
ScrollView,
|
7
|
-
PanGestureHandler: View,
|
8
|
-
attachGestureHandler: NOOP,
|
9
|
-
createGestureHandler: NOOP,
|
10
|
-
dropGestureHandler: NOOP,
|
11
|
-
updateGestureHandler: NOOP,
|
12
|
-
Direction: {
|
13
|
-
RIGHT: 1,
|
14
|
-
LEFT: 2,
|
15
|
-
UP: 4,
|
16
|
-
DOWN: 8,
|
17
|
-
},
|
18
|
-
State: {
|
19
|
-
BEGAN: 'BEGAN',
|
20
|
-
FAILED: 'FAILED',
|
21
|
-
ACTIVE: 'ACTIVE',
|
22
|
-
END: 'END',
|
23
|
-
UNDETERMINED: 'UNDETERMINED',
|
24
|
-
},
|
25
|
-
};
|
@@ -1,391 +0,0 @@
|
|
1
|
-
// This component is based on RN's DrawerLayoutAndroid API
|
2
|
-
//
|
3
|
-
// It perhaps deserves to be put in a separate repo, but since it relies
|
4
|
-
// on react-native-gesture-handler library which isn't very popular at the
|
5
|
-
// moment I decided to keep it here for the time being. It will allow us
|
6
|
-
// to move faster and fix issues that may arise in gesture handler library
|
7
|
-
// that could be found when using the drawer component
|
8
|
-
import * as React from 'react';
|
9
|
-
import { Component } from 'react';
|
10
|
-
import invariant from 'invariant';
|
11
|
-
import { Animated, StyleSheet, View, Keyboard, StatusBar, I18nManager, } from 'react-native';
|
12
|
-
import { PanGestureHandler, TapGestureHandler, } from '../handlers/gestureHandlers';
|
13
|
-
import { State } from '../State';
|
14
|
-
const DRAG_TOSS = 0.05;
|
15
|
-
const IDLE = 'Idle';
|
16
|
-
const DRAGGING = 'Dragging';
|
17
|
-
const SETTLING = 'Settling';
|
18
|
-
export default class DrawerLayout extends Component {
|
19
|
-
constructor(props) {
|
20
|
-
super(props);
|
21
|
-
this.accessibilityIsModalView = React.createRef();
|
22
|
-
this.pointerEventsView = React.createRef();
|
23
|
-
this.panGestureHandler = React.createRef();
|
24
|
-
this.drawerShown = false;
|
25
|
-
this.updateAnimatedEvent = (props, state) => {
|
26
|
-
// Event definition is based on
|
27
|
-
const { drawerPosition, drawerWidth, drawerType } = props;
|
28
|
-
const { dragX: dragXValue, touchX: touchXValue, drawerTranslation, containerWidth, } = state;
|
29
|
-
let dragX = dragXValue;
|
30
|
-
let touchX = touchXValue;
|
31
|
-
if (drawerPosition !== 'left') {
|
32
|
-
// Most of the code is written in a way to handle left-side drawer.
|
33
|
-
// In order to handle right-side drawer the only thing we need to
|
34
|
-
// do is to reverse events coming from gesture handler in a way they
|
35
|
-
// emulate left-side drawer gestures. E.g. dragX is simply -dragX, and
|
36
|
-
// touchX is calulcated by subtracing real touchX from the width of the
|
37
|
-
// container (such that when touch happens at the right edge the value
|
38
|
-
// is simply 0)
|
39
|
-
dragX = Animated.multiply(new Animated.Value(-1), dragXValue); // TODO(TS): (for all "as" in this file) make sure we can map this
|
40
|
-
touchX = Animated.add(new Animated.Value(containerWidth), Animated.multiply(new Animated.Value(-1), touchXValue)); // TODO(TS): make sure we can map this;
|
41
|
-
touchXValue.setValue(containerWidth);
|
42
|
-
}
|
43
|
-
else {
|
44
|
-
touchXValue.setValue(0);
|
45
|
-
}
|
46
|
-
// While closing the drawer when user starts gesture outside of its area (in greyed
|
47
|
-
// out part of the window), we want the drawer to follow only once finger reaches the
|
48
|
-
// edge of the drawer.
|
49
|
-
// E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by
|
50
|
-
// dots. The touch gesture starts at '*' and moves left, touch path is indicated by
|
51
|
-
// an arrow pointing left
|
52
|
-
// 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+
|
53
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
54
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
55
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
56
|
-
// |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|
|
57
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
58
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
59
|
-
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
60
|
-
// +---------------+ +---------------+ +---------------+ +---------------+
|
61
|
-
//
|
62
|
-
// For the above to work properly we define animated value that will keep start position
|
63
|
-
// of the gesture. Then we use that value to calculate how much we need to subtract from
|
64
|
-
// the dragX. If the gesture started on the greyed out area we take the distance from the
|
65
|
-
// edge of the drawer to the start position. Otherwise we don't subtract at all and the
|
66
|
-
// drawer be pulled back as soon as you start the pan.
|
67
|
-
//
|
68
|
-
// This is used only when drawerType is "front"
|
69
|
-
//
|
70
|
-
let translationX = dragX;
|
71
|
-
if (drawerType === 'front') {
|
72
|
-
const startPositionX = Animated.add(touchX, Animated.multiply(new Animated.Value(-1), dragX));
|
73
|
-
const dragOffsetFromOnStartPosition = startPositionX.interpolate({
|
74
|
-
inputRange: [drawerWidth - 1, drawerWidth, drawerWidth + 1],
|
75
|
-
outputRange: [0, 0, 1],
|
76
|
-
});
|
77
|
-
translationX = Animated.add(dragX, dragOffsetFromOnStartPosition); // TODO: as above
|
78
|
-
}
|
79
|
-
this.openValue = Animated.add(translationX, drawerTranslation).interpolate({
|
80
|
-
inputRange: [0, drawerWidth],
|
81
|
-
outputRange: [0, 1],
|
82
|
-
extrapolate: 'clamp',
|
83
|
-
});
|
84
|
-
const gestureOptions = {
|
85
|
-
useNativeDriver: props.useNativeAnimations,
|
86
|
-
};
|
87
|
-
if (this.props.onDrawerSlide) {
|
88
|
-
gestureOptions.listener = (ev) => {
|
89
|
-
const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));
|
90
|
-
const position = translationX / this.state.containerWidth;
|
91
|
-
this.props.onDrawerSlide?.(position);
|
92
|
-
};
|
93
|
-
}
|
94
|
-
this.onGestureEvent = Animated.event([{ nativeEvent: { translationX: dragXValue, x: touchXValue } }], gestureOptions);
|
95
|
-
};
|
96
|
-
this.handleContainerLayout = ({ nativeEvent }) => {
|
97
|
-
this.setState({ containerWidth: nativeEvent.layout.width });
|
98
|
-
};
|
99
|
-
this.emitStateChanged = (newState, drawerWillShow) => {
|
100
|
-
this.props.onDrawerStateChanged?.(newState, drawerWillShow);
|
101
|
-
};
|
102
|
-
this.openingHandlerStateChange = ({ nativeEvent, }) => {
|
103
|
-
if (nativeEvent.oldState === State.ACTIVE) {
|
104
|
-
this.handleRelease({ nativeEvent });
|
105
|
-
}
|
106
|
-
else if (nativeEvent.state === State.ACTIVE) {
|
107
|
-
this.emitStateChanged(DRAGGING, false);
|
108
|
-
if (this.props.keyboardDismissMode === 'on-drag') {
|
109
|
-
Keyboard.dismiss();
|
110
|
-
}
|
111
|
-
if (this.props.hideStatusBar) {
|
112
|
-
StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');
|
113
|
-
}
|
114
|
-
}
|
115
|
-
};
|
116
|
-
this.onTapHandlerStateChange = ({ nativeEvent, }) => {
|
117
|
-
if (this.drawerShown &&
|
118
|
-
nativeEvent.oldState === State.ACTIVE &&
|
119
|
-
this.props.drawerLockMode !== 'locked-open') {
|
120
|
-
this.closeDrawer();
|
121
|
-
}
|
122
|
-
};
|
123
|
-
this.handleRelease = ({ nativeEvent, }) => {
|
124
|
-
const { drawerWidth, drawerPosition, drawerType } = this.props;
|
125
|
-
const { containerWidth } = this.state;
|
126
|
-
let { translationX: dragX, velocityX, x: touchX } = nativeEvent;
|
127
|
-
if (drawerPosition !== 'left') {
|
128
|
-
// See description in _updateAnimatedEvent about why events are flipped
|
129
|
-
// for right-side drawer
|
130
|
-
dragX = -dragX;
|
131
|
-
touchX = containerWidth - touchX;
|
132
|
-
velocityX = -velocityX;
|
133
|
-
}
|
134
|
-
const gestureStartX = touchX - dragX;
|
135
|
-
let dragOffsetBasedOnStart = 0;
|
136
|
-
if (drawerType === 'front') {
|
137
|
-
dragOffsetBasedOnStart =
|
138
|
-
gestureStartX > drawerWidth ? gestureStartX - drawerWidth : 0;
|
139
|
-
}
|
140
|
-
const startOffsetX = dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth : 0);
|
141
|
-
const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;
|
142
|
-
const shouldOpen = projOffsetX > drawerWidth / 2;
|
143
|
-
if (shouldOpen) {
|
144
|
-
this.animateDrawer(startOffsetX, drawerWidth, velocityX);
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
this.animateDrawer(startOffsetX, 0, velocityX);
|
148
|
-
}
|
149
|
-
};
|
150
|
-
this.updateShowing = (showing) => {
|
151
|
-
this.drawerShown = showing;
|
152
|
-
this.accessibilityIsModalView.current?.setNativeProps({
|
153
|
-
accessibilityViewIsModal: showing,
|
154
|
-
});
|
155
|
-
this.pointerEventsView.current?.setNativeProps({
|
156
|
-
pointerEvents: showing ? 'auto' : 'none',
|
157
|
-
});
|
158
|
-
const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;
|
159
|
-
const fromLeft = drawerPosition === 'left';
|
160
|
-
// gestureOrientation is 1 if the expected gesture is from left to right and -1 otherwise
|
161
|
-
// e.g. when drawer is on the left and is closed we expect left to right gesture, thus
|
162
|
-
// orientation will be 1.
|
163
|
-
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);
|
164
|
-
// When drawer is closed we want the hitSlop to be horizontally shorter
|
165
|
-
// than the container size by the value of SLOP. This will make it only
|
166
|
-
// activate when gesture happens not further than SLOP away from the edge
|
167
|
-
const hitSlop = fromLeft
|
168
|
-
? { left: 0, width: showing ? undefined : edgeWidth }
|
169
|
-
: { right: 0, width: showing ? undefined : edgeWidth };
|
170
|
-
// @ts-ignore internal API, maybe could be fixed in handler types
|
171
|
-
this.panGestureHandler.current?.setNativeProps({
|
172
|
-
hitSlop,
|
173
|
-
activeOffsetX: gestureOrientation * minSwipeDistance,
|
174
|
-
});
|
175
|
-
};
|
176
|
-
this.animateDrawer = (fromValue, toValue, velocity, speed) => {
|
177
|
-
this.state.dragX.setValue(0);
|
178
|
-
this.state.touchX.setValue(this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth);
|
179
|
-
if (fromValue != null) {
|
180
|
-
let nextFramePosition = fromValue;
|
181
|
-
if (this.props.useNativeAnimations) {
|
182
|
-
// When using native driver, we predict the next position of the animation
|
183
|
-
// because it takes one frame of a roundtrip to pass RELEASE event from
|
184
|
-
// native driver to JS before we can start animating. Without it, it is more
|
185
|
-
// noticable that the frame is dropped.
|
186
|
-
if (fromValue < toValue && velocity > 0) {
|
187
|
-
nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);
|
188
|
-
}
|
189
|
-
else if (fromValue > toValue && velocity < 0) {
|
190
|
-
nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);
|
191
|
-
}
|
192
|
-
}
|
193
|
-
this.state.drawerTranslation.setValue(nextFramePosition);
|
194
|
-
}
|
195
|
-
const willShow = toValue !== 0;
|
196
|
-
this.updateShowing(willShow);
|
197
|
-
this.emitStateChanged(SETTLING, willShow);
|
198
|
-
if (this.props.hideStatusBar) {
|
199
|
-
StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
|
200
|
-
}
|
201
|
-
Animated.spring(this.state.drawerTranslation, {
|
202
|
-
velocity,
|
203
|
-
bounciness: 0,
|
204
|
-
toValue,
|
205
|
-
useNativeDriver: this.props.useNativeAnimations,
|
206
|
-
speed: speed ?? undefined,
|
207
|
-
}).start(({ finished }) => {
|
208
|
-
if (finished) {
|
209
|
-
this.emitStateChanged(IDLE, willShow);
|
210
|
-
if (willShow) {
|
211
|
-
this.props.onDrawerOpen?.();
|
212
|
-
}
|
213
|
-
else {
|
214
|
-
this.props.onDrawerClose?.();
|
215
|
-
}
|
216
|
-
}
|
217
|
-
});
|
218
|
-
};
|
219
|
-
this.openDrawer = (options = {}) => {
|
220
|
-
this.animateDrawer(
|
221
|
-
// TODO: decide if it should be null or undefined is the proper value
|
222
|
-
undefined, this.props.drawerWidth, options.velocity ? options.velocity : 0);
|
223
|
-
// We need to force the update, otherwise the overlay is not rerendered and it would not be clickable
|
224
|
-
this.forceUpdate();
|
225
|
-
};
|
226
|
-
this.closeDrawer = (options = {}) => {
|
227
|
-
// TODO: decide if it should be null or undefined is the proper value
|
228
|
-
this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0);
|
229
|
-
// We need to force the update, otherwise the overlay is not rerendered and it would be still clickable
|
230
|
-
this.forceUpdate();
|
231
|
-
};
|
232
|
-
this.renderOverlay = () => {
|
233
|
-
/* Overlay styles */
|
234
|
-
invariant(this.openValue, 'should be set');
|
235
|
-
const overlayOpacity = this.openValue.interpolate({
|
236
|
-
inputRange: [0, 1],
|
237
|
-
outputRange: [0, 1],
|
238
|
-
extrapolate: 'clamp',
|
239
|
-
});
|
240
|
-
const dynamicOverlayStyles = {
|
241
|
-
opacity: overlayOpacity,
|
242
|
-
backgroundColor: this.props.overlayColor,
|
243
|
-
};
|
244
|
-
return (<TapGestureHandler onHandlerStateChange={this.onTapHandlerStateChange}>
|
245
|
-
<Animated.View pointerEvents={this.drawerShown ? 'auto' : 'none'} ref={this.pointerEventsView} style={[styles.overlay, dynamicOverlayStyles]}/>
|
246
|
-
</TapGestureHandler>);
|
247
|
-
};
|
248
|
-
this.renderDrawer = () => {
|
249
|
-
const { drawerBackgroundColor, drawerWidth, drawerPosition, drawerType, drawerContainerStyle, contentContainerStyle, } = this.props;
|
250
|
-
const fromLeft = drawerPosition === 'left';
|
251
|
-
const drawerSlide = drawerType !== 'back';
|
252
|
-
const containerSlide = drawerType !== 'front';
|
253
|
-
// we rely on row and row-reverse flex directions to position the drawer
|
254
|
-
// properly. Apparently for RTL these are flipped which requires us to use
|
255
|
-
// the opposite setting for the drawer to appear from left or right according
|
256
|
-
// to the drawerPosition prop
|
257
|
-
const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;
|
258
|
-
const dynamicDrawerStyles = {
|
259
|
-
backgroundColor: drawerBackgroundColor,
|
260
|
-
width: drawerWidth,
|
261
|
-
};
|
262
|
-
const openValue = this.openValue;
|
263
|
-
invariant(openValue, 'should be set');
|
264
|
-
let containerStyles;
|
265
|
-
if (containerSlide) {
|
266
|
-
const containerTranslateX = openValue.interpolate({
|
267
|
-
inputRange: [0, 1],
|
268
|
-
outputRange: fromLeft ? [0, drawerWidth] : [0, -drawerWidth],
|
269
|
-
extrapolate: 'clamp',
|
270
|
-
});
|
271
|
-
containerStyles = {
|
272
|
-
transform: [{ translateX: containerTranslateX }],
|
273
|
-
};
|
274
|
-
}
|
275
|
-
let drawerTranslateX = 0;
|
276
|
-
if (drawerSlide) {
|
277
|
-
const closedDrawerOffset = fromLeft ? -drawerWidth : drawerWidth;
|
278
|
-
drawerTranslateX = openValue.interpolate({
|
279
|
-
inputRange: [0, 1],
|
280
|
-
outputRange: [closedDrawerOffset, 0],
|
281
|
-
extrapolate: 'clamp',
|
282
|
-
});
|
283
|
-
}
|
284
|
-
const drawerStyles = {
|
285
|
-
transform: [{ translateX: drawerTranslateX }],
|
286
|
-
flexDirection: reverseContentDirection ? 'row-reverse' : 'row',
|
287
|
-
};
|
288
|
-
return (<Animated.View style={styles.main} onLayout={this.handleContainerLayout}>
|
289
|
-
<Animated.View style={[
|
290
|
-
drawerType === 'front'
|
291
|
-
? styles.containerOnBack
|
292
|
-
: styles.containerInFront,
|
293
|
-
containerStyles,
|
294
|
-
contentContainerStyle,
|
295
|
-
]} importantForAccessibility={this.drawerShown ? 'no-hide-descendants' : 'yes'}>
|
296
|
-
{typeof this.props.children === 'function'
|
297
|
-
? this.props.children(this.openValue)
|
298
|
-
: this.props.children}
|
299
|
-
{this.renderOverlay()}
|
300
|
-
</Animated.View>
|
301
|
-
<Animated.View pointerEvents="box-none" ref={this.accessibilityIsModalView} accessibilityViewIsModal={this.drawerShown} style={[styles.drawerContainer, drawerStyles, drawerContainerStyle]}>
|
302
|
-
<View style={dynamicDrawerStyles}>
|
303
|
-
{this.props.renderNavigationView(this.openValue)}
|
304
|
-
</View>
|
305
|
-
</Animated.View>
|
306
|
-
</Animated.View>);
|
307
|
-
};
|
308
|
-
this.setPanGestureRef = (ref) => {
|
309
|
-
// TODO(TS): make sure it is OK
|
310
|
-
// taken from https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842
|
311
|
-
this
|
312
|
-
.panGestureHandler.current = ref;
|
313
|
-
this.props.onGestureRef?.(ref);
|
314
|
-
};
|
315
|
-
const dragX = new Animated.Value(0);
|
316
|
-
const touchX = new Animated.Value(0);
|
317
|
-
const drawerTranslation = new Animated.Value(0);
|
318
|
-
this.state = {
|
319
|
-
dragX,
|
320
|
-
touchX,
|
321
|
-
drawerTranslation,
|
322
|
-
containerWidth: 0,
|
323
|
-
};
|
324
|
-
this.updateAnimatedEvent(props, this.state);
|
325
|
-
}
|
326
|
-
UNSAFE_componentWillUpdate(props, state) {
|
327
|
-
if (this.props.drawerPosition !== props.drawerPosition ||
|
328
|
-
this.props.drawerWidth !== props.drawerWidth ||
|
329
|
-
this.props.drawerType !== props.drawerType ||
|
330
|
-
this.state.containerWidth !== state.containerWidth) {
|
331
|
-
this.updateAnimatedEvent(props, state);
|
332
|
-
}
|
333
|
-
}
|
334
|
-
render() {
|
335
|
-
const { drawerPosition, drawerLockMode, edgeWidth, minSwipeDistance, } = this.props;
|
336
|
-
const fromLeft = drawerPosition === 'left';
|
337
|
-
// gestureOrientation is 1 if the expected gesture is from left to right and -1 otherwise
|
338
|
-
// e.g. when drawer is on the left and is closed we expect left to right gesture, thus
|
339
|
-
// orientation will be 1.
|
340
|
-
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);
|
341
|
-
// When drawer is closed we want the hitSlop to be horizontally shorter
|
342
|
-
// than the container size by the value of SLOP. This will make it only
|
343
|
-
// activate when gesture happens not further than SLOP away from the edge
|
344
|
-
const hitSlop = fromLeft
|
345
|
-
? { left: 0, width: this.drawerShown ? undefined : edgeWidth }
|
346
|
-
: { right: 0, width: this.drawerShown ? undefined : edgeWidth };
|
347
|
-
return (<PanGestureHandler
|
348
|
-
// @ts-ignore could be fixed in handler types
|
349
|
-
ref={this.setPanGestureRef} hitSlop={hitSlop} activeOffsetX={gestureOrientation * minSwipeDistance} failOffsetY={[-15, 15]} onGestureEvent={this.onGestureEvent} onHandlerStateChange={this.openingHandlerStateChange} enableTrackpadTwoFingerGesture={this.props.enableTrackpadTwoFingerGesture} enabled={drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'}>
|
350
|
-
{this.renderDrawer()}
|
351
|
-
</PanGestureHandler>);
|
352
|
-
}
|
353
|
-
}
|
354
|
-
DrawerLayout.defaultProps = {
|
355
|
-
drawerWidth: 200,
|
356
|
-
drawerPosition: 'left',
|
357
|
-
useNativeAnimations: true,
|
358
|
-
drawerType: 'front',
|
359
|
-
edgeWidth: 20,
|
360
|
-
minSwipeDistance: 3,
|
361
|
-
overlayColor: 'rgba(0, 0, 0, 0.7)',
|
362
|
-
drawerLockMode: 'unlocked',
|
363
|
-
enableTrackpadTwoFingerGesture: false,
|
364
|
-
};
|
365
|
-
DrawerLayout.positions = {
|
366
|
-
Left: 'left',
|
367
|
-
Right: 'right',
|
368
|
-
};
|
369
|
-
const styles = StyleSheet.create({
|
370
|
-
drawerContainer: {
|
371
|
-
...StyleSheet.absoluteFillObject,
|
372
|
-
zIndex: 1001,
|
373
|
-
flexDirection: 'row',
|
374
|
-
},
|
375
|
-
containerInFront: {
|
376
|
-
...StyleSheet.absoluteFillObject,
|
377
|
-
zIndex: 1002,
|
378
|
-
},
|
379
|
-
containerOnBack: {
|
380
|
-
...StyleSheet.absoluteFillObject,
|
381
|
-
},
|
382
|
-
main: {
|
383
|
-
flex: 1,
|
384
|
-
zIndex: 0,
|
385
|
-
overflow: 'hidden',
|
386
|
-
},
|
387
|
-
overlay: {
|
388
|
-
...StyleSheet.absoluteFillObject,
|
389
|
-
zIndex: 1000,
|
390
|
-
},
|
391
|
-
});
|
@@ -1,113 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { Animated, Platform, processColor, StyleSheet, } from 'react-native';
|
3
|
-
import createNativeWrapper from '../handlers/createNativeWrapper';
|
4
|
-
import GestureHandlerButton from './GestureHandlerButton';
|
5
|
-
import { State } from '../State';
|
6
|
-
export const RawButton = createNativeWrapper(GestureHandlerButton, {
|
7
|
-
shouldCancelWhenOutside: false,
|
8
|
-
shouldActivateOnStart: false,
|
9
|
-
});
|
10
|
-
export class BaseButton extends React.Component {
|
11
|
-
constructor(props) {
|
12
|
-
super(props);
|
13
|
-
this.handleEvent = ({ nativeEvent, }) => {
|
14
|
-
const { state, oldState, pointerInside } = nativeEvent;
|
15
|
-
const active = pointerInside && state === State.ACTIVE;
|
16
|
-
if (active !== this.lastActive && this.props.onActiveStateChange) {
|
17
|
-
this.props.onActiveStateChange(active);
|
18
|
-
}
|
19
|
-
if (oldState === State.ACTIVE &&
|
20
|
-
state !== State.CANCELLED &&
|
21
|
-
this.lastActive &&
|
22
|
-
this.props.onPress) {
|
23
|
-
this.props.onPress(active);
|
24
|
-
}
|
25
|
-
this.lastActive = active;
|
26
|
-
};
|
27
|
-
// Normally, the parent would execute it's handler first,
|
28
|
-
// then forward the event to listeners. However, here our handler
|
29
|
-
// is virtually only forwarding events to listeners, so we reverse the order
|
30
|
-
// to keep the proper order of the callbacks (from "raw" ones to "processed").
|
31
|
-
this.onHandlerStateChange = (e) => {
|
32
|
-
this.props.onHandlerStateChange?.(e);
|
33
|
-
this.handleEvent(e);
|
34
|
-
};
|
35
|
-
this.onGestureEvent = (e) => {
|
36
|
-
this.props.onGestureEvent?.(e);
|
37
|
-
this.handleEvent(e); // TODO: maybe it is not correct
|
38
|
-
};
|
39
|
-
this.lastActive = false;
|
40
|
-
}
|
41
|
-
render() {
|
42
|
-
const { rippleColor, ...rest } = this.props;
|
43
|
-
return (<RawButton rippleColor={processColor(rippleColor)} {...rest} onGestureEvent={this.onGestureEvent} onHandlerStateChange={this.onHandlerStateChange}/>);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
const AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);
|
47
|
-
const btnStyles = StyleSheet.create({
|
48
|
-
underlay: {
|
49
|
-
position: 'absolute',
|
50
|
-
left: 0,
|
51
|
-
right: 0,
|
52
|
-
bottom: 0,
|
53
|
-
top: 0,
|
54
|
-
},
|
55
|
-
});
|
56
|
-
export class RectButton extends React.Component {
|
57
|
-
constructor(props) {
|
58
|
-
super(props);
|
59
|
-
this.onActiveStateChange = (active) => {
|
60
|
-
if (Platform.OS !== 'android') {
|
61
|
-
this.opacity.setValue(active ? this.props.activeOpacity : 0);
|
62
|
-
}
|
63
|
-
this.props.onActiveStateChange?.(active);
|
64
|
-
};
|
65
|
-
this.opacity = new Animated.Value(0);
|
66
|
-
}
|
67
|
-
render() {
|
68
|
-
const { children, style, ...rest } = this.props;
|
69
|
-
const resolvedStyle = StyleSheet.flatten(style ?? {});
|
70
|
-
return (<BaseButton {...rest} style={resolvedStyle} onActiveStateChange={this.onActiveStateChange}>
|
71
|
-
<Animated.View style={[
|
72
|
-
btnStyles.underlay,
|
73
|
-
{
|
74
|
-
opacity: this.opacity,
|
75
|
-
backgroundColor: this.props.underlayColor,
|
76
|
-
borderRadius: resolvedStyle.borderRadius,
|
77
|
-
borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,
|
78
|
-
borderTopRightRadius: resolvedStyle.borderTopRightRadius,
|
79
|
-
borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,
|
80
|
-
borderBottomRightRadius: resolvedStyle.borderBottomRightRadius,
|
81
|
-
},
|
82
|
-
]}/>
|
83
|
-
{children}
|
84
|
-
</BaseButton>);
|
85
|
-
}
|
86
|
-
}
|
87
|
-
RectButton.defaultProps = {
|
88
|
-
activeOpacity: 0.105,
|
89
|
-
underlayColor: 'black',
|
90
|
-
};
|
91
|
-
export class BorderlessButton extends React.Component {
|
92
|
-
constructor(props) {
|
93
|
-
super(props);
|
94
|
-
this.onActiveStateChange = (active) => {
|
95
|
-
if (Platform.OS !== 'android') {
|
96
|
-
this.opacity.setValue(active ? this.props.activeOpacity : 1);
|
97
|
-
}
|
98
|
-
this.props.onActiveStateChange?.(active);
|
99
|
-
};
|
100
|
-
this.opacity = new Animated.Value(1);
|
101
|
-
}
|
102
|
-
render() {
|
103
|
-
const { children, style, ...rest } = this.props;
|
104
|
-
return (<AnimatedBaseButton {...rest} onActiveStateChange={this.onActiveStateChange} style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>
|
105
|
-
{children}
|
106
|
-
</AnimatedBaseButton>);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
BorderlessButton.defaultProps = {
|
110
|
-
activeOpacity: 0.3,
|
111
|
-
borderless: true,
|
112
|
-
};
|
113
|
-
export { default as PureNativeButton } from './GestureHandlerButton';
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { ScrollViewProps as RNScrollViewProps, SwitchProps as RNSwitchProps, TextInputProps as RNTextInputProps, DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps, FlatList as RNFlatList, FlatListProps as RNFlatListProps } from 'react-native';
|
3
|
-
import { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler';
|
4
|
-
export declare const ScrollView: React.ForwardRefExoticComponent<RNScrollViewProps & {
|
5
|
-
children?: React.ReactNode;
|
6
|
-
} & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
|
7
|
-
export declare type ScrollView = typeof ScrollView & {
|
8
|
-
scrollTo(y?: number | {
|
9
|
-
x?: number;
|
10
|
-
y?: number;
|
11
|
-
animated?: boolean;
|
12
|
-
}, x?: number, animated?: boolean): void;
|
13
|
-
scrollToEnd(options?: {
|
14
|
-
animated: boolean;
|
15
|
-
}): void;
|
16
|
-
};
|
17
|
-
export declare const Switch: React.ForwardRefExoticComponent<RNSwitchProps & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
|
18
|
-
export declare type Switch = typeof Switch;
|
19
|
-
export declare const TextInput: React.ForwardRefExoticComponent<RNTextInputProps & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
|
20
|
-
export declare type TextInput = typeof TextInput;
|
21
|
-
export declare const DrawerLayoutAndroid: React.ForwardRefExoticComponent<RNDrawerLayoutAndroidProps & {
|
22
|
-
children?: React.ReactNode;
|
23
|
-
} & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
|
24
|
-
export declare type DrawerLayoutAndroid = typeof DrawerLayoutAndroid;
|
25
|
-
export declare const FlatList: React.ForwardRefExoticComponent<RNFlatListProps<any> & React.RefAttributes<RNFlatList<any>>>;
|
26
|
-
export declare type FlatList<ItemT> = React.ComponentType<RNFlatListProps<ItemT> & NativeViewGestureHandlerProps & React.RefAttributes<any>> & {
|
27
|
-
scrollToEnd: (params?: {
|
28
|
-
animated?: boolean;
|
29
|
-
}) => void;
|
30
|
-
scrollToIndex: (params: {
|
31
|
-
animated?: boolean;
|
32
|
-
index: number;
|
33
|
-
viewOffset?: number;
|
34
|
-
viewPosition?: number;
|
35
|
-
}) => void;
|
36
|
-
scrollToItem: (params: {
|
37
|
-
animated?: boolean;
|
38
|
-
item: ItemT;
|
39
|
-
viewPosition?: number;
|
40
|
-
}) => void;
|
41
|
-
scrollToOffset: (params: {
|
42
|
-
animated?: boolean;
|
43
|
-
offset: number;
|
44
|
-
}) => void;
|
45
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { ScrollView as RNScrollView, Switch as RNSwitch, TextInput as RNTextInput, DrawerLayoutAndroid as RNDrawerLayoutAndroid, FlatList as RNFlatList, } from 'react-native';
|
3
|
-
import createNativeWrapper from '../handlers/createNativeWrapper';
|
4
|
-
export const ScrollView = createNativeWrapper(RNScrollView, {
|
5
|
-
disallowInterruption: true,
|
6
|
-
shouldCancelWhenOutside: false,
|
7
|
-
});
|
8
|
-
export const Switch = createNativeWrapper(RNSwitch, {
|
9
|
-
shouldCancelWhenOutside: false,
|
10
|
-
shouldActivateOnStart: true,
|
11
|
-
disallowInterruption: true,
|
12
|
-
});
|
13
|
-
export const TextInput = createNativeWrapper(RNTextInput);
|
14
|
-
export const DrawerLayoutAndroid = createNativeWrapper(RNDrawerLayoutAndroid, { disallowInterruption: true });
|
15
|
-
// we use literal object since TS gives error when using RN's `positions`
|
16
|
-
// @ts-ignore FIXME(TS) maybe this should be removed?
|
17
|
-
DrawerLayoutAndroid.positions = { Left: 'left', Right: 'right' };
|
18
|
-
export const FlatList = React.forwardRef((props, ref) => (<RNFlatList ref={ref} {...props} renderScrollComponent={(scrollProps) => <ScrollView {...scrollProps}/>}/>));
|