SlideShare a Scribd company logo
Mobile App
Development:
Primi passi con
NativeScript e Angular 2
Who Am I ?
Filippo Matteo Riggio
Full Stack Dev
CTO @ Kaleidoscope
@FMRiggio
Scenario
Nativo
Swift / Java
Cordova
App che si appoggiano
ad una web-view (ionic,
famous7, ecc.)
Soluzioni cross
React Native
NativeScript
Xamarin
AppCelerator
Altri strumenti disponibili
Come scegliere?
Grafico innovativo superca**uto.
GHE SCHEI
GHE TEMPO
NO GHE SCHEI
NO GHE TEMPO
NativeScript
Build amazing iOS and Android apps
with technology you already know
Open source framework for building truly
native mobile apps with Angular, TypeScript
or JavaScript.
NativeScript è davvero native!
var time = new android.text.format.Time(); // ⇐ questo è Java
time.set( 1, 0, 2015 );
console.log( time.format( "%D" ) ); // 01/01/2015
var alert = new UIAlertView(); // ⇐ Questo è un riferimento alla class Obj-C UIAlertView
alert.message = "Hello world!";
alert.addButtonWithTitle( "OK" );
alert.show();
Gotta catch em all!
L'esempio userà le API prese da pokeapi.co
Installazione
npm install -g nativescript
tns --version
Creare un nuovo progetto
tns create pokeproject --ng --appid it.kaleidoscope.pokeproject
tns platform add ios
tns platform add android
Data, data, data!
/** ---- app.module.ts ---- **/
// Import the library
import { NativeScriptHttpModule } from "nativescript-angular/http";
// Inject the module
@NgModule({
[...]
imports: [NativeScriptModule, NativeScriptHttpModule]
})
App Logic
/** ---- app.component.ts ---- **/
// Imports
import { Component, OnInit } from "@angular/core";
@Component({
selector: "my-app",
templateUrl: "app.component.html"
})
export class AppComponent implements OnInit {
public constructor() { ... }
public ngOnInit() { ... }
public showInformation(index: number) { ... }
public showDialog(data: Array<string>) { ... }
}
Gotta catch em all!
/** ---- app.component.ts ---- **/
// Imports
import { Http } from "@angular/http";
import "rxjs/Rx";
export class AppComponent implements OnInit {
public pokemon: Array<any>;
public constructor(private http: Http) { ... }
public ngOnInit() {
this.http.get("https://pokeapi.co/api/v2/pokemon?limit=151")
.map(result => result.json())
.flatMap(result => result.results)
.subscribe(result => {
this.database.getDatabase().createDocument(result);
this.pokemon.push(result);
}, error => {
console.error(error);
});
}
}
User Interface
/** ---- app.component.html ---- **/
<ActionBar title="PokeProject"></ActionBar>
<StackLayout>
</StackLayout>
Docs: https://docs.nativescript.org/ui/basics
User Interface - Grid Layout
/** ---- app.component.html ---- **/
<GridLayout rows="auto" columns="auto, *, auto">
</GridLayout>
Docs: https://docs.nativescript.org/cookbook/ui/layouts/grid-layout
User Interface - ListView
/** ---- app.component.html ---- **/
<ListView [items]="pokemon">
<ng-template let-monster="item" let-index="index">
<GridLayout/>
</ng-template>
</ListView>
[...]
<GridLayout rows="auto" columns="auto, *, auto" margin="15">
<Label row="0" col="0" class="pokemon-number" text="{{ index + 1 }}." marginRight="10"></Label>
<Label row="0" col="1" class="pokemon-name" [text]="monster.name" ></Label>
<Image row="0" col="2" class="pokemon-image" src="~/images/{{index + 1}}.png" ></Image>
</GridLayout>
A bit of style!
/** ---- app.css ---- **/
.pokemon-number {
font-weight: bold;
}
.pokemon-name {
text-transform: capitalize;
}
.pokemon-image {
animation-name: pokemon-image;
animation-duration: 1s;
animation-delay: 1s;
opacity: 0;
}
@keyframes pokemon-image {
from { opacity: 0; transform: rotate(0deg); }
to { opacity: 1; transform: rotate(360deg); }
}
Aggiungere un event listener.
/** ---- app.component.html ---- **/
<GridLayout [...] (tap)="showInformation(index+1)">
[...]
</GridLayout>
/** ---- app.component.ts ---- **/
public showInformation(index: number) {
this.http.get("https://pokeapi.co/api/v2/pokemon/" + index)
.map(result => result.json())
.flatMap(result => result.types)
.map(result => (<any> result).type.name)
.toArray()
.subscribe(result => {
this.showDialog(result);
}, error => {
console.error(error);
});
}
Native Dialogs
/** ---- app.component.ts ---- **/
// Import the library
// https://docs.nativescript.org/cookbook/ui/dialogs
import dialogs = require("ui/dialogs");
public showDialog(data: Array<string>) {
dialogs.alert({
title: "Information",
message: "Questo pokemon è del tipo " + data.join(", "),
okButtonText: "OK"
});
}
Native Plugins
tns plugin add nativescript-couchbase
/// <reference path="./node_modules/nativescript-couchbase/couchbase.d.ts" />
Plugins disponibili: http://plugins.nativescript.org/
Camera quick example
import * as camera from "nativescript-camera";
import { Image } from "ui/image";
var options = { width: 300, height: 300, keepAspectRatio: false, saveToGallery: true };
camera.takePicture(options)
.then((imageAsset) => {
let image = new Image();
image.src = imageAsset;
console.log("Size: " + imageAsset.options.width + "x" + imageAsset.options.height);
console.log("keepAspectRatio: " + imageAsset.options.keepAspectRatio);
console.log("Photo saved in Photos/Gallery for Android or in Camera Roll for iOS");
}).catch((err) => {
console.log("Error -> " + err.message);
});
Couchbase DB provider
/** ---- database.ts ---- **/
import { Couchbase } from 'nativescript-couchbase';
export class Database {
private db: any;
public constructor() {
this.db = new Couchbase("db");
}
public getDatabase() {
return this.db;
}
}
/** ---- app.component.ts ---- **/
@Component({
selector: "my-app",
templateUrl: "app.component.html",
providers: [Database]
})
export class AppComponent implements OnInit {
public constructor(private http: Http, private database: Database) { [...] }
}
NoSQL MapReduce View
/** ---- database.ts ---- **/
[...]
public constructor() {
this.db = new Couchbase("db");
this.db.createView("pokemon", "1", (document, emitter) => {
emitter.emit(document._id, document);
});
}
[...]
Caching dei dati
/** ---- app.component.ts ---- **/
public ngOnInit() {
let rows = this.database.getDatabase().executeQuery("pokemon");
if (rows.length == 0) {
this.http.get("https://pokeapi.co/api/v2/pokemon?limit=151")
.map(result => result.json())
.flatMap(result => result.results)
.subscribe(result => {
this.database.getDatabase().createDocument(result);
this.pokemon.push(result);
}, error => {
console.error(error);
});
} else {
for (let i = 0; i < rows.length; i++) {
this.pokemon.push(rows[i]);
}
}
}
Accesso alle Api Native della UI
// NativeScript XML tag
<ActionBar title="Sign up"></ActionBar>
// Controller Obj-c (mappato in node_modules/tns-core-modules/ui/frame/frame.ios.js)
UINavigationController
// Componente UI Obj-c (mappato in node_modules/tns-core-modules/ui/action-bar/action-bar.ios.js)
UINavigationBar
// Modificare lo stile della ActionBar per iOS
if (page.ios) {
var navigationBar = frameModule.topmost().ios.controller.navigationBar;
navigationBar.barStyle = UIBarStyle.UIBarStyleBlack;
}
Comandi utili
tns prepare [ios|android]
tns build [ios|android]
tns deploy [ios|android]
tns emulator [ios|android]
tns livesync [ios|android] --watch
References
Documentazione di NativeScript
http://docs.nativescript.org
Lista dei plugins (certificati da Telerik)
http://plugins.nativescript.org
Plugin CouchBase
https://github.com/couchbaselabs/nativescript-couchbase
How NativeScript Works
http://developer.telerik.com/featured/nativescript-works/
Performances (web-view)
https://github.com/mlynch/pgday-eu-2017-perf/blob/master/web-perf-2017.pdf
Domande?
Bonus pack!
factotum
A Laravel-based CMS,
from web artisans to web artisans.
We love KISSing the DRY PIE.
https://factotum.kaleidoscope.it
Main focus concepts
Laravel-based
No words needed on
why choosing a top
level framework like
Laravel
Blazing fast
Who loves slow CMS?
Soon some
benchmarks, but you
will see on your own if
you try it!
Flexible
Because the mind of
our clients is like a child
in a luna parks, junkie
by tons of sugar.
Main features
Users
You can have many
users, many roles and
capabilities as you
want.
Content Types
You can define many
content types as you
want. Do you need
news or an event?
Custom Fields
Every content type can
have many different
fields. Yes, because not
all the contents are the
same.
Main features
Media
You can manage all the
media that you need.
Multilanguage
Yes, ready for
supporting abroad
users.
JSON APIs
(Soon)
...ora è davvero finito.
Grazie! :)

More Related Content

What's hot (19)

PDF
Building a Startup Stack with AngularJS
FITC
 
PDF
jQuery Internals + Cool Stuff
jeresig
 
PDF
Android programming -_pushing_the_limits
Droidcon Berlin
 
PDF
JavaScript Library Overview
jeresig
 
PPTX
Angular 2.0 Routing and Navigation
Eyal Vardi
 
PDF
MVC pattern for widgets
Behnam Taraghi
 
PDF
Mach-O par Stéphane Sudre
CocoaHeads France
 
PDF
Angular JS blog tutorial
Claude Tech
 
PDF
droidparts
Droidcon Berlin
 
PPTX
Vue business first
Vitalii Ratyshnyi
 
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
PDF
Modern frontend development with VueJs
Tudor Barbu
 
PPTX
AngularJS Internal
Eyal Vardi
 
PDF
The Gist of React Native
Darren Cruse
 
PDF
AngularJS - Overcoming performance issues. Limits.
Dragos Mihai Rusu
 
PDF
Angular js
Eueung Mulyana
 
PDF
준비하세요 Angular js 2.0
Jeado Ko
 
PPTX
Owl: The New Odoo UI Framework
Odoo
 
ODP
AngularJs Crash Course
Keith Bloomfield
 
Building a Startup Stack with AngularJS
FITC
 
jQuery Internals + Cool Stuff
jeresig
 
Android programming -_pushing_the_limits
Droidcon Berlin
 
JavaScript Library Overview
jeresig
 
Angular 2.0 Routing and Navigation
Eyal Vardi
 
MVC pattern for widgets
Behnam Taraghi
 
Mach-O par Stéphane Sudre
CocoaHeads France
 
Angular JS blog tutorial
Claude Tech
 
droidparts
Droidcon Berlin
 
Vue business first
Vitalii Ratyshnyi
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Modern frontend development with VueJs
Tudor Barbu
 
AngularJS Internal
Eyal Vardi
 
The Gist of React Native
Darren Cruse
 
AngularJS - Overcoming performance issues. Limits.
Dragos Mihai Rusu
 
Angular js
Eueung Mulyana
 
준비하세요 Angular js 2.0
Jeado Ko
 
Owl: The New Odoo UI Framework
Odoo
 
AngularJs Crash Course
Keith Bloomfield
 

Similar to Mobile App Development: Primi passi con NativeScript e Angular 2 (20)

PPTX
Intro to appcelerator
Mohab El-Shishtawy
 
PDF
Develop your first mobile App for iOS and Android
Ricardo Alcocer
 
PDF
Develop your first mobile App for iOS and Android
ralcocer
 
PDF
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Loïc Knuchel
 
PPTX
Xamarin.iOS introduction
Guido Magrin
 
PDF
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
Heiko Behrens
 
PPTX
Neoito — NativeScript Best Coding Practices
Neoito
 
PDF
A mobile web app for Android in 75 minutes
James Pearce
 
PDF
End to-end native iOS, Android and Windows apps wtih Xamarin
James Montemagno
 
PDF
Titanium Alloy Tutorial
Fokke Zandbergen
 
PDF
Building Native Apps With Titanium Mobile
Brendan Lim
 
PDF
Creating and Distributing Mobile Web Applications with PhoneGap
James Pearce
 
PDF
There's more than web
Matt Evans
 
PDF
Connect.js 2015 - Building Native Mobile Applications with Javascript
joshcjensen
 
PPTX
Building Native Android Apps with JavaScript
Abhishek Kant
 
PDF
Backend-driven native UIs
John Sundell
 
PPTX
Native cross-platform mobile apps with C# and Xamarin.Forms
Peter Major
 
PDF
Nativescript angular
Christoffer Noring
 
PDF
Create a mobile web app with Sencha Touch
James Pearce
 
PDF
Bd conf sencha touch workshop
James Pearce
 
Intro to appcelerator
Mohab El-Shishtawy
 
Develop your first mobile App for iOS and Android
Ricardo Alcocer
 
Develop your first mobile App for iOS and Android
ralcocer
 
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Loïc Knuchel
 
Xamarin.iOS introduction
Guido Magrin
 
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
Heiko Behrens
 
Neoito — NativeScript Best Coding Practices
Neoito
 
A mobile web app for Android in 75 minutes
James Pearce
 
End to-end native iOS, Android and Windows apps wtih Xamarin
James Montemagno
 
Titanium Alloy Tutorial
Fokke Zandbergen
 
Building Native Apps With Titanium Mobile
Brendan Lim
 
Creating and Distributing Mobile Web Applications with PhoneGap
James Pearce
 
There's more than web
Matt Evans
 
Connect.js 2015 - Building Native Mobile Applications with Javascript
joshcjensen
 
Building Native Android Apps with JavaScript
Abhishek Kant
 
Backend-driven native UIs
John Sundell
 
Native cross-platform mobile apps with C# and Xamarin.Forms
Peter Major
 
Nativescript angular
Christoffer Noring
 
Create a mobile web app with Sencha Touch
James Pearce
 
Bd conf sencha touch workshop
James Pearce
 
Ad

Recently uploaded (20)

PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Ad

Mobile App Development: Primi passi con NativeScript e Angular 2

  • 1. Mobile App Development: Primi passi con NativeScript e Angular 2
  • 2. Who Am I ? Filippo Matteo Riggio Full Stack Dev CTO @ Kaleidoscope @FMRiggio
  • 3. Scenario Nativo Swift / Java Cordova App che si appoggiano ad una web-view (ionic, famous7, ecc.) Soluzioni cross React Native NativeScript Xamarin AppCelerator
  • 6. Grafico innovativo superca**uto. GHE SCHEI GHE TEMPO NO GHE SCHEI NO GHE TEMPO
  • 7. NativeScript Build amazing iOS and Android apps with technology you already know Open source framework for building truly native mobile apps with Angular, TypeScript or JavaScript.
  • 8. NativeScript è davvero native! var time = new android.text.format.Time(); // ⇐ questo è Java time.set( 1, 0, 2015 ); console.log( time.format( "%D" ) ); // 01/01/2015 var alert = new UIAlertView(); // ⇐ Questo è un riferimento alla class Obj-C UIAlertView alert.message = "Hello world!"; alert.addButtonWithTitle( "OK" ); alert.show();
  • 9. Gotta catch em all! L'esempio userà le API prese da pokeapi.co
  • 10. Installazione npm install -g nativescript tns --version
  • 11. Creare un nuovo progetto tns create pokeproject --ng --appid it.kaleidoscope.pokeproject tns platform add ios tns platform add android
  • 12. Data, data, data! /** ---- app.module.ts ---- **/ // Import the library import { NativeScriptHttpModule } from "nativescript-angular/http"; // Inject the module @NgModule({ [...] imports: [NativeScriptModule, NativeScriptHttpModule] })
  • 13. App Logic /** ---- app.component.ts ---- **/ // Imports import { Component, OnInit } from "@angular/core"; @Component({ selector: "my-app", templateUrl: "app.component.html" }) export class AppComponent implements OnInit { public constructor() { ... } public ngOnInit() { ... } public showInformation(index: number) { ... } public showDialog(data: Array<string>) { ... } }
  • 14. Gotta catch em all! /** ---- app.component.ts ---- **/ // Imports import { Http } from "@angular/http"; import "rxjs/Rx"; export class AppComponent implements OnInit { public pokemon: Array<any>; public constructor(private http: Http) { ... } public ngOnInit() { this.http.get("https://pokeapi.co/api/v2/pokemon?limit=151") .map(result => result.json()) .flatMap(result => result.results) .subscribe(result => { this.database.getDatabase().createDocument(result); this.pokemon.push(result); }, error => { console.error(error); }); } }
  • 15. User Interface /** ---- app.component.html ---- **/ <ActionBar title="PokeProject"></ActionBar> <StackLayout> </StackLayout> Docs: https://docs.nativescript.org/ui/basics
  • 16. User Interface - Grid Layout /** ---- app.component.html ---- **/ <GridLayout rows="auto" columns="auto, *, auto"> </GridLayout> Docs: https://docs.nativescript.org/cookbook/ui/layouts/grid-layout
  • 17. User Interface - ListView /** ---- app.component.html ---- **/ <ListView [items]="pokemon"> <ng-template let-monster="item" let-index="index"> <GridLayout/> </ng-template> </ListView> [...] <GridLayout rows="auto" columns="auto, *, auto" margin="15"> <Label row="0" col="0" class="pokemon-number" text="{{ index + 1 }}." marginRight="10"></Label> <Label row="0" col="1" class="pokemon-name" [text]="monster.name" ></Label> <Image row="0" col="2" class="pokemon-image" src="~/images/{{index + 1}}.png" ></Image> </GridLayout>
  • 18. A bit of style! /** ---- app.css ---- **/ .pokemon-number { font-weight: bold; } .pokemon-name { text-transform: capitalize; } .pokemon-image { animation-name: pokemon-image; animation-duration: 1s; animation-delay: 1s; opacity: 0; } @keyframes pokemon-image { from { opacity: 0; transform: rotate(0deg); } to { opacity: 1; transform: rotate(360deg); } }
  • 19. Aggiungere un event listener. /** ---- app.component.html ---- **/ <GridLayout [...] (tap)="showInformation(index+1)"> [...] </GridLayout> /** ---- app.component.ts ---- **/ public showInformation(index: number) { this.http.get("https://pokeapi.co/api/v2/pokemon/" + index) .map(result => result.json()) .flatMap(result => result.types) .map(result => (<any> result).type.name) .toArray() .subscribe(result => { this.showDialog(result); }, error => { console.error(error); }); }
  • 20. Native Dialogs /** ---- app.component.ts ---- **/ // Import the library // https://docs.nativescript.org/cookbook/ui/dialogs import dialogs = require("ui/dialogs"); public showDialog(data: Array<string>) { dialogs.alert({ title: "Information", message: "Questo pokemon è del tipo " + data.join(", "), okButtonText: "OK" }); }
  • 21. Native Plugins tns plugin add nativescript-couchbase /// <reference path="./node_modules/nativescript-couchbase/couchbase.d.ts" /> Plugins disponibili: http://plugins.nativescript.org/
  • 22. Camera quick example import * as camera from "nativescript-camera"; import { Image } from "ui/image"; var options = { width: 300, height: 300, keepAspectRatio: false, saveToGallery: true }; camera.takePicture(options) .then((imageAsset) => { let image = new Image(); image.src = imageAsset; console.log("Size: " + imageAsset.options.width + "x" + imageAsset.options.height); console.log("keepAspectRatio: " + imageAsset.options.keepAspectRatio); console.log("Photo saved in Photos/Gallery for Android or in Camera Roll for iOS"); }).catch((err) => { console.log("Error -> " + err.message); });
  • 23. Couchbase DB provider /** ---- database.ts ---- **/ import { Couchbase } from 'nativescript-couchbase'; export class Database { private db: any; public constructor() { this.db = new Couchbase("db"); } public getDatabase() { return this.db; } } /** ---- app.component.ts ---- **/ @Component({ selector: "my-app", templateUrl: "app.component.html", providers: [Database] }) export class AppComponent implements OnInit { public constructor(private http: Http, private database: Database) { [...] } }
  • 24. NoSQL MapReduce View /** ---- database.ts ---- **/ [...] public constructor() { this.db = new Couchbase("db"); this.db.createView("pokemon", "1", (document, emitter) => { emitter.emit(document._id, document); }); } [...]
  • 25. Caching dei dati /** ---- app.component.ts ---- **/ public ngOnInit() { let rows = this.database.getDatabase().executeQuery("pokemon"); if (rows.length == 0) { this.http.get("https://pokeapi.co/api/v2/pokemon?limit=151") .map(result => result.json()) .flatMap(result => result.results) .subscribe(result => { this.database.getDatabase().createDocument(result); this.pokemon.push(result); }, error => { console.error(error); }); } else { for (let i = 0; i < rows.length; i++) { this.pokemon.push(rows[i]); } } }
  • 26. Accesso alle Api Native della UI // NativeScript XML tag <ActionBar title="Sign up"></ActionBar> // Controller Obj-c (mappato in node_modules/tns-core-modules/ui/frame/frame.ios.js) UINavigationController // Componente UI Obj-c (mappato in node_modules/tns-core-modules/ui/action-bar/action-bar.ios.js) UINavigationBar // Modificare lo stile della ActionBar per iOS if (page.ios) { var navigationBar = frameModule.topmost().ios.controller.navigationBar; navigationBar.barStyle = UIBarStyle.UIBarStyleBlack; }
  • 27. Comandi utili tns prepare [ios|android] tns build [ios|android] tns deploy [ios|android] tns emulator [ios|android] tns livesync [ios|android] --watch
  • 28. References Documentazione di NativeScript http://docs.nativescript.org Lista dei plugins (certificati da Telerik) http://plugins.nativescript.org Plugin CouchBase https://github.com/couchbaselabs/nativescript-couchbase How NativeScript Works http://developer.telerik.com/featured/nativescript-works/ Performances (web-view) https://github.com/mlynch/pgday-eu-2017-perf/blob/master/web-perf-2017.pdf
  • 31. factotum A Laravel-based CMS, from web artisans to web artisans. We love KISSing the DRY PIE. https://factotum.kaleidoscope.it
  • 32. Main focus concepts Laravel-based No words needed on why choosing a top level framework like Laravel Blazing fast Who loves slow CMS? Soon some benchmarks, but you will see on your own if you try it! Flexible Because the mind of our clients is like a child in a luna parks, junkie by tons of sugar.
  • 33. Main features Users You can have many users, many roles and capabilities as you want. Content Types You can define many content types as you want. Do you need news or an event? Custom Fields Every content type can have many different fields. Yes, because not all the contents are the same.
  • 34. Main features Media You can manage all the media that you need. Multilanguage Yes, ready for supporting abroad users. JSON APIs (Soon)
  • 35. ...ora è davvero finito. Grazie! :)

