NativeScript-Snackbar Plugin

In a follow up to my previous post on how to use the Material Design ‘Snackbar’ component in your Android NativeScript app, I’d like to announce that yesterday I published a plugin available here on NPM. Currently this is Android only, I’m looking to integrate with a decent Cocoapod for the iOS version.

If you’re familiar with npm and using your CLI then the following command will install the plugin into your current app.

npm install nativescript-snackbar

Once the plugin is installed into your project, you just need to require the module in your code where you’d like to execute the methods available.

I chose to keep the methods very simple to prevent any issues for users who aren’t going to dig into the native constructors and methods for the Snackbar.

The methods are:

.simple(string snackText) – this snackbar just shows a string of text and hides after the default 3000ms delay.

action({snackText, hideDelay, actionText, actionClickFunction}) – this method expects an object with the properties above to be passed in the arguments options. This snackbar you have the ability to set the snackText, hideDelay (optional), actionText, and actionClickFunction.

If you don’t pass actionText or the actionClickFunction the .simple() method will be executed showing just the snackText.

Be sure to check out the examples, they’re on the plugin page on NPM and you can find them in the README here on GitHub

If you have any questions, comments, or would like to help contribute to this plugin then let me know. I’d really like to get the iOS version completed soon to make it cross platform and remove any platform checking logic within the current code. Once this is done it will clean up the .JS files a bit. Thanks for checking it out.