0
Sencha Touch Intro Web Based Native(ish) Apps
 
 
 
Setup Viewport Data View
Setup
Download The SDK <ul><ul><li>Extract contents </li></ul></ul><ul><ul><li>Grab the CSS files from resources/css folder </li...
Create Base HTML <ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title>BmoreJS Mobile</title> </li></ul><ul><li...
Include CSS & JS <ul><li>     <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;sencha-touch-debug.css...
Setup The Aplication <ul><li>     <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: ...
Setup The Aplication <ul><li>     <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: ...
Setup The Aplication <ul><li>     <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: ...
320x460
http://tinyurl.com/iosicon 57x57
Setup The Aplication <ul><li>     <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: ...
Viewport
Create The Viewport <ul><li>     <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li...
Create The Viewport <ul><li>     <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li...
Create The Viewport <ul><li>     <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li...
Create The Viewport <ul><li>     <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li...
 
Docked Items <ul><li>        this.viewport = new Ext.Panel({ </li></ul><ul><li>             fullscreen: true, </li></ul><u...
 
Buttons <ul><li>             dockedItems: [{ </li></ul><ul><li>                 xtype: &quot;toolbar&quot;, </li></ul><ul>...
 
Button UI <ul><li>             dockedItems: [{ </li></ul><ul><li>                 xtype: &quot;toolbar&quot;, </li></ul><u...
Standard Button UI's Color Variations confirm                                         decline
Data
Data Store Model Reader Proxy Source
Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     ...
Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     ...
Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     ...
Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul>...
Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul>...
Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul>...
View
The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul>...
The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul>...
The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul>...
The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul>...
Templates <ul><li>itemTpl: '<a href=&quot;{url}&quot;><img src=&quot;{img}&quot;>{text}</a>', </li></ul>
The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul>...
 
Upcoming SlideShare
Loading in...5
×

Sencha Touch Intro

6,440

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
6,440
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
105
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Im going to give an introduction to sencha touch, which is a web based javascript library that can be used to create native looking apps. I say native looking, or native(ish) because the apps really end up looking and interacting like a native app. The UI elements such as buttons, lists, toolbars, all look very similar to their native counterparts on the iphone. The interactions work the same as well, such as momentum scrolling, swiping and pinching.
  • So where did this library come from. The library came into existence from the company Ext hiring  David Kaneda, who developed jqTouch on his own.   The company formerly called Ext took their Ext JS library and combined the concepts used in it with the cutting edge mobile web development that David had done.
  • The library they created reproduces the look and feel of native iOS apps, and has the JavaScript syntax and structure found in the Ext JS library with an MVC concept thrown in. Currently only Android and iOS devices are supported. BlackBerry 6&apos;s WebKit based browser should be supported in the next release of Sencha Touch and windows mobile should be down the road sometime. So this actually leaves us with a really easy way to develop our apps.
  • It means that when we develop an app, we can test it in Chrome and Safari and we can be fairly sure it will work just fine when used in Android and iOS devices. The library has been developed with these WebKit based browsers in mind. I would also suggest testing your app in not just chrome or safarim, but both Chrome and Safari, because while they share the same rendering engines, they do not share the same javascript engines, and there are subtle differences between them. Both IE and Firefox will fail horribly at this point. Don&apos;t bother. Support for IE or Windows Mobile should be available in the near future, though firefox support is not likely to ever happen, since there is no mobile device that has been made in the last two years that runs firefox. I just threw Opera in here because I felt bad for it. Lets move on to actually creating a simple app.
  • I like to split up this process into four main steps. We first setup the app, these are things that are related to the initial configuration of our app. The viewport is the main UI component of our app, which may contain a toolbar, or tabs, or whatever is the main navigation method of our app. Data is somethinge we of course need, apps aren&apos;t much fun without data. Even angry birds needs data. Finally the view, which is how we display our data, or otherwise interact with specific parts of the app. We can of course have many views, but for this demo we will just have one. Once we get all of these things in place, we should have a working app.
  • Lets start on the setup
  • First thing we need is the SDK download, so grab that from the Sencha web site. Note that it is a free library, and you do not need to put your email address in to download it. To develop the basic app, all we need is the default CSS and JS they provide in the SDK download. Throw these into your project folder.
  • Next we need a simple HTML page. Just the basics will do, as the Sencha Touch library will create all of the HTML elements it needs on its own.
  • Now we need to include the library stylesheet and javascript. These should both be in the head section of the HTML document. The debug versions of both the CSS and JavaScript are used for developing, which contain uncompressed content along with some console messages about improper usage and API changes. Directly after these includes were going to add a script block with the code to setup our Sencha Touch app. This could also be in the form of another javascript include but for the sake of this demo, ill just use a script block.
  • Were done with HTML now. That is all the html we will ever need to write for a Sencha Touch app, from now on, it&apos;s pure JavaScript. Here is a typical application setup. The application setup does a couple of things for us.
  • First off, it sets up a name for our application. This will setup namespaces for views stores, models and controllers based on our app name.    We will use these namespaces later on when we setup our store and model. Since this app is so simple, im not going to take advantage of the view or controller namespaces it creates.
  • *used when in standalone mode, which is when you add a web app to your home screen. webclip.   Next, it sets up the startup screen which is shown while the page is loading in standalone mode. The icon is also used for standalone mode. There are also options for tabletStartupScreen and tabletIcon &lt;link rel=&amp;quot;apple-touch-startup-image&amp;quot; href=&amp;quot;/startup.png&amp;quot;&gt;
  • The startup image for the phone should be 320 x 460 and must be in PNG format. The icon image for phones should be 57x57, however I like to use 114x114 because that is what the retina display uses, and standard displays will scale this down anyway. More details about all of the sizing requirements can be found in apples documentation, which is quite good, though hard to navigate. apple-touch-icon apple-touch-icon-precomposed (glossOnIcon === false)
  • The icon image for phones should be 57x57, however I like to use 114x114 because that is what the retina display uses, and standard displays will scale this down anyway. More details about all of the sizing requirements can be found in apples documentation, which is quite good, though hard to navigate. apple-touch-icon apple-touch-icon-precomposed (glossOnIcon === false)
  • The final part of this setup is the launch function to execute when the browser is ready. This is where we will create our UI. It could be compared to the onload event in html, or if your use to Ext JS, the onReady function.   Lets dive into the UI setup now by stubbing out this launch function and creating the viewport. 
  • step 2 - creating the viewport.
  • *Ext namespace - panel   So I create a Panel, and set it to fullscreen true. Let&apos;s take a look at this in a browser now.
  • *Ext namespace - panel   So I create a Panel, and set it to fullscreen true. Let&apos;s take a look at this in a browser now.
  • *Ext namespace - panel   So I create a Panel, and set it to fullscreen true. Let&apos;s take a look at this in a browser now.
  • *Ext namespace - panel   So I create a Panel, and set it to fullscreen true. Let&apos;s take a look at this in a browser now.
  • Wow, it&apos;s a grey screen. What we are not seeing here is that this panel we created has fit itself into the size of the window and can now manage UI elements to fit within that viewable area, resizing them appropriately if the orientation changes. Then next step is to give it something to manage. Like a toolbar maybe.
  • A docked item can be docked to any side of the screen and will stick there when the user is scrolling the page, along with moving position when the orientation changes. We can add the docked item to the main viewport screen as we have done here, and it will persist between section changes, or we can create a unique docked item for each section. The former method that we are using here is the more resource efficent. Let&apos;s see what this looks like now.
  • There is our docked item, the toolbar with a title. as long as were here, lets go ahead and add a button.
  • *items = children   We do this by adding an item to the items array of the toolbar.  We don&apos;t need to specify that its a button were adding, because the toolbar default to using buttons. Lets take a look at what this looks like.   Don&apos;t ask about UI right now.
  • There we go, we have a back button. You might be wondering why it&apos;s a back button, instead of a regular looking button. This all comes down to the UI configuration.
  • The button UI options are &apos;normal&apos;, &apos;back&apos;, &apos;round&apos;, &apos;action&apos;, &apos;forward&apos; and &apos;small&apos;, with the default being &apos;normal&apos;.
  • The normal, round and small options also have a confirm and decline version, which are just green and red versions of the same buttons. Let&apos;s move on to getting our data loaded into the app. For this we will need three things.
  • The model that defines what our data looks like, the store holds  data - along with a proxy - that will fetch our data.
  • Creating the model is fairly straight forward, we just need to give our model a name and describe the fields that are contained within it.
  • We give it a name of Statuses, since im going to pull in my timeline of statuses from Twitter.
  • Then we define what our data looks like. Now that we have a model of our data in place, lets create a store.
  • Our store is also fairly straight forward, particulairly if your use to using Ext JS. SInce we gave our app the BmoreJS name there is a namespace setup for stores which were going to use.
  • We use the model we just created.
  • and fetch the data with a script tag (which lets us do cross domain requests) from the Twitter API. Now that this is in place, we need a way to view the data.
  • back in our viewport, we add a list that is tied to the store we just created.
  • back in our viewport, we add a list that is tied to the store we just created.
  • back in our viewport, we add a list that is tied to the store we just created.
  • back in our viewport, we add a list that is tied to the store we just created.
  • back in our viewport, we add a list that is tied to the store we just created.
  • make overview slide showing whole process. place between each section.
  • Transcript of "Sencha Touch Intro"

    1. 1. Sencha Touch Intro Web Based Native(ish) Apps
    2. 5. Setup Viewport Data View
    3. 6. Setup
    4. 7. Download The SDK <ul><ul><li>Extract contents </li></ul></ul><ul><ul><li>Grab the CSS files from resources/css folder </li></ul></ul><ul><ul><li>Grab the JS files from the root folder </li></ul></ul>
    5. 8. Create Base HTML <ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title>BmoreJS Mobile</title> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>
    6. 9. Include CSS & JS <ul><li>     <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;sencha-touch-debug.css&quot;> </li></ul><ul><li>     <script type=&quot;application/javascript&quot; src=&quot;sencha-touch-debug.js&quot;></script> </li></ul>
    7. 10. Setup The Aplication <ul><li>    <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: 'BmoreJS',         phoneStartupScreen: 'phone-startup.png',         phoneIcon: 'apple-touch-icon.png',         launch: function(){} </li></ul><ul><li>    });     </script> </li></ul>
    8. 11. Setup The Aplication <ul><li>    <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: 'BmoreJS',         phoneStartupScreen: 'phone-startup.png',         phoneIcon: 'apple-touch-icon.png',         launch: function(){} </li></ul><ul><li>    });     </script> </li></ul>
    9. 12. Setup The Aplication <ul><li>    <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: 'BmoreJS',         phoneStartupScreen: 'phone-startup.png',         phoneIcon: 'apple-touch-icon.png',         launch: function(){} </li></ul><ul><li>    });     </script> </li></ul>
    10. 13. 320x460
    11. 14. http://tinyurl.com/iosicon 57x57
    12. 15. Setup The Aplication <ul><li>    <script type=&quot;application/javascript&quot;>     Ext.regApplication({         name: 'BmoreJS',         phoneStartupScreen: 'phone-startup.png',         phoneIcon: 'apple-touch-icon.png',         launch: function(){} </li></ul><ul><li>    });     </script> </li></ul>
    13. 16. Viewport
    14. 17. Create The Viewport <ul><li>    <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li></ul><ul><li>            this.viewport = new Ext.Panel({ </li></ul><ul><li>                 fullscreen: true </li></ul><ul><li>             }); </li></ul><ul><li>         } </li></ul><ul><li>    ...     </script> </li></ul>
    15. 18. Create The Viewport <ul><li>    <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li></ul><ul><li>            this.viewport = new Ext.Panel({ </li></ul><ul><li>                 fullscreen: true </li></ul><ul><li>             }); </li></ul><ul><li>         } </li></ul><ul><li>    ...     </script> </li></ul>
    16. 19. Create The Viewport <ul><li>    <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li></ul><ul><li>            this.viewport = new Ext.Panel({ </li></ul><ul><li>                 fullscreen: true </li></ul><ul><li>             }); </li></ul><ul><li>         } </li></ul><ul><li>    ...     </script> </li></ul>
    17. 20. Create The Viewport <ul><li>    <script type=&quot;application/javascript&quot;>     ...         launch: function(){ </li></ul><ul><li>            this.viewport = new Ext.Panel({ </li></ul><ul><li>                 fullscreen: true </li></ul><ul><li>             }); </li></ul><ul><li>         } </li></ul><ul><li>    ...     </script> </li></ul>
    18. 22. Docked Items <ul><li>       this.viewport = new Ext.Panel({ </li></ul><ul><li>             fullscreen: true, </li></ul><ul><li>             dockedItems: [{ </li></ul><ul><li>                 xtype: &quot;toolbar&quot;, </li></ul><ul><li>                 dock: &quot;top&quot;, </li></ul><ul><li>                 title: 'BmoreJS' </li></ul><ul><li>             }] </li></ul><ul><li>       }); </li></ul>
    19. 24. Buttons <ul><li>             dockedItems: [{ </li></ul><ul><li>                 xtype: &quot;toolbar&quot;, </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     ui: 'back', </li></ul><ul><li>                     text: 'back', </li></ul><ul><li>                     handler: function(){} </li></ul><ul><li>                 }] </li></ul><ul><li>             }] </li></ul>
    20. 26. Button UI <ul><li>             dockedItems: [{ </li></ul><ul><li>                 xtype: &quot;toolbar&quot;, </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     ui: 'back', </li></ul><ul><li>                     text: 'back', </li></ul><ul><li>                     handler: function(){} </li></ul><ul><li>                 }] </li></ul><ul><li>             }] </li></ul>
    21. 27. Standard Button UI's Color Variations confirm                                         decline
    22. 28. Data
    23. 29. Data Store Model Reader Proxy Source
    24. 30. Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     }); </li></ul>
    25. 31. Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     }); </li></ul>
    26. 32. Model <ul><li>     Ext.regModel('Statuses', { </li></ul><ul><li>         fields: ['id_str','text'] </li></ul><ul><li>     }); </li></ul>
    27. 33. Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul><ul><li>         proxy: { </li></ul><ul><li>             type: 'scripttag', </li></ul><ul><li>             url: 'http://api.twitter.com/1/statuses/user_timeline.json', </li></ul><ul><li>             extraParams: { </li></ul><ul><li>               screen_name: 'bmorejs' </li></ul><ul><li>             } </li></ul><ul><li>         }, </li></ul><ul><li>         autoLoad: true </li></ul><ul><li>     }); </li></ul>
    28. 34. Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul><ul><li>         proxy: { </li></ul><ul><li>             type: 'scripttag', </li></ul><ul><li>             url: 'http://api.twitter.com/1/statuses/user_timeline.json', </li></ul><ul><li>             extraParams: { </li></ul><ul><li>               screen_name: 'bmorejs' </li></ul><ul><li>             } </li></ul><ul><li>         }, </li></ul><ul><li>         autoLoad: true </li></ul><ul><li>     }); </li></ul>
    29. 35. Store <ul><li>     BmoreJS.stores.Statuses = new Ext.data.Store({ </li></ul><ul><li>         model: 'Statuses', </li></ul><ul><li>         proxy: { </li></ul><ul><li>             type: 'scripttag', </li></ul><ul><li>             url: 'http://api.twitter.com/1/statuses/user_timeline.json', </li></ul><ul><li>             extraParams: { </li></ul><ul><li>               screen_name: 'bmorejs' </li></ul><ul><li>             } </li></ul><ul><li>         }, </li></ul><ul><li>         autoLoad: true </li></ul><ul><li>     }); </li></ul>
    30. 36. View
    31. 37. The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     xtype: 'list', </li></ul><ul><li>                     itemTpl: '{text}', </li></ul><ul><li>                     store: BmoreJS.stores.Statuses </li></ul><ul><li>                 }] </li></ul><ul><li>                 ... </li></ul><ul><li>             }); </li></ul>
    32. 38. The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     xtype: 'list', </li></ul><ul><li>                     itemTpl: '{text}', </li></ul><ul><li>                     store: BmoreJS.stores.Statuses </li></ul><ul><li>                 }] </li></ul><ul><li>                 ... </li></ul><ul><li>             }); </li></ul>
    33. 39. The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     xtype: 'list', </li></ul><ul><li>                     itemTpl: '{text}', </li></ul><ul><li>                     store: BmoreJS.stores.Statuses </li></ul><ul><li>                 }] </li></ul><ul><li>                 ... </li></ul><ul><li>             }); </li></ul>
    34. 40. The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     xtype: 'list', </li></ul><ul><li>                     itemTpl: '{text}', </li></ul><ul><li>                     store: BmoreJS.stores.Statuses </li></ul><ul><li>                 }] </li></ul><ul><li>                 ... </li></ul><ul><li>             }); </li></ul>
    35. 41. Templates <ul><li>itemTpl: '<a href=&quot;{url}&quot;><img src=&quot;{img}&quot;>{text}</a>', </li></ul>
    36. 42. The List <ul><li>             this.viewport = new Ext.Panel({ </li></ul><ul><li>                 layout: 'fit', </li></ul><ul><li>                 ... </li></ul><ul><li>                 items: [{ </li></ul><ul><li>                     xtype: 'list', </li></ul><ul><li>                     itemTpl: '{text}', </li></ul><ul><li>                     store: BmoreJS.stores.Statuses </li></ul><ul><li>                 }] </li></ul><ul><li>                 ... </li></ul><ul><li>             }); </li></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×