Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pankod/react-native-store-rating

Ratings and reviews influence how your app ranks in search results, and can affect whether someone downloads your app. Users can rate your app on a scale of desired amount of stars.
https://github.com/pankod/react-native-store-rating

react-native typescript

Last synced: about 6 hours ago
JSON representation

Ratings and reviews influence how your app ranks in search results, and can affect whether someone downloads your app. Users can rate your app on a scale of desired amount of stars.

Awesome Lists containing this project

README

        



            



React Native Store Rating



React Native Module to getting users to easily rate and leave a review about your app.


[![npm version](https://img.shields.io/npm/v/@pankod/react-native-store-rating.svg)](https://www.npmjs.com/package/@pankod/react-native-store-rating)
[![dependencies Status](https://david-dm.org/pankod/react-native-store-rating/status.svg)](https://david-dm.org/pankod/react-native-store-rating)
[![dev-dependencies Status](https://david-dm.org/pankod/react-native-store-rating/dev-status.svg)](https://david-dm.org/pankod/react-native-store-rating?type=dev)



Created by Pankod




Ratings and reviews influence how your app ranks in search results, and can affect whether someone downloads your app. Users can rate your app on a scale of desired amount of stars. They can also add a written review for iOS and Android apps.

## Stores Supported:
| **Apple App Store** | **Google Play** |
:--------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: |
| **✓** | **✓** |
| | |

## Getting started
```
$ npm i @pankod/react-native-store-rating
```

or

```
$ yarn add @pankod/react-native-store-rating
```

## Usage
Users are presented with a modal allowing them to choose amount of stars which is defined with `totalStarCount` props.

The star rate taken from the users is compared to the value defined in "storeRedirectThreshold". If this value is greater than the value of "storeRedirectThreshold", the user is directed to the App store or Google Play Store. If it is equal and smaller, comment popup will be opened and users will be allowed to type comment.

Example: Let's say we defined 3 as a value to `storeRedirectThreshold` property,
```javascript

```

User redirect to App Store or Google Play Store when the given star rate is greater then 3.

Comment modal will be opened if the given star rate equal or less then 3.

## Live Demo with Expo

[![Explore with Expo Snack](/expo_preview.png)](https://snack.expo.io/@pankod/github.com-pankod-react-native-store-rating:example)

## Example
``` javascript
import React, { Component } from 'react'
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native'
import RateModal from '@pankod/react-native-store-rating'

export default class example extends Component {
state = {
isModalOpen: false
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
})

const rateModalStyles = StyleSheet.create({
button: {
backgroundColor: 'transparent',
borderColor: 'transparent',
textTransform: 'upparcase'
},
})

render() {
return (

this.setState({ isModalOpen: true })}>
Open Modal

{
console.log('change rating', e);
}}
onClosed={() => {
console.log('pressed cancel button...')
this.setState({
isModalOpen: false
})
}}
sendContactUsForm={(state) => {
alert(JSON.stringify(state));
}}
styles={rateModalStyles}
ratingProps={{
selectedColor: 'red',
}}
modalProps={{
animationType: 'fade',
}}
/>


)
}
}
```


## Options

| Properties | Type | Description |Default |
|------------|-------------------------------------|-------------|----------------------------------------------------------------|
| **playStoreUrl**
**required* | `string` | Google Play Store App Url
`market://details?id=${APP_PACKAGE_NAME}` | |
| **iTunesStoreUrl**
**required* | `string` | Apple ITunes App Url
`itms-apps://itunes.apple.com/app/${APP_ID}`| |
| **modalTitle** | `string` | The modal header title | `"How many stars do you give to this app?"` |
| **rateBtnText** | `string` | The button text. | `"Rate"` |
| **cancelBtnText** | `string` | The cancel button text. | `"Cancel"` |
| **totalStarCount** | `number` | The starts count on modal. | `5` |
| **defaulRating** | `number` | If no number set, it will determine 3 stars rating. | `5` |
| **isVisible** | `boolean` | Shows rating on modal. | ` true` |
| **sendBtnText** | `string` | The text of send button. | `"Send"` |
| **commentPlaceholderText** | `string` | User review modal placeholder text. | `"You can write your comments here"` |
| **isTransparent** |`boolean` | Background style | `true` |
| **starLabels** | `array` | The array of rating title. | `['Terrible', 'Bad', 'Okay', 'Good', 'Great']` |
| **emptyCommentErrorMessage** | `string` | User review comment box validation text | `"Please specify your opinion."` |
| **isModalOpen** | `boolean` | Control if the modal open or not. | `false` |
| **storeRedirectThreshold** | `number` | ? | `3` |
| **style**
**deprecated* | `Object` | An object containing the styles objects to style the modal. Use `styles` instead. | `example:`
`{ backgroundColor: #000, paddingHorizontal: 30 }` |
| **styles** | `Object` | An object for the styles for all the components inside RateModal (modal, title, buttons, textbox, error message). It overrides the default styling at `Assets/Styles/Ratemodal.tsx`, use the same properties for selectors as there. | `{}` |
| **ratingComponent** | `React.ElementType` | Your custom rating component. | `react-native-ratings/AirbnbRating` |
| **ratingProps** | `Object` | Necessary props for the rating component not mentioned above. Depends on the component you use, but here you can set the color of the stars for the AirbnbRating as well. | `{}` |
| **modalProps** | `Object` | Props to pass to the React Native's [Modal](https://reactnative.dev/docs/modal) component. | `{}` |


## Functions

| Properties | Type | Description |Default |
|------------|-------------------------------------|-------------|----------------------------------------------------------------|
| **onStarSelected** | `Function` | Function fired when the rating has changed.| `return: number` |
| **onClosed**
**required* | `Function` | Function fired when the modal has closed.| `console.warn('pressed cancel button...')` |
| **onSendReview** | `Function` | Function fired when redirected to the store. Passes the component state. | |
| **sendContactUsForm**
**required* | `Function` | Read component state and function fired when the user comment was submitted. | `{ isModalOpen: true, rating: 3, review: "Lorem ipsum dolor sit amet...", reviewError:false, showContactForm:true }` |

#### Notes

As of version 1.1.0 this package is compatible with both iOS and Android.

#### Releases
- 1.0.0 - Initial release
- 1.1.0 - Some props and functions name changed && added example app.