Alloy

Alloy framework, a new Appcelerator framework for the Titanium SDK designed to rapidly develop quality Titanium applications. It is based on the model-view-controller architecture and contains built-in support for Backbone.js and Underscore.js .

Create Alloy Project

To create a new Alloy project, start Titanium Studio, then
  1. From the menu, select File > New > Mobile Project. The New Mobile Project wizard appears.
  2. Select Alloy in the Available Templates box, choose a template, then click the Next button.
  3. Complete all of the fields, then click the Finish button.
A new skeleton Alloy project will be generated. The project structure look like 


Resources are placed under the app directory.

Files


1. alloy.js 
2.config.json 

Directories


1. assets
2.controllers
3.models
4.styles
5.views

alloy.js 
you can declare you global variables, collections and functions in this file.

Example:

Alloy.Globals.someGlobalFunction = function(){};

config.json
Alloy uses the config.json file, located in the project's app directory, to specify global values, conditional environment and platform values, and widget dependencies. The configuration file contains the following objects:

Object
Description
global
Contains key-value pairs present for all environments and platforms.
env:development
Contains key-value pairs present for targets built for development, running in either the simulator or emulator.
env:test
Contains key-value pairs present for targets built for testing on a device.
env:production
Contains key-value pairs present for targets built for production, running after a package installation.
os:android
Contains key-value pairs present for targets built for Android.
os:blackberry
Contains key-value pairs present for targets built for BlackBerry.
os:ios
Contains key-value pairs present for targets built for iOS.
os:mobileweb
Contains key-value pairs present for targets built for Mobile Web.
dependencies
Contains key-value pairs for widget dependencies, where the key is the widget name and the value is the version number of the widget.

When mixed together, 'os' values override 'env' values, which override 'global' values. These values are accessible during runtime by prefixing the key withAlloy.CFG.

 assets directory

This directory is used to place your images based platform specific.
You can place you preloaded db file within assets folder.

controllers directory

This directory is used to place your .js files. Note that your xml , tss and the .js files should have same name.

models

This directory is used your db connection and manipulate operation files. which is in .js format.

styles

This file is used to hold your .tss files.  

views

This file used to place the view layout files in .xml format.

Thanks.



No comments:

Post a Comment