Quick Example of registering a scheme in TiApp.xml, implementing the code in app.js / alloy.js
/** | |
* @method slideIn | |
* Makes the specified view appear using a "slide-in" animation, it will automatically | |
* detect where the view is offscreen and bring it into the user's vison. | |
* @param {Titanium.UI.View} view View to animate. | |
* @param {Number} duration Fade duration in milliseconds. | |
* @param {function()} [finishCallback] Callback function, invoked after the popIn completes. | |
*/ | |
exports.slideIn = function (view, duration, finishCallback) { | |
Execute "tishadow run" in your Titanium app directory whenever a JavaScript file changes. Edit your JS files in a text editor, save, then switch to the test device or simulator. Profit.
[sudo] npm install -g supervisor
If you want to your CommonJS modules to work in both Alloy and plain Titanium projects, you might need a way to detect if you're in Alloy. For instance, if you're in Alloy you would get Underscore from the alloy-module, while in plain Titanium you would require Underscore directly.
Well, you can:
var _ = require((typeof ENV_TEST === 'boolean') ? 'alloy' : 'underscore')._;
The above works by utilizing Alloy's optimization process. In this process, constants like ENV_TEST
will be either TRUE
or FALSE
. The actual expressions in wich they are used will then be evaluated. If FALSE
the code block will be removed. In plain Titanium projects the constants are undefined and this typeof ENV_TEST
will be undefined
, so the code block will be executed.
web: node server |
function doClickMenu(evt){ | |
alert(evt.source.title); | |
} | |
// we need to do some things to the Window once it is properly instanciated, so we add an event listener to its OPEN event | |
$.win.addEventListener('open',function(){ | |
var actionBar = $.win.activity.actionBar; // get a handle to the action bar | |
actionBar.title='My App'; // change the App Title | |
actionBar.displayHomeAsUp=true; // Show the "angle" pointing back | |
actionBar.onHomeIconItemSelected = function() { // what to do when the "home" icon is pressed |
// add all items to collection | |
Alloy.Collections.Fugitive.reset([{ | |
"name" : "Jeff Haynie" | |
}, { | |
"name" : "Nolan Wright" | |
}, { | |
"name" : "Don Thorp" | |
}, { | |
"name" : "Marshall Culpepper" | |
}, { |
//Setup module to run Behave tests | |
require('behave').andSetup(this); | |
describe('The model helper package: login USER', function() { | |
var ACSModels = new (require('models').MODELS)(Alloy); | |
it.eventually('*** logs in user', function(done) { | |
var model = ACSModels.createModel('user', { |
// Setup Geoloaction Background Tasks for the app | |
Ti.Geolocation.purpose = "This app would like to use your location."; | |
Ti.App.iOS.registerBackgroundService({url: "geoBackgroundTask.js"}); | |
/** | |
* Note: If you are programming in a standard project for Titanium, | |
* this snippet would probably go in your app.js file | |
* / |
<?xml version="1.0" encoding="UTF-8"?> | |
<projectDescription> | |
<name>g_2tabbed</name> | |
<comment></comment> | |
<projects> | |
</projects> | |
<buildSpec> | |
<buildCommand> | |
<name>com.appcelerator.titanium.core.builder</name> | |
<arguments> |