appcelerator alloy deep dive - titokyo 2013

42
Ricardo Alcocer Platform Evangelist @ Appcelerator, Inc. @ricardoalcocer [email protected] Appcelerator® Deep Dive tiTokyo February 16, 2013

Upload: ralcocer

Post on 18-Jun-2015

7.840 views

Category:

Technology


3 download

DESCRIPTION

Slides for my presentation at tiTokyo 2013

TRANSCRIPT

Page 1: Appcelerator Alloy Deep Dive - tiTokyo 2013

Ricardo AlcocerPlatform Evangelist @ Appcelerator, Inc.

@ricardoalcocer [email protected]

Appcelerator® Deep Dive

tiTokyoFebruary 16, 2013

Page 2: Appcelerator Alloy Deep Dive - tiTokyo 2013

About me

• Currently work as Appcelerator Platform Evangelist in the Silicon Valley Area

• Have been developing Apps with Titanium since 2009

• Former Titanium trainer in the Caribbean and Latin America

• Hacker in constant training

Page 3: Appcelerator Alloy Deep Dive - tiTokyo 2013

Download Titanium Studio

• Download Titanium Studio from appcelerator.com

• Make sure you install and configure the necessary SDKs from Apple and Android

Page 4: Appcelerator Alloy Deep Dive - tiTokyo 2013

Two flavors of Titanium?

Page 5: Appcelerator Alloy Deep Dive - tiTokyo 2013

Very simple App in Titanium Classic

Page 6: Appcelerator Alloy Deep Dive - tiTokyo 2013

Files organized by directories

Page 7: Appcelerator Alloy Deep Dive - tiTokyo 2013

App.JS

Page 8: Appcelerator Alloy Deep Dive - tiTokyo 2013

Different versions of ApplicationWindow.js

Page 9: Appcelerator Alloy Deep Dive - tiTokyo 2013

FirstView.js

Page 10: Appcelerator Alloy Deep Dive - tiTokyo 2013

Enter the MVC Pattern

Model

ControllerView

User

Routing, decision making

Business logic, data manipulation, etc

What the user sees

.JS Files.XML + .TSS Files

Page 11: Appcelerator Alloy Deep Dive - tiTokyo 2013

What is Appcelerator® Alloy™?

• Official MVC Framework for Titanium• Free and Open Source• Declarative UI• Widgets• Themes

Page 12: Appcelerator Alloy Deep Dive - tiTokyo 2013

Why build an MVC Framework?

• Help developers build scalable apps• Provide a basis for best practices on

Titanium development• Simplify development of Titanium apps• Make Titanium more approachable to web

developers and designers (use of XML, CSS)• Reduce the amount of code written• Set the foundation for widget/ component/

sample libraries

Page 13: Appcelerator Alloy Deep Dive - tiTokyo 2013

Same App built on Alloy

Page 14: Appcelerator Alloy Deep Dive - tiTokyo 2013

Dramatic reduction of required files

Page 15: Appcelerator Alloy Deep Dive - tiTokyo 2013

Write less code!

Page 16: Appcelerator Alloy Deep Dive - tiTokyo 2013

Alloy provides advanced ways of interacting with XML from Javascript

Page 17: Appcelerator Alloy Deep Dive - tiTokyo 2013

Basic Folder Structure

App Logic

User Interface Definition

App styling (colors, positioning, etc)

Page 18: Appcelerator Alloy Deep Dive - tiTokyo 2013

User Interface Definition

Page 19: Appcelerator Alloy Deep Dive - tiTokyo 2013

User Interface Definition

Menu Definition

Page 20: Appcelerator Alloy Deep Dive - tiTokyo 2013

User Interface Definition

Main View Definition

Page 21: Appcelerator Alloy Deep Dive - tiTokyo 2013

User Interface Definition

Main View Definition

Page 22: Appcelerator Alloy Deep Dive - tiTokyo 2013

Open and Close the menu using Javascript : index.js

Page 23: Appcelerator Alloy Deep Dive - tiTokyo 2013

Live Demo

Page 24: Appcelerator Alloy Deep Dive - tiTokyo 2013

Change the look-and-feel and layout of your App using Themes

Let’s add Themes to our App

Page 25: Appcelerator Alloy Deep Dive - tiTokyo 2013

Themes

Page 26: Appcelerator Alloy Deep Dive - tiTokyo 2013

Live Demo

Page 27: Appcelerator Alloy Deep Dive - tiTokyo 2013

Reuse code by creating Widgets

Let’s build a Widget for the Menu functionality

Page 28: Appcelerator Alloy Deep Dive - tiTokyo 2013

Widgets are like “mini-apps”

• Similar folder structure

• Instead of an “index” file, you have a “widget” file

Page 29: Appcelerator Alloy Deep Dive - tiTokyo 2013

Widget.json

• Contains meta-data about the Widget

Page 30: Appcelerator Alloy Deep Dive - tiTokyo 2013

To use the Widget

• Define it as a dependency on your “config.json” file

• Use the “Require” tag to include it in your XML file

Page 31: Appcelerator Alloy Deep Dive - tiTokyo 2013

Live Demo

Page 32: Appcelerator Alloy Deep Dive - tiTokyo 2013

Adding data to your app

Page 33: Appcelerator Alloy Deep Dive - tiTokyo 2013

With Alloy you can use backbone.js to create data-bound controls

• Model creation is built into Titanium Studio

Page 34: Appcelerator Alloy Deep Dive - tiTokyo 2013

The “model file”

• The generated “model file” defines a data structure and a data store

Page 35: Appcelerator Alloy Deep Dive - tiTokyo 2013

Bind your model to a UI control

• The “Collection” Tag allows you to define a data collection based on your model, and bind it to your TableView

Page 36: Appcelerator Alloy Deep Dive - tiTokyo 2013

Data can be added dynamically

• Reference data elements from within your XML

Page 37: Appcelerator Alloy Deep Dive - tiTokyo 2013

Live Demo

Page 38: Appcelerator Alloy Deep Dive - tiTokyo 2013

There’s much more!

• Sync Adapters• Migrations• Underscore.js functionalities• Command-Line Interface (CLI)• Appcelerator Cloud Services (ACS)

Page 39: Appcelerator Alloy Deep Dive - tiTokyo 2013

Alloy 1.0 is out! Here’s what new:

• Only works with Ti SDK 3.0 and later• Android fastdev• New SQL Adapter inline with our

updated adapter model• Content Assist in Studio: it will be

officially released in 3.1.0 but it is already available in the nightly stream

Page 40: Appcelerator Alloy Deep Dive - tiTokyo 2013

What’s next with Alloy?

• Debugging of Alloy apps in Studio (coming in 3.1.0)

• Dynamic Styling of Apps• Adapter framework• Widget models and themes• Finalizing model-view binding

Page 41: Appcelerator Alloy Deep Dive - tiTokyo 2013

Code

• All code samples in this presentation can be found at:

http://github.com/ricardoalcocer

Page 42: Appcelerator Alloy Deep Dive - tiTokyo 2013

Thank you

Ricardo [email protected]

Follow me on Twitter @ricardoalcocer