Help Needed Building Plugin


#1

Hi All,

So working on a project for University, and need some help and guidance with plugins.

A high level overview of the plugin is a plugin which contains customised components for a company, to allow a more stream lime ability to develop applications.

What I want to achieve is having a plugin, which has multiple containers of different stuff.

Example:

A customised plugin, which makes an API call to login a user.

This is where I need help.

The plugin will have a folder called “LoginBtn” - within that folder, it will contain the CSS, XML, JS, JS-View files to create that button and implement the API calling.

Once the plugin is installed, do I simply do the following to call the button and have it appear in my application.

app.xml:

<Page loaded="pageLoaded" class="page" xmlns:loginBtn="~/name-of-plugin/loginBtn/loginBtn-page" xmlns="http://www.nativescript.org/tns.xsd"
 actionBarHidden="true">
	<StackLayout>
		<loginBtn:loginBtn-Frm class="loginA" tap="loginA" />
	</StackLayout>
</Page>```

I attempt to call the JS file for the loginBtn within the plugin, which is "loginBtn-page.js" 

I'm trying to follow the method of this example:
https://github.com/NativeScript/nativescript-ui-plugin-custom

Any help and guidance would be amazing. I'll clean up my code, and try and upload an example to GITHUB today.

Thanks, Harrison

#2

Did you install your plugin via node_modules or it’s directly placed in side your app folder?


#3

Hey manojdcoder,

I followed the method of building plugins that Nativescript gives in its tutorials.

I use the “./pack.sh” method to build the plugin.

And then “tns add plugin ‘plugin-name.tgz’”

Is this not the correct way?