Add Types for react-primitives (#26973)

* add types for react-primitives

* Add new lines

* remove custom linting rules
This commit is contained in:
Ahmed Ghoneim
2018-07-03 06:07:31 +02:00
committed by Mohamed Hegazy
parent ec281ea2f1
commit 566e039485
4 changed files with 143 additions and 0 deletions

33
types/react-primitives/index.d.ts vendored Normal file
View File

@@ -0,0 +1,33 @@
// Type definitions for react-primitives 0.6
// Project: https://github.com/lelandrichardson/react-primitives
// Definitions by: Ahmed Ghoneim <https://github.com/aghoneim92>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import { ComponentType } from 'react';
import {
Animated,
Dimensions,
Easing,
Image,
PixelRatio,
Platform,
StyleSheet,
Text,
TouchableOpacityProps,
View
} from 'react-native';
export const Touchable: ComponentType<TouchableOpacityProps>;
export {
Animated,
Dimensions,
Easing,
Image,
PixelRatio,
Platform,
StyleSheet,
Text,
View
};

View File

@@ -0,0 +1,87 @@
import * as React from 'react';
import {
Animated,
Dimensions,
Easing,
Image,
PixelRatio,
Platform,
Text,
Touchable,
View,
StyleSheet
} from 'react-primitives';
const { Image: AnimatedImage } = Animated;
const { width, height } = Dimensions.get('window');
const { width: screenWidth, height: screenHeight } = Dimensions.get('screen');
const styles = StyleSheet.create({
container: {
height: screenHeight
},
nav: {
width: screenWidth,
height: 20
},
image: {
width,
height: 100
},
text: {
fontSize: 14 * PixelRatio.get()
}
});
interface State {
opacity: Animated.Value;
}
export default class Component extends React.Component<{}, State> {
state: State = {
opacity: new Animated.Value(0)
};
componentDidMount() {
Animated.timing(this.state.opacity, {
toValue: 1,
duration: 10000,
easing: Easing.cubic
}).start();
}
render() {
const {
state: { opacity }
} = this;
return (
<View style={styles.container}>
<View style={styles.nav}>
<Text>My Awesome App!</Text>
</View>
<AnimatedImage
style={[styles.image, { opacity }]}
source={{ uri: 'source' }}
/>
<Image style={styles.image} source={{ uri: 'source' }} />
<Text style={styles.text}>Hii</Text>
{Platform.OS === 'ios' && (
<View>
<Text>IOS Specific Text!</Text>
</View>
)}
<Touchable onPress={() => undefined}>
<Text>Touch me!</Text>
</Touchable>
<View>
<Text>Helloooooo</Text>
<Touchable>
<Text>Touch me too!</Text>
</Touchable>
</View>
</View>
);
}
}

View File

@@ -0,0 +1,20 @@
{
"files": [
"index.d.ts",
"react-primitives-tests.tsx"
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"jsx": "react",
"baseUrl": "../",
"typeRoots": ["../"],
"types": []
}
}

View File

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