1.0.3 • Published 5 years ago

nativescript-rating-dialog v1.0.3

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
5 years ago

Nativescript Rating Dialog

Build Status

Installation

tns plugin add nativescript-rating-dialog

Usage

import { RatingDialog, RatingDialogOption } from 'nativescript-rating-dialog';

let ratingDialog = new RatingDialog();

const option: RatingDialogOption = {
    title: "Title",
    icon: "favorite",
    android: {
        positiveButtonText: "Send",
        negativeButtonText: "Cancel",
        threshold: 3,
        onThresholdCleared: (dialog, rating, thresholdCleared) => {
        },
        onThresholdFailed: (dialog, rating) => {
        },
        onDialogDismiss: (rating) => {
          if (rating < 3) {
            console.log(`Negative Rate of ${rating} out of 5`);
            alert(`Negative Rate of ${rating} out of 5`);
          } else {
            alert(`Positive Rate of ${rating} out of 5`);
            console.log(`Positive Rate of ${rating} out of 5`);
          }
        }
    },
    ios: {
        onPositiveButtonText: "Done",
        onNegativeButtonText: "Send Feedback",
        onPositiveRate: (rating) => {
          console.log('Positive', rating);
        },
        onNegativeRate: (rating) => {
          console.log('Negative', rating);
        },
        onDismiss: () => {
          console.log('Dismiss');
        }
    }
};

ratingDialog.show(option);

API

Rating Dialog Option

PropertyTypeDescription
iconstringSet icon (use app icon as default) (optional).
titlestringSet title
textColorstringSet title text color (optional)
backgroundColorstringSet background color (optional)
androidAndroidRatingDialogOptionSet android options (optional)
iosIOSRatingDialogOptionSet iOS options (optional)

Android Rating Dialog Option

PropertyTypeDescription
thresholdnumberSet threshold (number of rating) to trigger the feedback (default is 2)
positiveButtonTextColorstringSet positive button text color (optional)
negativeButtonTextColorstringSet negative buttonText color (optional)
positiveButtonTextstringSet positive button text
negativeButtonTextstringSet negative button text (optional)
ratingBarColorstringSet rating bar color (optional)
ratingBarBackgroundColorstringSet rating bar background color (optional)
playstoreUrlstringSet playstore url (to redirect user to the app on app store) (optional)
feedbackFormAndroidRatingDialogFeedbackFormSet feedback form options (optional)
onThresholdCleared (ratingDialog: any, rating: number, thresholdCleared: boolean)Callback FunctionSet onThresholdCleared callback which fired when your rating score is greater than the threshold. (override the default redirection to Google Play) (optional)
onThresholdFailed (ratingDialog: any, rating: number, thresholdCleared: boolean)Callback FunctionSet onThresholdFailed callback which fired when your rating score is less than the threshold. (use when you want to show your custom feedback form) (optional)
onRatingChanged (rating: number, thresholdCleared: boolean)Callback FunctionSet onRatingChanged callback which fires when the rating changed (optional)
onRatingBarFormSumbit (feedback: string)Callback FunctionSet onRatingBarFormSumbit callback which fires when the rating is submitted (optional)
onDialogDismiss(rating: number)Callback FunctionSet onDialogDismiss callback which fires when the user dismissed the dialog (optional)

Android RatingDialog Feedback Form

PropertyTypeDescription
formTitlestringSet form title
formSubmitTextstringSet form submit button text
cancelTextstringSet cancel button text
feedbackFormHintstringSet feedback form hint (optional)
feedBackTextColorstringSet feedBack text color (optional)

iOS Rating Dialog Option

PropertyTypeDescription
subtitlenumberSet subtitle (optional) (default is: "Please rate your experience")
onPositiveButtonColorstringSet positive button color (optional)
onNegativeButtonColorstringSet negative button color (optional)
onPositiveButtonTextstringSet positive button text (optional)
onNegativeButtonTextstringSet negative button text (optional)
positiveTextstringSet positive text (optional) (default is: "Awesome!")
negativeTextstringSet negative text (optional) (default is: "Darn. we should have been better.")
textColorstringSet tex color (optional)
emptyStarImagestringSet name of the empty star image resource (optional)
fullStarImagestringSet name of the full star image resource (optional)
dismissButtonColorstringSet dismiss button color (optional)
itunesIdstringSet itunesId (optional)
onPositiveRate (rating: number)Callback FunctionSet onPositiveRate callback which fires when the user chose more than 3 stars and click the rate (optional)
onNegativeRate (rating: number)Callback FunctionSet onNegativeRate callback which fires when the user chose less than 4 stars and click the rate (optional)
onDismiss ()Callback FunctionSet onDismiss callback which fires when the user dismissed that screen without choosing anything (optional)

Author

Jonathan Mayunga, mayunga.j@gmail.com

Credits

For Android we're using the Smart App Rate by Codemy, and for iOS MBRateApp by MatiBot.

License

Apache License Version 2.0, January 2004