diff --git a/types/react-native-star-rating/index.d.ts b/types/react-native-star-rating/index.d.ts new file mode 100644 index 0000000000..2285134c8f --- /dev/null +++ b/types/react-native-star-rating/index.d.ts @@ -0,0 +1,130 @@ +// Type definitions for react-native-star-rating 1.0 +// Project: https://github.com/djchie/react-native-star-rating +// Definitions by: iRoachie +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; +import { ImageURISource, StyleProp, ViewStyle } from 'react-native'; + +export interface StarRatingProps { + /** + * Style of the button containing the star. + */ + buttonStyle?: StyleProp; + + /** + * Style of the element containing the star rating component. + */ + containerStyle?: StyleProp; + + /** + * Sets the interactivity of the star buttons. + * + * Default is false + */ + disabled?: boolean; + + /** + * The name of the icon to represent an empty star. + * Refer to react-native-vector-icons. + * Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). + * + * Default is "star-o" + */ + emptyStar?: string | ImageURISource; + + /** + * Color of an empty star. + * + * Default is gray + */ + emptyStarColor?: string; + + /** + * The name of the icon to represent a full star. + * Refer to react-native-vector-icons. + * Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx') + * + * Default is "star" + */ + fullStar?: string | ImageURISource; + + /** + * Color of a filled star. + * + * Default is black + */ + fullStarColor?: string; + + /** + * The name of the icon to represent an half star. + * Refer to react-native-vector-icons. + * Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). + * + * Default is "star-half-o" + */ + halfStar?: string | ImageURISource; + + /** + * Color of a half-filled star. + * + * Defaults to fullStarColor. + */ + halfStarColor?: string; + + /** + * Sets ability to select half stars + * + * Default is false + */ + halfStarEnabled?: boolean; + + /** + * The name of the icon set the star image belongs to. + * Refer to react-native-vector-icons. + * + * Default is "FontAwesome" + */ + iconSet?: string; + + /** + * The maximum number of stars possible. + * + * Default is 5 + */ + maxStars?: number; + + /** + * The current rating to show. + * + * Default is 0 + */ + rating?: number; + + /** + * Renders stars from right to left + * + * Default is false + */ + reversed?: boolean; + + /** + * Size of the star. + * + * Default is 40 + */ + starSize?: number; + + /** + * Style to apply to the star. + */ + starStyle?: StyleProp; + + /** + * A function to handle star button presses. + */ + selectedStar?(rating: number): void; +} + +export default class StarRating extends React.Component {} diff --git a/types/react-native-star-rating/react-native-star-rating-tests.tsx b/types/react-native-star-rating/react-native-star-rating-tests.tsx new file mode 100644 index 0000000000..377e802a1d --- /dev/null +++ b/types/react-native-star-rating/react-native-star-rating-tests.tsx @@ -0,0 +1,35 @@ +import * as React from 'react'; +import StarRating from 'react-native-star-rating'; + +interface State { + starCount: number; +} + +class GeneralStarExample extends React.Component<{}, State> { + constructor(props: {}) { + super(props); + + this.state = { + starCount: 3.5 + }; + } + + onStarRatingPress = (rating: number) => { + this.setState({ + starCount: rating + }); + } + + render() { + return ( + + ); + } +} + +export default GeneralStarExample; diff --git a/types/react-native-star-rating/tsconfig.json b/types/react-native-star-rating/tsconfig.json new file mode 100644 index 0000000000..74fff84c8a --- /dev/null +++ b/types/react-native-star-rating/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-star-rating-tests.tsx"] +} diff --git a/types/react-native-star-rating/tslint.json b/types/react-native-star-rating/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-star-rating/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }