Share
Embed
Transcript
54 slides
-
<<< „Hi, I´m Marcus!“ h3p://about.me/marcus.ross Historie: •
Developer • Trainer / DevCoach • Unbequem-‐Frager -
Agenda • Das App-‐Problem • Die Antworten
– alten Antworten – neuen Antworten • Das Tooling um Ionic • Die ZukunC -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de KonzepMon von Apps -‐ Web vs.NaMve Marcus Ross Trainer/Freelancer @zahlenhelfer -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de Das Problem • Chef: „Wir brauchen eine App“ • IT: „Wow, ja gerne, welche PlaVorm?“ • Chef: „Wieso PlaVorm – Mobil!“ • IT: „Also Web oder naMve iOS?“ • Chef: „Na alle! Oder nicht?“ • IT: „OK – Problem!“ -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de Web vs. NaMve -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de Was passiert durch ios ? <label>Single file</label> <input type="file"> -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de WebApp UI • Mögliche Frameworks für UI – jQueryMobile – iUi – Bootstrap – SenchaTouch – Enyo -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de WebApp MVC • Mögliche Frameworks für MVC/MVR – Backbone.js – Knockout.js – Ember.js – Batman.js Quellen für Ideen: TODOMVC! -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de Was also nehmen? • naMve Power vs. HTML (lange Listen, flackern, etc.) • Monetarisierung der App vs. Freies Deployment (schnelles Update) • Zugriff auf Sensoren vs. HTML5 • nur ein System vs. jedes System • naMve UI vs. Irgend was an UI • SQL Datenbanken vs. local Storage -
ipdc_conference
#ipdc12 www.iphone-‐developer-‐conference.de Antwort: • Kommt drauf an L • ...daher schauen wir uns die Praxis an! -
Die neue Lösung • Programmiersprache = JS •
Hardware & Packaging = Cordova • SinglePageApplicaMon = Angular.js • UserInterface = Ionic -
• ehemals PhoneGap von Nitobi • miqlerweile Apache Toplevel
Projekt • PhoneGap jetzt als DistribuMon bei Adobe • Zugriff auf Hardware & Co. mit JS • JavaScript Call dispatch zu naMven Calls -
Cordova Kamera Beispiel navigator.camera.getPicture(onSuccess, onFail, {
quality: 50, destinationType: Camera.DestinationType.DATA_URL } ); function onSuccess(imageData) { var image = document.getElementById('myImage'); image.src = "data:image/jpeg;base64," + imageData; } function onFail(message) { alert('Failed because: ' + message); } -
Angular.js • der defacto Standard zu MVVM •
von Google gepusht • aktuell Version 2.0 in der Entwicklung • SPA-‐Framework • bringt RouMng, Templates und Dependency-‐Mgmt -
Hersteller • Erstellt von • 2012 gegründet
• Ionic unter MIT Lizenz • 2014 -‐ $1.0 Mio seed • 2015 -‐ $2.6 Mio. add (Techcrunch) -
ionic – Was ist es? • ist mehr als
css magic für mobile-‐gui • denkt einfach an Bootstrap für mobile • ist natürlich responsive • pla(orm conMnuity (mehr dazu gleich) • nutzt Apache Cordova zum App verpacken • nutzt Angular.js für RouMng und Struktur • es ist ein Stack von Tools -
Die Gretchenfrage Ist IONIC nicht einfach
nur wieder ein mobile UI Framework? -
Das ist der Code var hideSheet = $ionicActionSheet.show({
buttons: [ { text: '<b>Share</b> This' }, { text: 'Move' } ], destructiveText: 'Delete', titleText: 'Modify your album', cancelText: 'Cancel', cancel: function() { // add cancel code.. }, buttonClicked: function(index) { return true; } }); -
Der Stack ist kompleq • Cordova • JavaScript
• Angular • ionic -
ionic View • Sandbox für App´s • Teilen
von Apps ohne ZerMfikate möglich • Prima für Kunden • Invite per Email • Hardwarezugriff funkMoniert • kostenloser Download im AppStore -
ionicPush • Service von DriCy • aktuell in
der closed Alpha • AnalyMcs und Mgmt-‐Tools möglich • alternaMve zum generischem Plugin von Cordova • Pricing nicht vorhanden -
Vorbereitung zum Start • iOS -‐> Xcode
• android -‐> Google SDK (17) • npm install –g ios-‐sim -
ionicons • 100 % freie Icons (MIT) •
Als CSS-‐Klasse nutzbar • hqp://ionicons.com/ -
Mögliche weitere Schriqe • Template auswählen: – $ ionic
start myApp blank – $ ionic start myApp tabs – $ ionic start myApp sidemenu • Pla(orm Support – $ ionic pla(orm add ios – $ ionic pla(orm add android – $ ionic pla(orm add windowsphone -
Developer Loop • $ ionic serve •
$ ionic [run|emulate] <pla(orm> [opMons] – [-‐-‐livereload|-‐l] LiveReload auf dem Device – [-‐-‐consolelogs|-‐c] Applogs auf der Ionic CLI – [-‐-‐serverlogs|-‐s] Serverlogs auf der Ionic CLI $ ionic run ios -‐-‐livereload -‐-‐consolelogs -‐-‐ serverlogs -
Ionic Projektstruktur • www -‐> place to work (index.html)
• plugins -‐> place for cordova plugins • scss -‐> like to assemble your sass • hooks -‐> internal stuff like cordova hooks • config.xml -‐> cordovas manifest -
Ionic UMls var deviceInformation = ionic.Platform.device();
var isWebView = ionic.Platform.isWebView(); var isIPad = ionic.Platform.isIPad(); var isIOS = ionic.Platform.isIOS(); var isAndroid = ionic.Platform.isAndroid(); var isWindowsPhone = ionic.Platform.isWindowsPhone(); var currentPlatform = ionic.Platform.platform(); var currentPlatformVersion = ionic.Platform.version(); ionic.Platform.exitApp(); // stops the app -
ngCordova • Layer der über Apache Cordova liegt
• Vereinfachung der cordova-‐api • Nutzt Promises staq Callbacks • Stellt eine Angular-‐freundliche Api bereit -
ngCrodova einbinden $ bower install -‐-‐save ngCordova •
index.html erweitern <script src="lib/ngCordova/dist/ng-‐ cordova.min.js"></script> • app.js erweitern angular.module('starter', ['ngCordova',...]) • Cordova Plugins laden $ cordova plugin add org.apache.cordova.camera -
Bisher bei Cordova navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
desMnaMonType: Camera.DesMnaMonType.DATA_URL }); funcMon onSuccess(imageData) { var image = document.getElementById('myImage'); image.src = "data:image/jpeg;base64," + imageData; } funcMon onFail(message) { alert('Failed because: ' + message); } -
mit ngCordova module.controller('PictureCtrl', function($scope, $cordovaCamera) {
$scope.takePicture = function() { $cordovaCamera.getPicture({ }).then(function(imageData) { // Success! Image data is here }, function(err) { // An error occured. Show a message to the user }); } }); -
Farben und Style • default css @ index.html
<link href="lib/ionic/css/ionic.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> ...aber es geht auch anders -
Anpassungs durch SASS • Support für Sass laden
$ ionic setup sass • Sass-‐Source liegt im Projekt unter scss/ionic.app.scss • Änderungen werden automaMsch übernommen $ ionic serve -
collecMon-‐repeat vs. ngRepeat • Renderd im DOM nur was
aktuell sichtbar ist <ion-‐content> <ion-‐item collection-‐repeat="item in items"> {{item}} </ion-‐item> </ion-‐content> -
DANKE! Marcus Ross – Zahlenhelfer ConsulMng -‐ @zahlenhelfer
alle Folien auch auf www.speakerdeck.com/u/zahlenhelfer