Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to Ionic App Framework

Intro to Ionic App Framework

A brief introduction to the Ionic App Framework. NOTE: Video recording of the talk coming soon.

Matt Stauffer

July 17, 2014
Tweet

More Decks by Matt Stauffer

Other Decks in Technology

Transcript

  1. Ionic
    @stauffermatt
    Intro to
    App Framework

    View Slide

  2. Matt Stauffer
    @stauffermatt
    Partner, Technical Director
    Tighten Co.
    tighten.co

    View Slide

  3. What is Ionic?
    A frontend framework,
    built on Cordova, Angular,
    and Sass.

    View Slide

  4. View Slide

  5. PhoneGap vs. Cordova
    2009: PhoneGap started at Nitobi
    2011: PhoneGap purchased by Adobe
    2012: PhoneGap donated from Adobe to Apache
    Software Foundation, and renamed as Cordova

    Today: PhoneGap is a distribution of Cordova,
    like(ish) Webkit -> Safari and Chrome

    View Slide

  6. View Slide

  7. PROS CONS
    Pros and Cons of Cordova/Ionic-based app dev
    • Faster development
    • Using web-based
    technology, so smaller
    learning curve for web devs
    • Cross-platform out of the
    box
    • Can be less performant than
    native on some less-capable
    devices
    • Limited to the UI capabilities
    of modern web
    • Ionic is opinionated—faster
    dev but sometimes less
    flexibility

    View Slide

  8. Prerequisites
    1. Install Node/NPM
    2. Install Ruby/Sass
    3. Learn the basics of Angular and Sass
    4. (optional) Install Gulp
    5. (optional) Install Xcode or Android Eclipse/
    SDK for distribution

    View Slide

  9. Steps to your first
    Ionic Project

    View Slide

  10. Install Ionic globally
    STEP 1

    View Slide

  11. $ npm install -g cordova ionic
    Install Cordova
    and Ionic Globally

    View Slide

  12. Clone demo project
    STEP 2

    View Slide

  13. $ ionic start frontendAwesome sidemenu
    $ cd frontendAwesome tabs
    blank
    other
    templates
    ]
    project name template name
    Blank Tabs Sidemenu

    View Slide

  14. Build & Emulate
    STEP 3

    View Slide

  15. $ ionic build ios
    $ ionic emulate ios
    $ ionic serve
    Build iOS/Xcode files
    Open iOS app in emulator
    Serve preview in browser

    View Slide

  16. Customize Styles
    STEP 4

    View Slide

  17. scss/ionic.app.scss
    // Customize Ionic variables pre-import
    $stable: #e8f8f8;
    @import “www/lib/ionic/scss/ionic”;
    // Add custom styles
    .highlighted { color: #ffff00; }

    View Slide

  18. Customize Content
    STEP 5

    View Slide

  19. Angular templating
    • {{markup}} (like Handlebars)
    • Directives (custom HTML elements)
    • Angular Directives (ng-repeat, ng-model)
    • Ionic Directives (ion-view, ion-content)
    • Filters ( {{ data | filter }} )

    View Slide

  20. www/js/app.js
    angular.module(...)
    .run(...)
    .config(..., $stateProvider
    .state('app', ...)
    .state('app.posts', {
    url: '/posts',
    views: {
    'menuContent': {
    templateUrl: 'templates/posts/index.html',
    controller: 'PostsCtrl'
    }
    }
    })
    .state('app.post', ...)

    View Slide

  21. www/js/controllers.js
    angular.module('starter.controllers', [])
    .controller('AppCtrl', ...)
    .controller('PostsCtrl', function($scope) {
    $scope.posts = [
    {
    id: 1,
    title: 'Hello',
    body: 'World'
    },
    {...},
    {...}
    ];
    })
    .controller('PostCtrl', ...)

    View Slide

  22. www/templates/posts.html





    {{post.title}}




    View Slide

  23. www/templates/post.html


    {{post.title}}





    View Slide

  24. Ionic CSS Components
    STEP 6

    View Slide

  25. View Slide

  26. View Slide

  27. Ionic JS Components
    STEP 7

    View Slide

  28. View Slide

  29. Distribute
    STEP 8

    View Slide

  30. iOS & Android demo distribution
    • iOS
    • -> Xcode -> TestFlight -> many devices
    • -> Xcode -> Your device directly
    • Android
    • -> USB -> your device
    • -> Eclipse SDK -> * -> many devices
    *http://www.thoughtworks.com/insights/blog/testflight-alternatives-android

    View Slide

  31. Miscellany
    Chrome Dev Tools Emulate is your friend

    View Slide

  32. Miscellany
    Use foreman to run gulp & ionic serve at
    once # Procfile
    gulp: gulp watch
    serve: ionic serve
    $ foreman start
    http://mattstauffer.co/blog/using-a-procfile-to-streamline-your-local-development

    View Slide

  33. Let’s Build.
    @stauffermatt
    (demo time: build a real app)

    View Slide