SlideShare a Scribd company logo
Getting Started with Titanium & Alloy
January 6, 2016
Fokke Zandbergen
Developer Evangelist
Appcelerator
@FokkeZB
Pierre van de Velde
CTO
TheSmiths
@PierreVdeV
Nice to meet you!
Program
!"
1. The Big Picture
2. Signup & Setup
!
3. Titanium
!
4. Alloy
!
5. Ten More Things (we wish we’d known)
!
The Big Picture
Getting Started with Titanium & Alloy
Getting Started with Titanium & Alloy
Getting Started with Titanium & Alloy
Getting Started with Titanium & Alloy
Signup & Setup
www.appcelerator.org
• Titanium CLI
/appcelerator/titanium
[sudo] npm install -g titanium && ti setup
• Titanium SDK *
/appcelerator/titanium_mobile
ti sdk install -b 5_1_X -d
• Alloy CLI
/appcelerator/alloy
[sudo] npm install -g alloy
www.appcelerator.com/signup
web.appcelerator.com
Prerequisites
Break
Titanium
NO!
Getting Started with Titanium & Alloy
HTML apps
#
JS2Native
Architecture
Alloy Codebase Development
JavaScript
Package
Run-time
Titanium
Module APIs
Titanium
Core APIs
Hyperloop
APIs
Kroll
(iOS/Android)
HAL
(Windows)
3P APIs OS Device & UI APIs Platform
Hello World
var window = Ti.UI.createWindow({
backgroundColor: “white"
});
var label = Ti.UI.createLabel({
text: “Hello World”
});
label.addEventListener(“click”,
function open() {
alert(“Hello World”);
}
);
window.add(label);
window.open();
Ti API
Ti.createMyFartApp()
Ti.UI.createX() // Cross-platform UI View factories
Ti.UI.X // The UI View proxy the factory creates
Ti.UI.iOS.createX() // Platform specific UI View factories
Ti.X // Cross-platform device APIs
Ti.Android.X // Platform specific device APIs
require(“ti.map”).X // CommonJS & Titanium Modules
docs.appcelerator.com
File Structure
▾ Resources
▾ images
logo.png
app.js
main.js
utils.js
tiapp.xml config
code
DEMO
Break
Getting Started with Titanium & Alloy
Alloy MVC
Classic Spaghetti
var window = Ti.UI.createWindow({
backgroundColor: “white"
});
var label = Ti.UI.createLabel({
text: “Hello World”
});
label.addEventListener(“click”,
function open() {
alert(“Hello World”);
}
);
window.add(label);
window.open();
style
logic
markup
<Alloy>
<Window>
<Label onClick=”open”>Hello World</Label>
</Window>
</Alloy>
”Window”: {
backgroundColor: “white”
}
function open() {
alert(“Hello World”);
}
$.index.open();
index.xml
index.tss
index.js
Alloy
▸ app
▾ Resources
▾ alloy
▾ controllers
index.js
backbone.js
CFG.js
underscore.js
▾ images
logo.png
alloy.js
app.js
utils.js
tiapp.xml
▾ Resources
▾ images
logo.png
app.js
main.js
utils.js
tiapp.xml
▾ app
▾ assets
▾ images

logo.png
▾ controllers
index.js
▾ lib
utils.js
▾ styles
index.tss
▾ views
index.xml
▾ widgets
alloy.js
config.json
tiapp.xml
File Structure
Pro Tip: Unhide Resources
Getting Started with Titanium & Alloy
What happens to your XML and TSS?
<Foo>
<Foo ns=“Ti.bar”>
<Foo module=“bar”>
<Require src=“foo”>

<Widget src=“foo”>

<Foo id=“bar”>
<Foo bar=“zoo”>



“#bar”: {

color: “white”

}
Ti.UI.createFoo();
Ti.bar.createFoo();
require(“bar”).createFoo();
Alloy.createController(“foo”)

.getView();
Alloy.createWidget(“foo”)

.getView();
$.bar = Ti.UI.createFoo();
Ti.UI.createFoo({

bar: “zoo”

});
$.bar = Ti.UI.createFoo({

color: “white”

});
app


controllers
views
styles
assets
widgets
controllers
views
styles
assets
themes
styles
assets
Themes & Widgets
☁COLLECTIONSYNC ADAPTERSTORAGE BINDINGS VIEWS
Ti.UI
⚡EVENTS
Data binding
<Alloy>
<Collection src=”album” />
<TableView dataCollection=”album”
dataTransform=”transformer”
dataFilter=”filter”>
<TableViewRow title=”{title} by {artist}” />
</TableView>
</Alloy>
index.xml
function filter(collection) {
return collection.where({artist:”Beatles”});
}
function transformer(model) {
var transformed = model.toJSON();
transformed.title = transformed.title.toUpperCase();
return transformed;
}
index.js
DEMO
Break
Ten More Things
(we wish we’d known)
Protect the Global Scope
var uuid = Ti.Platform.createUUID(); // wrong
(function(global) {
var version = Ti.Platform.version; // safe
Alloy.Globals.iOS8 = version.split(“.”)[0] === ”8”;
global.started = Ti.Platform.createUUID(); // avoid
Alloy.Globals.seed = Ti.Platform.createUUID(); // better
})(this);
alloy.js / app.js
module.exports = {
seed: Ti.Platform.createUUID(); // best
};
utils.js
Share/Re-Use Images
assets/iphone/images/image@2x.png
assets/iphone/images/image@3x.png
assets/images/image.png
assets/android/images/res-mdpi/image.png
assets/android/images/res-xhdpi/image.png
assets/android/images/res-xxhdpi/image.png
assets/android/images/res-xhdpi/some.file
platform/android/res/drawable-xhdpi/some.file
platform/android/res/drawable-nl-port-xhdpi/some.file
assets/some_dir/some.file
assets/android/some_dir/some.file
assets/iphone/some_dir/some.file
BEST
PRACTICE
Use the Alloy CLI
$ [appc] alloy generate controller foo
$ alloy copy foo bar/zoo
$ alloy move foo bar/zoo
$ alloy remove bar/zoo
Use Conditional Code
<Alloy>
<Label platform=”ios,!android”>iOS, Windows</Label>
<Label formFactor=”handheld”>Handheld</Label>
<Label if=”Alloy.Globals.iOS8”>iOS 8</Label>
</Alloy>
”Label[platform=ios,!android formFactor=tablet]”: {
color: “red”
}
”Label[if=Alloy.Globals.iOS8]”: {
backgroundColor: “green”
}
if (OS_IOS && ENV_PRODUCTION && DIST_STORE) {
alert(“iOS App Store, not Ad Hoc”);
}
index.xml
index.tss
index.js
Use Conditional Config
{
"global": {"foo":1},
"env:development": {"foo":2},
"env:test":{"foo":3},
"env:production":{"foo":4},
"os:ios env:production": {"foo":5},
"os:ios env:development": {"foo":6},
"os:ios env:test": {"foo":7},
"os:android":{"foo":8},
"os:mobileweb":{"foo":9},
"dependencies": {
“com.foo.widget":"1.0"
}
}
if (OS_IOS && ENV_TEST && Alloy.CFG.foo !== 7) {
alert(“Wrong!”);
}
config.json > CFG.js
index.js
Get your code organised
You can organise controllers in subfolders.
Use CommonJS modules
module.exports = {
property: value,
util: function() {}
};
module.js
Drop modules .zip files in root directory
Don’t repeat yourself
Use Alloy.CFG to get your config in one place
"global": {
"COLORS": { "WHITE": “#fff" },
"FONTS": { "FONT_FAMILY_LIGHT": “Montserrat-Light" },
"SIZES": { "MARGIN_XSMALL": “5” }
}
config.json
".container": {
top: Alloy.CFG.SIZES.MARGIN_XSMALL,
backgroundColor: Alloy.CFG.COLORS.WHITE
}
style.tss
Use global styling
Create Global styling to be applied everywhere
".Compact": { height: Ti.UI.SIZE, width: Ti.UI.SIZE }
".Left" : { left: 0 }
".Top" : { top: 0 }
".Error" : {
backgroundColor: Alloy.CFG.COLORS.WHITE,
color: Alloy.CFG.COLORS.RED,
}
app.tss
<Label class="Bottom Hidden Error" /> view.xml
Platform specifics
Phones are not fixed size, use layouts
<View class="container" layout="vertical"> view.xml
Use platform specific styling
"ActivityIndicator[platform=android]":{
style: Ti.UI.ActivityIndicatorStyle.DARK
}
"ActivityIndicator[platform=ios]":{
style: Ti.UI.iPhone.ActivityIndicatorStyle.DARK
}
style.tss
Specifics folders for platform & density
Getting Started with Titanium & Alloy
www.tislack.org

More Related Content

PDF
Appcelerator Alloy MVC
PDF
Building Native Mobile Apps using Javascript with Titanium
PPT
Titanium Alloy Framework
PPTX
MDC2011 Android_ Webdriver Automation Test
PDF
Appcelerator Titanium Alloy
PPTX
Alloy Simple App Demonstration
PPTX
TiConf EU 2014
PDF
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
Appcelerator Alloy MVC
Building Native Mobile Apps using Javascript with Titanium
Titanium Alloy Framework
MDC2011 Android_ Webdriver Automation Test
Appcelerator Titanium Alloy
Alloy Simple App Demonstration
TiConf EU 2014
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組み

What's hot (20)

PDF
Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors
PDF
しごとで使うTitanium 第2版
PDF
Titanium 最近の動向 (2016年)
PDF
Ti.conf titanium on firefoxos
PDF
TiCalabash: Fully automated Acceptance Testing @ TiConf EU 2014
PDF
Vietnam qa meetup
PDF
Android1.5~8.0 Walkthrough
PDF
Front End Development for Back End Developers - UberConf 2017
PDF
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
ODP
iOS Automation with Cucumber, Appium and Saucelabs
PDF
Bootiful Development with Spring Boot and React - RWX 2017
PDF
Rapid Android Development for Hackathon
ODP
5 Reasons Why Maven Sux
PDF
Bootiful Development with Spring Boot and React - SpringOne 2017
PDF
Front Ends for Back End Developers - Spring I/O 2017
PPT
Os Johnson
PDF
Front End Development for Backend Developers - GIDS 2019
PDF
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
ODP
iOS Developers Conference-iOS Automation with Cucumber, Appium and Saucelabs
PDF
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors
しごとで使うTitanium 第2版
Titanium 最近の動向 (2016年)
Ti.conf titanium on firefoxos
TiCalabash: Fully automated Acceptance Testing @ TiConf EU 2014
Vietnam qa meetup
Android1.5~8.0 Walkthrough
Front End Development for Back End Developers - UberConf 2017
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
iOS Automation with Cucumber, Appium and Saucelabs
Bootiful Development with Spring Boot and React - RWX 2017
Rapid Android Development for Hackathon
5 Reasons Why Maven Sux
Bootiful Development with Spring Boot and React - SpringOne 2017
Front Ends for Back End Developers - Spring I/O 2017
Os Johnson
Front End Development for Backend Developers - GIDS 2019
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
iOS Developers Conference-iOS Automation with Cucumber, Appium and Saucelabs
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Ad

Viewers also liked (17)

PPTX
Manila-An Update from Liberty
PDF
Paseo Virtual (Google Earth)
PDF
Jcc manhattan boot camp
PDF
Prensa Radio Digital
DOC
10.05.04.03_questionário satisfação serviços
PDF
Oracle
PPTX
Principales enfermedades caprinas
PPTX
Requerimientos nutricionales en caprinos po
PPTX
Осадчук, корекція
PPTX
Корекційна робота, Фіщук
PPT
Vocabulary unit 1. Living things
PPTX
Unidad 6. Diseño de Bloques Completos al Azar
PPTX
2016 02 10 la ermita 5 años
PPTX
2015 05 10 1ºeso centro metereológico 2016
PPTX
2016 06 20 piscifactoría 1º y 2º ep
Manila-An Update from Liberty
Paseo Virtual (Google Earth)
Jcc manhattan boot camp
Prensa Radio Digital
10.05.04.03_questionário satisfação serviços
Oracle
Principales enfermedades caprinas
Requerimientos nutricionales en caprinos po
Осадчук, корекція
Корекційна робота, Фіщук
Vocabulary unit 1. Living things
Unidad 6. Diseño de Bloques Completos al Azar
2016 02 10 la ermita 5 años
2015 05 10 1ºeso centro metereológico 2016
2016 06 20 piscifactoría 1º y 2º ep
Ad

Similar to Getting Started with Titanium & Alloy (20)

PDF
Titanium Alloy Tutorial
PPTX
Codestrong 2012 breakout session alloy (mvc) app framework overview
PPTX
Alloy - Codestrong 2012
PDF
Appcelerator Titanium Intro (2014)
PPTX
Alloy Framework
PPTX
Presentation
PPTX
Intro to appcelerator
PDF
Appcelerator Titanium Alloy
PDF
TiAppCamp Atlanta 2013: Alloy Overview
ZIP
iPhone/iPad Development with Titanium
KEY
Appcelerator iPhone/iPad Dev Con 2010 San Diego, CA
PPTX
Appcelerator Alloy Deep Dive - tiTokyo 2013
PPTX
Appcelerator Alloy Deep Dive - tiTokyo 2013
PDF
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
PPTX
Dev summer-keynote
PPTX
Appcelerator Titanium Intro
PDF
Titanium #MDS13
PDF
An introduction to Titanium
PPTX
Titanium Workshop - [Sainté Mobile Days]
PPT
Titanium Meetup Deck
Titanium Alloy Tutorial
Codestrong 2012 breakout session alloy (mvc) app framework overview
Alloy - Codestrong 2012
Appcelerator Titanium Intro (2014)
Alloy Framework
Presentation
Intro to appcelerator
Appcelerator Titanium Alloy
TiAppCamp Atlanta 2013: Alloy Overview
iPhone/iPad Development with Titanium
Appcelerator iPhone/iPad Dev Con 2010 San Diego, CA
Appcelerator Alloy Deep Dive - tiTokyo 2013
Appcelerator Alloy Deep Dive - tiTokyo 2013
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
Dev summer-keynote
Appcelerator Titanium Intro
Titanium #MDS13
An introduction to Titanium
Titanium Workshop - [Sainté Mobile Days]
Titanium Meetup Deck

More from Fokke Zandbergen (19)

PDF
Building the (Support) Robot at Zapier
PDF
Lessons from helping developers integrate 1,000 APIs with Zapier
PDF
We are all Remote Advocates
PDF
Cross-platform Native App ontwikkeling met Appcelerator
PDF
Cross-Platform Native Apps with JavaScript
PDF
Titanium: Develop Native Mobile Apps with JavaScript
PDF
Appcelerator OSS & Platform
PDF
Platform 4.0 Meetup Launch Event
PDF
The Ultimate Titanium CLI Toolchain
PDF
Getting ready for iOS 8 & iPhone 6
PDF
Titanium Community Toolkit Showcase
PDF
5 app alternatieven #AIB2013
PDF
Apps voor kerken #Kerk2013
PDF
TiNy #TiAppCamp
PDF
Internetmarketing
PDF
Alloy Tips & Tricks #TiLon
PDF
Alloy #DMC13
Building the (Support) Robot at Zapier
Lessons from helping developers integrate 1,000 APIs with Zapier
We are all Remote Advocates
Cross-platform Native App ontwikkeling met Appcelerator
Cross-Platform Native Apps with JavaScript
Titanium: Develop Native Mobile Apps with JavaScript
Appcelerator OSS & Platform
Platform 4.0 Meetup Launch Event
The Ultimate Titanium CLI Toolchain
Getting ready for iOS 8 & iPhone 6
Titanium Community Toolkit Showcase
5 app alternatieven #AIB2013
Apps voor kerken #Kerk2013
TiNy #TiAppCamp
Internetmarketing
Alloy Tips & Tricks #TiLon
Alloy #DMC13

Recently uploaded (10)

PDF
Kids, Screens & Emotional Development by Meenakshi Khakat
DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
DOC
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
PPTX
ASMS Telecommunication company Profile
DOC
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
PPTX
Social Media People PowerPoint Templates.pptx
PPTX
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
PDF
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
PDF
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf
Kids, Screens & Emotional Development by Meenakshi Khakat
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
ASMS Telecommunication company Profile
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
Social Media People PowerPoint Templates.pptx
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf

Getting Started with Titanium & Alloy