diff --git a/types/react-native-swipe-gestures/index.d.ts b/types/react-native-swipe-gestures/index.d.ts new file mode 100644 index 0000000000..c832c6e7cb --- /dev/null +++ b/types/react-native-swipe-gestures/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for react-native-swipe-gestures 1.0 +// Project: https://github.com/glepur/react-native-swipe-gestures +// Definitions by: Ian +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Component } from 'react'; +import { PanResponderGestureState } from 'react-native'; + +export interface SwipeDirections { + SWIPE_UP: 'SWIPE_UP'; + SWIPE_DOWN: 'SWIPE_DOWN'; + SWIPE_LEFT: 'SWIPE_LEFT'; + SWIPE_RIGHT: 'SWIPE_RIGHT'; +} + +export const swipeDirections: SwipeDirections; + +export interface GestureRecognizerConfig { + velocityThreshold?: number; + directionalOffsetThreshold?: number; + gestureIsClickThreshold?: number; +} + +export interface GestureRecognizerProps { + config?: GestureRecognizerConfig; + onSwipe?: (gestureName: string, state: PanResponderGestureState) => void; + onSwipeUp?: (state: PanResponderGestureState) => void; + onSwipeDown?: (state: PanResponderGestureState) => void; + onSwipeLeft?: (state: PanResponderGestureState) => void; + onSwipeRight?: (state: PanResponderGestureState) => void; +} + +export default class GestureRecognizer extends Component {} diff --git a/types/react-native-swipe-gestures/react-native-swipe-gestures-tests.tsx b/types/react-native-swipe-gestures/react-native-swipe-gestures-tests.tsx new file mode 100644 index 0000000000..f7f40e40b3 --- /dev/null +++ b/types/react-native-swipe-gestures/react-native-swipe-gestures-tests.tsx @@ -0,0 +1,25 @@ +import * as React from 'react'; +import GestureRecognizer, { GestureRecognizerConfig, swipeDirections } from 'react-native-swipe-gestures'; + +const { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT } = swipeDirections; + +const config: GestureRecognizerConfig = { + velocityThreshold: 0.3, + directionalOffsetThreshold: 80, + gestureIsClickThreshold: 5, +}; + +class Example extends React.Component { + render() { + return ( + {}} + onSwipeUp={state => {}} + onSwipeDown={state => {}} + onSwipeLeft={state => {}} + onSwipeRight={state => {}} + /> + ); + } +} diff --git a/types/react-native-swipe-gestures/tsconfig.json b/types/react-native-swipe-gestures/tsconfig.json new file mode 100644 index 0000000000..489c76cdc5 --- /dev/null +++ b/types/react-native-swipe-gestures/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-swipe-gestures-tests.tsx" + ] +} diff --git a/types/react-native-swipe-gestures/tslint.json b/types/react-native-swipe-gestures/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-swipe-gestures/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }