On Github Dr4K4n / presentation-angular-webapps
I love the web, I love to program for the web. In fact I love it so much, this presentation is a website! on github ;) But before we get to the real topic, a few words about myself.
Some of you may ask yourself. "Never heard of him, what does he even do around here?"
the last point is important, I use linux on a everyday basis. But to give this presentation a had to use windows, GoToMeeting doesn't work under Linux.
Data from PRODYNA OnAir prepared by a tiny JavaScript enough about myselfs, lets talk about mobile web apps
what I mean with "Mobile Web App" Why Mobile Web Apps? Is it a good idea? - as soon as you are convinced - How to build a mobile web app
some of the stuff I tell you is also valid for mobile websites, with slight changes
talk about different possibilities for mobile apps pro/cons goal is, you should be able to make a reasonable decision
we'll focus on the first too, but I'll tell you little bit about the others
- different platforms - each has its own programming language - each has its own development environment - even different operating systems needed!
website + "mini browser" = native app
phonegap/cordova is the "market leader" Appcelerator Titanium uses native UI and javascript for the application logic "Interpreted" hybrid apps. -> limited functionality phonegap "on steriods" / without HTML good/bad / new HEAVY APIs :-( Phonegap vs. cordova? - initially named phonegap - bought from adobe - code contributed to apache, named "cordova" - cordova is the open source - functionally nearly identical
INTERPRETED whole runtime delivered on the phone (App Store problems!) - rhomobile (ruby) - xamarin (mono, formerly monotouch) - BAD tool support (debugger) - Problems with the app store (runtime not allowed) GENERATED XML VM (cross compiler) introspect Android Java-Code -> XML -> stack machine (XSLT) -> Objective-C - doesn't work for platform specific components (UI) EMF, XTEXT, XPAND - domain (backend integrated apps, games) - write a DSL for this domain - generate APPS - BIG INITIAL INVESTMENT (only sensible if you want to develop many similar apps) enterprise app stores
you now have a basic idea of the two most common approaches when should i use which? the customer just wants a great app, in most cases he doesn't really care how it is implemented
things are good multiple platforms/languages are a problem -> hard/much to learn So, when is it a good idea to use native development?
- styling is important to business users, but you can develop web apps that look pretty sharp - gps, camera, etc. not that much of a problem - device integration: you will later see, this is not that much of a problem. - depending on how deep you wanna get, you need to compare the effots (write cordova plugin vs. implement everything native)
- spotify uses lock screen widgets, share functionalities, audio playing, bluetooth a2dp integration - facebook was a web app, moved to native because of performance (August 2012 - over 2 years ago) - youtube is native, video playing, sharing, widgets
development = instant feedback, no emulator, only a webbrowser! the last two are no "hard" cons. You CAN do this, its just a little more complicated. Performance is okay, brwosers are getting faster every day
- business: forms, data driven, UI not 100% important, performance not critical
news app, not much more functionality than read articles - wikipedia, also not many fancy features - itunes, is a great hybrid app!
so, are some great mobile web apps. Why not make some more of them? I say
endusers can hardly notice the difference I will show you what can be done today. BUT I STILL HAVE SOME DOUBTS! Web development is not that much cooler!
What about...
offline: no traditional request/response with a server possible gps/camera: easy! styling: BUT I HATE CSS! There is help out there! JavaScript is ugly! It's not all that bad (anymore) let me start with the last one first
It is better now.
with every modern website, these are the 3 to help you HTML5, JavaScript (ECMAScript) 5, CSS3 (like the fancy animations of this presentation)
Most of them are based on - a platform to run JavaScript with Googles V8 engine outside of the browser
depend scaffold develop check test build debug bower yeoman WebStorm jslint jasmine grunt Chrome dev toolsalso to note npm, sublime text, karma, phantomjs, protractor, gulp, firefox
chrome://inspect/
demo - debugging. t3n.de im chrome vorbereiten und zeigen
this is valid for NORMAL websites Fpr Mobile Apps "only" smartphones/tablets
just a quick sidenote on responsive webdesign there is much more to it. But you get the basic idea
Why MOBILE FIRST? Number of device sales rapid growth / already more also mobile devices in companies get more important (PD Stream) just to give you some perspective
What's different to web site styling. additionally IDEAS ? UX = User expects an "App" to behave diffent than a website. (slide in menu) one hand (phone) - two hands (tablet/pc) swipe, pinch to zoom
there are a lot of frameworks to support you. CSS and JS
"Who knows bootstrap?" -> webseite zeigen bootstrap Liferay 6.2 Bootstrap! * Bootstrap not really for MOBILE ionic - CSS components for mobile basically they both use a grid to be "responsive" some have backend integration or bring own backends!
HTML5 has APIs for all of them.
SO FAR LEARNT: Styling can be done, looks cool which hardware makes a phone special? different from a pc?
phonegap has plugins to use even more. They wrap native APIs/libraries into JavaScript.
device integration also means: integrate into the phone operating system? EXAMPLE: Click on a youtube link in facebook app or website -> youtube app
Where is it getting complicated?
You can implement this native and still include it
Where are the limits? Its only a matter of time! Hybrid, there are some cordova plugins, maybe even write your own?
Again HTML5 to the rescue
no server (request/response) "state" - close app, open app, resume!
some examples
All of these are SPAs that work offline We need this for Mobile Apps too! Sidenote: Is it complicated? NEXT SLIDE
textarea = { textarea: null, init: function() { this.textarea = document.getElementsByTagName('textarea')[0]; this.textarea.focus(); this.load(); }, load: function() { this.textarea.value = localStorage.getItem('text'); }, save: function() { localStorage.setItem('text', this.textarea.value); } }
So, everything clear, right? It seems possible, so HOW best to do it?
I will present you my stack to build mobile web apps.
no iphone/Mac/Android/windows needed (but good for testing and initial setup...) I will give a short introduction on all of these
A really quick introduction to angular MVC built in! There is no way without a controller! controllers and services are the essential components Injection?! Data-Binding?! -> really powerful tools, some EXAMPLES ahead!
<script src="angular.min.js"></script> <body ng-app> <input type="text" ng-model="yourName" placeholder="Enter a name"> <h1>Hello {{yourName}}!</h1> </body>
One-Way Databinding EXAMPLE Data binding is really easy and very powerful. Works not only directly in HTML, also in the services and controllers.
Hide old stuff
var module = angular.module('ListApp', []); module.controller('ListCtrl', function ($scope) { $scope.things = [ { name: "AngularJS", color: "Red", hidden: false }, { name: "Vaadin", color: "Blue", hidden: false }, { name: "Wicket", color: "orange", hidden: false } ]; $scope.hideOldStuff = function() { $scope.things[1].hidden = !$scope.things[1].hidden; $scope.things[2].hidden = !$scope.things[2].hidden; } });
<div ng-controller="ListCtrl"> <h1>Only a list</h1> <button ng-click="hideOldStuff()">Hide old stuff</button> <ul> <li ng-repeat="thing in things" style="color:{{thing.color}}" ng-hide="thing.hidden"> {{thing.name}} </li> </ul> </div>
Two-Way databinding EXAMPLE ng-repeat! cool What is this ng-repeat?
Think of them as "extensions" of HTML
ng-app, ng-controller, ng-repeat, ng-show, ng-model, ...
make your life easier
write your own HTML-elements
manipulate the DOM not only view components! add event listener -> web components -> polymer Angular-UI and Ionic heavily rely on this! Lot of special directives! EXAMPLES later! enough on Angular -> talk about cordova
this is the "mini browser" CLI to create & build hybrid web apps plugins
cordova create hello com.prodyna.hello HelloWorld cd hello cordova platform add android cordova build cordova run --device
!build needs android/ios/wp SDKs installed on local machine! sessions.sh mit doitlive ausführen?
cordova plugin add org.apache.cordova.camera
navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions );
"Takes a photo using the camera, or retrieves a photo from the device's image gallery. The image is passed to the success callback as a base64-encoded String, or as the URI for the image file. The method itself returns a CameraPopoverHandle object that can be used to reposition the file selection popover." plugins are for certain platforms only, some support all
central part are the css components optimized for mobile devices provide a platform for mobile web app development. Angular + cordova + plugins + nice icing on top
ionic start myApp sidemenu cd myApp ionic platform add ios ionic build ios ionic emulate ios
pretty much like cordova "start" is different "sidemenu" is a template
Free* build service by Adobe
For personal use 1 private app and unlimited apps from github repos
No Windows, MacOS needed to build the app for the app stores Fraport Mac Mini
more sophisticated Apps built with ionic
SPO-Portal Quick Offer
sworkit
a simple example app built with ionic running on an android emulator. SPO-Portal?webOS, decendant of palm os, developed by Palm, later HP -> open source -> LG (TV sets january 2014)
Apple AppStore Review - no guarantee to get in there phonegap is gray area
ESD Web Technologies Expert Group
SCMA - Solution Center Mobile Applications
more dialogues/trainings to come!
HELP wanted! AngularJS training if enough participants