0.1.3 • Published 5 years ago

react-native-customized-star-rating v0.1.3

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

npm version

NPM

React-Native-Customized-Star-Rating Component:

  • Customized animated star rating in react-native which is compatible for both IOS and Android.

Advantages:

  • User can change star view look and feel by changing star image
  • User can customize star image animation by modifying the easing animation value
  • User can give star count to display how many stars required to render
  • Customized star component can accept 2 types of image importing from both local and URL based.

Table of Contents:

  1. Prerequisites
  2. Installation
  3. Props
  4. Demo
  5. Usage
  6. Roadmap
  7. Author

Prerequisites:

shell, brew, watchman, npm, react-native-cli - these are the packages which were need to be installed.

Installation:

  • installing react-native-customized-star-rating plugin and adding dependeices as below
    npm install react-native-customized-star-rating --save
    or
    yarn add react-native-customized-star-rating
  • Adding Dependencies: react-native link react-native-customized-star-rating

Demo:

Props:

PropTypeDescriptionRequiredDefault
noOfStarsintThe total number of starsYesNA
starRowStyleobjectStyle required for star row viewYesNA
starSizeStyleobjectStyle required for star image viewYesNA
selectedStarintLocal react state to get selected star idYesNA
starAnimationScaleint or floatTo scale up star image sizeYesNA
animationDurationintAnimation duration time which defines how long animation should playYesNA
easingTypeEasing nameEasing animation typeYesNA
emptyStarImagePathobjectIt can accept either local image path or remote image pathYesNA
filledStarImagePathobjectIt can accept either local image path or remote image pathYesNA
onClickFunccallBackfunction()Define call back function hereYesNA

Usage:

import CustomizedStarRating from 'react-native-customized-star-rating';

class ParentComponent extends Component {
    constructor(props) {
        super(props);
        this.state = {
            scaleAnimation: new Animated.Value(1),
            filledStar: 0,
        }
    }

    clickStar(j) {
        this.setState({ filledStar: j })
    }

    render() {
        return (
            <CustomizedStarRating
                noOfStars={'4'}
                starRowStyle={styles.starRowStyle}
                starSizeStyle={styles.starSizeStyle}
                selectedStar={this.state.filledStar}
                starAnimationScale={1.15}
                animationDuration={300}
                easingType={Easing.easeInCirc}
                emptyStarImagePath={require('../images/emptyStar.png')}
                filledStarImagePath={{ uri: 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Nautical_star.svg/1200px-Nautical_star.svg.png' }}
                onClickFunc={(i) => this.clickStar(i)}
            />
        );
    }
}

export default ParentComponent

Roadmap:

  • View the project roadmap here

Author: