Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jcassidyav/feedback

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jcassidyav/feedback

Add a plugin description

  • 1.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

NativeScript Feedback

NPM version Downloads

npmnpm        

Demo apps

NativeScript-Core (XML)

Check out the apps/demo folder. This is how to clone and run it:

git clone https://github.com/jcassidyav/feedback
npm run setup
npm run start apps.demo.android # or apps.demo.ios

Installation

npm i @jcassidyav/feedback

API

requiring / importing the plugin

JavaScript
var FeedbackPlugin = require("nativescript-feedback");
var feedback = new FeedbackPlugin.Feedback();
TypeScript
import { Feedback, FeedbackType, FeedbackPosition } from "nativescript-feedback";

export class MyClassWithFeedback {
  private feedback: Feedback;
  
  constructor() {
    this.feedback = new Feedback();
  }
}

show

Showing feedback can be as easy as:

this.feedback.show({
  message: "Easiest thing ever, right?"
});

That uses a bunch of sane defaults. However, there are a lot of things you may want to tweak. All of which are optional:

PropertyDefaultDescription
titleundefinedThe bold title at the top.
titleColornew Color("white")The title's color.
titleFontBold system fontiOS needs the font name and android the file name. See the demo for examples.
titleSize16The size of the title font.
messageundefinedThe message below the title.
messageColornew Color("white")The message's color.
messageFontSystem fontiOS needs the font name and android the file name. See the demo for examples.
messageSize13The size of the message font.
duration4000The duration to show the feedback (milliseconds).
typeFeedbackType.CustomOne of .Custom, .Success, .Warning, .Error, .Info. Each with a distinct style as show in the animations above. You can still override all other properties according to your liking.
positionFeedbackPosition.TopEither .Top or .Bottom.
backgroundColorDepends on the typeThe background's color.
iconDepends on the typeA custom icon shown on the left. Loaded from App_Resources/<platform> folders. Example here. Want no icon at all? Don't set a type.
android.iconColorSee descriptionOn iOS the icon color is as-is, but on Android it's white. Set this color to override the latter (also see the TypeScript example below).
android.iconPulseEnabledtrueOn Android you can disable the pulsating effect of the icon.
onTapundefinedA callback function that gets invoked when the user tapped your feedback.
onShowundefinedA callback for when the feedback is shown. iOS note: is called twice: once when animating and once when done.
onHideundefinedA callback for when the feedback is hidden.

One of the examples in the demo app shows a custom icon and alternative colors. You'd get there by doing:

JavaScript
var FeedbackType = require ("nativescript-feedback").FeedbackType;
var FeedbackPosition = require ("nativescript-feedback").FeedbackPosition;
var color = require("color");

this.feedback.show({
  title: "Thumbs up!",
  titleColor: new color.Color("#222222"),
  position: FeedbackPosition.Bottom, // iOS only
  type: FeedbackType.Custom, // this is the default type, by the way
  message: "Custom colors and icon. Loaded from the App_Resources folder.",
  messageColor: new color.Color("#333333"),
  duration: 3000,
  backgroundColor: new color.Color("yellowgreen"),
  icon: "customicon", // in App_Resources/platform folders
  onTap: function() { console.log("showCustomIcon tapped") },
  onShow: function(animating) { console.log(animating ? "showCustomIcon animating" : "showCustomIcon shown") },
  onHide: function() { console.log("showCustomIcon hidden") }
});
TypeScript
import { FeedbackType, FeedbackPosition } from "nativescript-feedback";
import { Color } from "tns-core-modules/color";

this.feedback.show({
  title: "Thumbs up!",
  titleColor: new Color("#222222"),
  position: FeedbackPosition.Bottom,
  type: FeedbackType.Custom, // this is the default type, by the way
  message: "Custom colors and icon. Loaded from the App_Resources folder.",
  messageColor: new Color("#333333"),
  duration: 3000,
  backgroundColor: new Color("yellowgreen"),
  icon: "customicon", // in App_Resources/platform folders
  android: {
    iconColor: new Color("#222222") // optional, leave out if you don't need it
  },
  onTap: () => console.log("showCustomIcon tapped"),
  onShow: animating => console.log(animating ? "showCustomIcon animating" : "showCustomIcon shown"),
  onHide: () => console.log("showCustomIcon hidden")
});

hide

Hiding a message can be done automatically (see duration), by a gesture (tap / swipe), or programmatically as shown here:

this.feedback.hide();

Convenience functions

Since in many cases you want to only show success / info / warning / error messages anyway, this plugin's got you covered. You can call any of these functions and still pass in any of the aforementioned properties to tweak it to your liking:

success
this.feedback.success({
  title: "Awesome",
  message: "That was great!"
});
info
this.feedback.info({
  title: "Info <> Data",
  message: "Info is relevant data, not just any data."
});
warning
this.feedback.warning({
  message: "Your battery is almost empty"
});
error
this.feedback.error({
  title: "KABOoooOOM!",
  titleColor: new Color("black")
});

Credits

This is a clone of Eddy Verbruggen's nativescript-feedback converted to use the nativescript plugin seed and latest Alerter Library.

On Android we're using the Alerter library by Tapadoo, and on iOS ISMessages by ilyainyushin.

Keywords

FAQs

Package last updated on 16 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc