Add types for react-native-platform-touchable

This commit is contained in:
Toni Granados
2019-01-25 17:10:59 +01:00
parent 7c13736555
commit 0cf6eb14dc
4 changed files with 69 additions and 0 deletions

View File

@@ -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 <https://github.com/tngranados>
// 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<PlatformTouchableProps> {
// 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;

View File

@@ -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 (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Touchable
onPress={() => {}}
style={{ backgroundColor: "#eee", padding: 30 }}
background={Touchable.Ripple("pink", false)}
>
<Text>Hello there!</Text>
</Touchable>
</View>
);
}
}

View File

@@ -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"]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }