A CLI tool for easily extending titanium components as a widget.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
comp2widget.js
package.json
template.stub

README.md

comp2widget Titanium Alloy

A CLI tool for easily extending titanium components as a widget.

Quickstart npm

  1. Install comp2widget using NPM:

    npm install -g comp2widget
    
  2. Create a widget if you didn't already have:

    alloy generate widget myWidget
    
  3. Add the component you want to extend to the index.xml file and give it an id:

    <Alloy>
        <Label id="myComponent"></Label>
    </Alloy>
  4. Cd into the widget folder:

    cd app/widgets/myWidget/
    
  5. Generate the helper file:

    comp2widget Titanium.UI.Label
    
  6. Add following to the top of the index.js file:

    var args = arguments[0] || {};
    require(WPATH('Titanium.UI.Label2widget')).extend(exports, args, $.myComponent);
  7. Now you can override and extend the component as you wish:

    $.myComponent.text = 'Original text: ' + args.text || '';
    exports.setText = function (text)
    {
        $.myComponent.setText('Original text: ' + text);
    }

Usage

Use comp2widget or comp2widget -h for full usage:

Usage: comp2widget <component name ...> [options]

Options:

  -h, --help           output usage information
  -V, --version        output the version number
  -s, --sdk <version>  SDK version to use
  -o, --out <name>     output name
  -n, --nocache        don't use cached api.json