Editor's Notes

  • #8: Motore V8 su Android e JavascriptCore su iOS. I layout vengono definiti tramite file XML Gli stili attraverso un subset di CSS.
  • #16: I layout in NativeScript sono descritti utilizzando una serie di tag XML. Il layout della nostra app è composto da un header e da un layout verticale. L'header : <ActionBar/> e il vertical layout <StackLayout/>
  • #17: La nostra app presenta principalmente una lista. Useremo il layout di tipo griglia, per mostrare la lista di pokemon. Il layout configurato come da codice, permette di avere rows con altezze diverse (che si adattano da sole) e colonne dove la prima e terza colonna hanno una larghezza fissa (auto) e la centrale ha una larghezza che si adatta in automatico allo spazio restante. Auto: prende lo spazio necessario dagli elementi contenuti. Star (*): prende tutto lo spazio disponibile (dopo aver riempito lo spazio “auto” e con dimensioni fisse). Le dimensioni con (*) è possibile usarle anche con moltiplicatori, per gestire la proporzione diversamente 2*,* = 33% - 66%
  • #18: Il tag template verrà ripetuto per ogni elemento dell'array pokemon e, durante il ciclo, viene assegnato un elemento dell'array all'oggetto monster.
  • #21: Dialogs mostra un popup nativo.
  • #22: NativeScript permette di aggiungere plugin nativi (come cordova) accessibili tramite API javascript. Ogni plugin, inoltre, è provvisto dal file delle definizioni typescript, da aggiungere al file delle referenze.
  • #25: Dal sito di Couchbase A MapReduce View will emit a key-value pair. Logic can be placed around the emitter to make the views more specific.
  • #27: Il tag template verrà ripetuto per ogni elemento dell'array pokemon e, durante il ciclo, viene assegnato un elemento dell'array all'oggetto monster.
  • #28: Prepare => copia i file sulla sottodirectory della piattaforma per preparare alla build Deploy => run on real device Emulator => run on emulator