Smartphones zijn niet meer weg te denken uit het dagelijks leven. Bedrijven ontwikkelen steeds meer en meer toepassingen om hun producten of diensten via deze smartphones aan te bieden.
Sencha Touch stelt ontwikkelaars in staat om met behulp van HTML5, CSS en JavaScript applicaties te bouwen die zowel op Android als op iOS draaien.
Deze technische sessie wordt gegeven door Tom Druyts.
19. DEPENDENCY
MANAGEMENT
Only include the sencha-touch-debug.js file
Use Ext.create to create new objects
• Will automatically load the class if it isn’t loaded yet
• No need to write the imports yourself anymore
22. CONFIG
If we got a lot of properties, you need to write a lot of
getters and setters
Nobody likes writing getters and setters, it is just boring
Put them in a config object, and get the setters and
getters for free
29. CLASS SYSTEM
Basic understanding of the Class system
Powerful system built in the framework to make the life
of developers much easier
Now we can stop the boring stuff and start writing
applications
34. APP.JS
Defines the entry point of the application
The launch function will automatically be called when the
framework is loaded
Within the launch function, create your first view and add
it to the viewport
35. VIEWS
Views are what the user interacts with directly
Sencha Touch comes with a wide range of predefined
views that you can use
• Panels, Containers
• Buttons
• Lists
• Textfields, checkboxes, toggle fields
• …
Must be created in the view subfolder
36. CONTROLLERS
Controllers are responsible for responding to events that
occur within your app
They are automatically created when the application is
launched
Makes use of the powerful twin configuration:
• Refs
• Controls
37. CONTROLLERS: REFS
Used to get a reference to a component
Makes use of the ComponentQuery syntax to the locate
components
Example:
Refs: {
homeButton: ‘#home’
}
You get the getter for free !
39. CONTROLLERS: ROUTES
Since Sencha Touch 2 controllers have support for Routes
Enables History support
Example:
Routes: {
‘login’: ‘showLogin’
}
Will listen to http://myApp.com/#login
41. MODELS: FIELDS
Defines the properties of the model
Consists of:
• Name
• Type
fields: {
{name: ‘id’, type: ‘int’}
{name: ‘name’, type: ‘string’}
}
42. MODELS: PROXIES
Defines where and how to load/save the data
Mainly used by stores
You must define:
• Type of proxy
• The URL
• The reader (json or xml)
44. PROXIES: REST
var broodje = Ext.create(‘App.model.Broodje’, {name: ‘smos kaas’});
broodje.save() // POST /broodjes
broodje.destroy() //DELETE /broodjes/123
If not happy with the default URLs, implement the
buildUrl method to customize the generated URLs
45. MODELS:
ASSOCIATIONS
Most applications have relations between models
The associations API enables developers to express those
relations
Possibilities:
• hasMany
• belongsTo
47. ASSOCIATIONS: THE
BENEFITS
Benefits off defining associations:
• Data of ‘child’ members get automatic loaded
• Easy to traverse the associated data
broodje.ingredients().each(function(ingredient) {
console.log(ingredient);
});
48. MODELS: VALIDATIONS
Models have support for validations
Possible validations:
• Presence
• Length
• Format
• Inclusion
• Exclusion
50. MODELS: VALIDATIONS
How to use ?
var newUser = Ext.create('User',
{ name: 'admin', age: 'twenty-nine', gender: 'not a valid gender' }
);
var errors = newUser.validate();
errors.isValid(); //returns false if there were validations errors
errors.items(); //returns an array of all errors
51. STORES
Is just basically a collection of model instances
Are used to load data into a List
Can optionally use a Proxy to load the required data
Support for sorting & grouping
52. HYBRID APPLICATIONS
This is all nice but we are still running in the browser
What if we want a ‘real’ application ?
What if we want to access device functionality like
• Contacts list
• Camera
• Photos
• …
53. HYBRID ?
Site
Web sites
Web apps
Native app
App
Native
54. HYBRID ?
Site
Web sites
Web apps
Hybrid
apps
Native app
App
Native
55. HYBRID ?
WebFont Video Audio Graphics
Camera HTTP
CSS Styling & Layout
Location AJAX
JavaScript
Contacts Events
Semantic HTML
SMS Sockets
Parralel Cross app
File system
processing messagin
56. HYBRID ?
WebView
WebFont Video Audio Graphics
Camera HTTP
CSS Styling & Layout
Location AJAX
JavaScript
Contacts Events
Semantic HTML
SMS Sockets
Parralel Cross app
File system
processing messagin
57. Native wrapper
WebView
WebFont Video Audio Graphics
Camera HTTP
CSS Styling & Layout
Location AJAX
JavaScript
Contacts Events
Semantic HTML
SMS Sockets
Parralel Cross app
File system
processing messagin
58. SENCHA TOOLS
Sencha Tools allows you to build a Native Wrapper
Build your project with the Sencha Tools and you get a
native app
But what about the left side ?
59. PHONEGAP
Tries to close the gap between web apps and access to
the device APIs
Different on every platform
Access to:
• Camera
• Contacts
• Notification
• Storage
• …
Je bentzelfverantwoordelijkom .validate() op teroepen ! Gebeurtnietautomatisch !
Network technologies on the right. Platform integration on the bottom. Device APIs on the left.Meestewebbrowser op iPhone, Android,… is beter in het rechterbovengedeelte. En slecht, of nietbestaandeaan de linkerkant.Je hebtdusgeentoegang tot de contactenlijst, sms, de camera, en alleandere device APIs… En het onderste is redelijkondersteund.Duswatkunnen we nu doen ? Het feitdat browser het rechterbovenstegedeeltegoedondersteunenwillen we nietverliezen, dusdatgaan we wrappen.
Wemakengebruik van een embedded webviewdatditgedeelteondersteunt.
En we stoppendeze embedded webview in een native wrapper. Onze native wrapper is dusgewooneenwebview, die al dezefunctionaliteitondersteunten waarin we onzeapplicatiedraait. Ditblijkteenenormpopulaireoplossing