diff --git a/types/react-native-platform-touchable/index.d.ts b/types/react-native-platform-touchable/index.d.ts new file mode 100644 index 0000000000..561019475e --- /dev/null +++ b/types/react-native-platform-touchable/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for react-native-platform-touchable 1.1 +// Project: https://github.com/react-native-community/react-native-platform-touchable +// Definitions by: Toni Granados +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; +import { BackgroundPropType, RippleBackgroundPropType, ThemeAttributeBackgroundPropType, TouchableWithoutFeedbackProps } from "react-native"; + +export interface PlatformTouchableProps extends TouchableWithoutFeedbackProps { + // TouchableOpacity (default iOS) + activeOpacity?: number; + // TouchableNativeFeedback (default Android) + background?: BackgroundPropType; + foreground?: boolean; + // TouchableHighlight + underlayColor?: string; + onHideUnderlay?: () => void; + onShowUnderlay?: () => void; +} + +export class Touchable extends React.Component { + // TouchableOpacity (default iOS) + setOpacityTo: (value: number) => void; + // TouchableNativeFeedback (default Android) + static SelectableBackground(): ThemeAttributeBackgroundPropType; + static SelectableBackgroundBorderless(): ThemeAttributeBackgroundPropType; + static Ripple(color: string, borderless?: boolean): RippleBackgroundPropType; + static canUseNativeForeground(): boolean; +} + +export default Touchable; diff --git a/types/react-native-platform-touchable/react-native-platform-touchable-tests.tsx b/types/react-native-platform-touchable/react-native-platform-touchable-tests.tsx new file mode 100644 index 0000000000..19f9952d6c --- /dev/null +++ b/types/react-native-platform-touchable/react-native-platform-touchable-tests.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; +import { Text, View } from "react-native"; +import Touchable from "react-native-platform-touchable"; + +class PlatformTouchableExample extends React.Component { + render() { + return ( + + {}} + style={{ backgroundColor: "#eee", padding: 30 }} + background={Touchable.Ripple("pink", false)} + > + Hello there! + + + ); + } +} diff --git a/types/react-native-platform-touchable/tsconfig.json b/types/react-native-platform-touchable/tsconfig.json new file mode 100644 index 0000000000..5cbb1ffb1a --- /dev/null +++ b/types/react-native-platform-touchable/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "jsx": "react-native", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-native-platform-touchable-tests.tsx"] +} diff --git a/types/react-native-platform-touchable/tslint.json b/types/react-native-platform-touchable/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-platform-touchable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }