Sencha Touch: Html5 and Javascript Mobile Web App Framework
Sencha Touch: Html5 and Javascript Mobile Web App Framework
By Akshay Prabhu
[email protected]
Building Applications on mobile
To build applications on
different mobile platforms we
would require knowledge of
objective c for ios, android sdk
for android platform or j2me.
http://www.sencha.com/products/touch/
Sencha Touch.js
SenchaTouch.css
In this HTML file, we would now link the necessary files from the Sencha Touch
<!DOCTYPE
library . html>
<html>
<head>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=us-
ascii" />-->
<title>Overlay</title>
</head>
</body>
</html>
Create the application JavaScript File:-
myapp.js the file where the actual code of the application would reside.
Ext.setup({
tabletStartupScreen:'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: true,
onReady: function() {
// write your Sencha Code here
}
});
BUILDING MOBILE USER INTERFACES WITH SENCHA
TOUCH
It also contains several ready to use icons which are stored in the form
There are several default themes that can be used in the web
Application and even the CSS is highly customizable
There are several extensions called as UX which can be included in
the Sencha library. For eg:-UX Touch Grid Panel.
Sencha Touch Components
Panels
It can contain an
array of different
Sencha
components
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: true,
onReady: function() {
new Ext.Panel ({
fullscreen : true ,
items : [ ] ,
dockedItems : [ ]
});
}
});
Docked Items Example
},
{
title: 'Tab 2',
html: '2'
},
{
title: 'Tab 3',
html: '3'
}]
});
Templates and XTemplates
Templates are useful to
var planetinfo=new Ext.Template( render data in a
‘<table>’, customized way by
creating a HTML
‘<tr>’, Template.
‘<td>’, With the help of
XTemplates we can also
'<h2>Name:{name}</h2>', create a for loop to run
through the array of
‘</td>’, items or an If loop to
place conditional
‘</tr>’, statements.
‘</table>>’ They are frequently used
with store class to render
)
some data in a
customized way.
List of Formatting Functions with
Templates
• ellipsis(length): Useful for when you want to only show the first x characters and then
provide a more detailed view.
• htmlEncode: If the variable contains ampersands, less than, greater than symbols or
quotes HTML escape them.
• date[(format)]: Transform the variable to a date format, if the format argument is omitted
uses the mask 'm/d/Y' .
Data Stores
Ext.regModel('Task',
{
For data-driven controls - such as
fields: [
Lists and Trees, Sencha Touch
{name: 'name', type: 'string'},
requires that you use their data model
{name: 'description', type: 'string'}
abstraction.
]
})
]
)};
Step 2 Step 3
listPanel = new Ext.List({ wrapperpanel=new Ext.Panel({
id: 'disclosurelist',
store: storex, id:'wrapperpan',
grouped:'true', items:listPanel,
}); });
Other useful Sencha Components
var datePicker = new
Ext.DatePicker({
useTitles: true,
});
xtype:'button',
text:'Test',
handler:function(){
Ext.Msg.prompt('Welcome','Enter
First Name', Ext.emptyFn);
} Prompt Box
Maps in Sencha Touch
Sencha Touch also provides the
Map class.
This class requires the Google
Map API, below is the example
to illustrate the same
new Ext.Panel({
fullscreen:true,
items:[
{
xtype: ’map’ ,
title: ’ Maps ’
}
]
});
Sencha Touch UX Extensions
In addition to the
existing Sencha
Components, there
are many extensions
available to the
existing library.
]
});
Touch Grid Panel(Continued)
var colModel = [{
header: "<span style='font-size:13px'>AppName</span>",
mapping: "AppName",
style: "text-align: center;"
}, { new Ext.ux.TouchGridPanel({
header: "<span style='font-size:13px'>Description</span>", store: store,
mapping: "Description", colModel: colModel,
style: "text-align: center;"
}, {
header: "<span style='font-size:13px'>Type</span>", });
mapping: "Type",
style: "text-align: center;"
}, {
header: "<span style='font-size:13px'>Download</span>",
mapping: "Download",
cls: "centered-cell",
}
];
Animations
Sencha Touch provides many animation schemes like:-
Slide
Pop
Fade
Cube
Flip
panel.
Sencha Touch Events
EventPanel.addListener({
In the example,
body:{ touch events
swipe: function()
are added to
{Ext.Msg.alert( "Title" , "swiped");},
tap: function() the body or
{Ext.Msg.alert( "Title" , "Tapped");} element
} section if the
panel.
});
});
Difference between Panel and Panel Body or Element
The framework’s provide many ready to use themes
that make the Web App look native
Limitations of Sencha Touch
Sencha touch API doesn't have the following capabilty:
Access to camera
Access to contacts
Access to accelerometer
native applications.
Components.
Also, as shown in the figure deep
as far as possible
Using background image as
panel.on('cardswitch',
function(newCard, oldCard) { if gradient should be ac\voided,
(oldCawrd) CSS3 properties should be used
{ this.remove(oldCard, true); } }, instead to apply gradient effect.
panel);
Sencha Touch Community
Demos
http://dev.sencha.com/de
ploy/touch/examples/kitch
ensink/
http://touchsolitaire.mobi/
app/
http://dev.sencha.com/de
ploy/touch/examples/kiva/
Learning Resources For Sencha
http://dev.sencha.com/deploy/touch/examples/kitchensink/
http://www.sencha.com/learn/Sencha_Touch
http://miamicoder.com/2010/creating-sencha-touch-toolbar-buttons/
http://www.sencha.com/learn/Tutorial:Sencha_Touch_Hello_World
Video Tutorials:-
http://vimeo.com/channels/sencha