SlideShare una empresa de Scribd logo
1 de 216
Descargar para leer sin conexión
NativeScript
Cross-platform mobile apps with JavaScript
Todd Anglin
@toddanglin
Burke Holland
@burkeholland
Workshop Agenda
• Intro to NativeScript
• NativeScript core concepts
• “Hello World”
• Defining Views
• Debugging JavaScript
• Basic data binding
• Styling views with CSS
• Intro to Angular 2 concepts
• Angular 2 + NativeScript
• Navigating views
• BONUS
• Extending with plugins
• Adding animations
• Using Telerik Platform
Ante Meridiem (9AM to Noon) Post Meridiem (1PM to 4PM)
Intro to NativeScript
”How did we get here?”
2013 2014 2015 2016 2017
Early
prototypes
“Core”
engineering
Public
launch
Adoption
ramp-up
Mass
adoption
Project Timeline
Delivering on the
overdue promise of
“hybrid.”
Swift/Obj-C Java .NET
Mobile Web
Hybrid
Native
("1st Gen" x-plat native)
We ❤ Web.
But…
We need:
• Better offline support
• Access to device APIs
• Home screen icons
• Push notifications
• App monetization
• …
Hybrid Promise
100%
Web
100%
Native
Hybrid
Reach
Code/Skill Reuse
Richness
Premium experience
Device APIs
Best of both?
Hybrid Reality
80% coded 20%
remaining
80% of dev time
Hybrid Reality
80% coded 20%
remaining
80% of dev time 80% of dev time
Hybrid Reality
Hybrid "Peak"
Hybrid Promise
100%
Web
100%
Native
Hybrid
Reach
Code/Skill Reuse
Richness
Premium experience
Device APIs
Compromises
Binary Choice
NativeHybrid
😎 Best experience
🐢 One platform at a time
🔥 Fast to market
😭 Compromise on UX
Binary Choice
NativeHybrid
🔥 Fast to market
😎 Best experience
JavaScript-
driven
native
🔥 Fast to market
😎 Best experience
"Hybrid"
Web UI with limited access to
native APIs
Native App Shell
WebView
Plugins Plugins
Entire app lives here
Native App
"JavaScript-driven Native"
Native UI driven by JavaScript
Native UI
JavaScript-to-Native bridge
JavaScript Engine
(Your app code runs here)
Native APIs
NativeScript
(by Telerik)
React Native
(by Facebook)
“JavaScript-drive Native”
Native App
Native UI
JavaScript-to-Native runtime
JavaScript Engine
(Your app code runs here)
Native APIs
Native App
Native UI
JavaScript Engine
(Your app code runs here)
Native APIs
API
Wrapper
API
Wrapper
PluginsPlugins
API
Wrapper
API
Wrapper
API
Wrapper
API
Wrapper
Plugins created with JS/TypeScript Plugins created with native code
“JavaScript-driven Native”
• Share code
• Reuse existing skills/teams
• Reuse existing libraries
• Native UI (no WebView!)
• Full access to device APIs
• Immediate access to new OS
features
🔥 Fast to market
😎 Best experience
What is NativeScript?
• Open source framework (ASLv2)
• Create native mobile apps for iOS, Android
(and eventually Windows 10)
• Use JavaScript (“web skills”)
• Write once, run everywhere
• Share 100% code between iOS/Android
• Share 80% code with web
• Reuse popular plugins from
NodeJS/iOS/Android
• Integrates deeply with Angular and
TypeScript
With NativeScript…
• No web views (platform native UI)
• Use JavaScript (or TypeScript)
• 100% access to ALL native APIs (even new APIs)
• Made for “web developers” (JS, CSS, XML)
• Use Angular for web AND native mobile
• Reuse thousands of libraries from
Node/iOS/Android/Web
The {N} difference…
Demo available in the
app stores in May
Rich, animated,
“no compromise”
native UI
(with shared UI code)
1
Measurable
native UI
performance
(“no jank”)
2
Maximum code
and skill
reusability
3
Video credit: Nathan Walker, {N} community member
How does NativeScript
work?
Under the covers
Generated at build time
for OS & 3rd party
native libraries
NativeScript Android example
output:
JavaScript
NativeScript iOS example
JavaScript
Runs on V8 JavaScript VM
Runs on JavaScriptCore VM
NativeScript Module Layer (NML)
• Abstractions on native APIs that provide unified,
cross-platform API
• Dozens available out of the box
• Easy for developers to add
• IMPORTANT: All native APIs still available at JavaScript layer for platform-specific
scenarios
• NativeScript modules follow Node module’s
conventions (CommonJS).
Example: NativeScript file module
Putting it all together
Style with CSSDefine UI with XML Logic with JavaScript
“Hello World”
Two ways to use NativeScript
1)
2)
Command Line Interface (CLI)
• Use Command Prompt (Win) or
Terminal (Mac, Linux)
• Free, Part of open source project
• Requires installation, local environment setup to
build for iOS/Android (requires Mac for iOS)
• Integrates with Visual Studio Code (via plugin)
WHY: More control, Free, Integrate with
existing IDEs/code editors
WHO: More technical developers used to
using CLI, Open source developers
Telerik Platform
• Use AppBuilder or Screen Builder
• Subscription required
• Build in the cloud (no local install
required)
• Easiest way to get started
WHY: Richer tooling, Easier setup,
Platform integrated
WHO: Less technical developers, Prefer
Platform integrations, Windows
developers targeting iOS
Telerik Platform
Powerful visual tooling, cloud builds and
more for NativeScript app developers.
NativeScript CLI requirements
https://github.com/nativescript/nativescript-cli#system-requirements
Xcode, Xcode CLI tools, iOS SDK
JDK, Apache Ant, Android SDK
$ tns doctor
Choice in Architecture
JavaScript
Write your application
using plain JavaScript
TypeScript
Use TypeScript to get
Object Oriented features
and compile time error
checking
Angular
Use Angular to architect
application. Reuse almost
all code between web and
mobile
Angular & TypeScript
• Created by Google
• Open source
• Popular JavaScript framework
for building complex web apps
• “Angular 2” ships in May
• Created by Microsoft
• Open source
• Popular compiler for JavaScript that
adds powerful language features
• Used to create Angular 2 and {N}
Starting a new project
{demo}
Running on iOS
or
$ tns emulate ios
Running on Android
or
$ tns emulate android
A better Android emulator
Visual Studio Android
Emulator
Genymotion
NativeScript LiveSync
$ tns livesync //For all connected devices/emulators
$ tns livesync android //Target specific platform
$ tns livesync ios --emulator
$ tns livesync ios --emulator --watch
• Refresh app with
latest changes to
JS, CSS, XML
• No re-build
• Works with
emulators AND
device
app.js
Defining Views
Pages
• XML markup structure
• Elements (e.g. <Page>, <Label>) are
NativeScript modules
Layouts
UI Elements
Layouts
Absolute Dock Grid Stack Wrap
UI Widgets
• Button
• Label
• TextField
• TextView
• SearchBar
• Switch
• Slider
• Progress
• ActivityIndicator
• Image
• ListView
• HtmlView
• WebView
• TabView
• SegmentedBar
• DatePicker
• TimePicker
• ListPicker
• Dialogs
Out-of-the-box
Native UI widgets
means…
• Native behavior
• Native perf
• Native accessibility
• Parity with “native”
Native UI widgets
Native API
{N} Module button
android.widget.Button UIButton
Label
TextField
Repeater
SegmentedBar
GridLayout
GridLayout
Label TextField
StackLayout
{demo}
Targeting Views
• Target based on:
• screens size
• minWH<X>, minW<X>, minH<X>
• platform
• ios, android, windows
• Orientation
• land, port
<file-name>[.<qualifier>]*.<extension>
styles.android.css
styles.ios.css
mypage.minWH600.xml
mypage.xml
TIP
• Platform specific capabilities are always available
• JavaScript: <view>.android or <view>.ios
• Markup: <android></android> or <ios></ios>
• Attributes: android:<attribute> or ios:<attribute>
• Ex: <label android:class="…" ios:class="…" />
Write once by default.
Target specific platform capabilities when needed.
{demo}
Handling Events
XML
<button text="Click Me" tap="{{ onTap }}" ...
JS (ViewModel)
function pageViewModel() {
var viewModel;
viewModel.onTap = function() {
alert("You tapped me!");
}
return viewModel;
}
exports.pageViewModel = pageViewModel;
JS (View)
function onViewLoad(args) {
var page = args.object;
page.bindingContext = pageViewModel();
}
• Create event
handlers in
JavaScript
• Bind to event
names
Handling Events
tap
label.on(gestures.GestureTypes.tap, function (args) {
console.log("Tap");
});
swipe
label.on(gestures.GestureTypes.swipe, function (args) {
console.log("Swipe Direction: " + args.direction);
});
Multiple events
label.on("tap, doubleTap, longPress", function (args) {
console.log("Event: " + args.eventName);
});
• Tap
• Double Tap
• Long Press
• Swipe
• Pan
• Pinch
• Rotation
• Touch
{demo}
Debugging
“If debugging is the process of removing
software bugs, then programming must
be the process of putting them in.”
- Edsger Dijkstra
Debugging Strategies
• Debug by alert (no really)
• Debug by console.log
• Debug by Developer Tools
• Debug by IDE
• Visual Studio
• Visual Studio Code
Debug By Alert
{demo}
Telerik UI for NativeScript
- Open source
- Widgets: ListView,
SlideDrawer
- No support
UI for {N}
- Widgets: Chart,
Calendar, DataForm
- No support in entry
pricing
- UI for {N} can buy
this version for
support
UI for {N} PRO
FREE $199/$599 (with support)
Advanced, rich, native UI widgets for iOS
and Android
Telerik UI for NativeScript
npm install nativescript-telerik-ui --save
• Add powerful
ListView,
SlideDrawer to
apps
• Free native
widgets
• Support available
with PRO license
Custom XML Components
<page xmlns:custom="modules/mymodule">
<custom:MyCustomControl />
</page>
• Encapsulate
reusable UI in
components
• JS only, OR
• XML + CSS + JS
• Add to pages with
xmlns
modules
mymodule
.XML
MyCustomControl.js
MyCustomControl.css
MyCustomControl.xml
{demo}
Navigating Views
Basics
• Topmost frame is root-
level container
• Facilitates navigation between
views
"topmost frame"
var frameModule = require("ui/frame");
var topmost = frameModule.topmost();
Navigating with "topmost"
1. By File Name
topmost.navigate("details-page");
2. With Navigation Entry
var navigationEntry = {
moduleName: "details-page",
context: {info: "something"},
animated: false
};
topmost.navigate(navigationEntry);
3. Dynamically with Function
var factoryFunc = function () {
var page = new pagesModule.Page();
page.content = ...
return page;
};
topmost.navigate(factoryFunc);
• Always navigating with
topmost.navigate()
• Pass context to views
and parse in
onNavigatedTo event
• Go back with:
• topmost.goBack();
View transitions
var navigationEntry = {
moduleName: "main-page",
animated: true,
transition: {
name: "slide",
duration: 380,
curve: "easeIn" }
};
topmost.navigate(navigationEntry);
• curl (same as curlUp) (iOS only)
• curlUp (iOS only)
• curlDown (iOS only)
• explode (Android Lollipop and later)
• fade
• flip (same as flipRight)
• flipRight
• flipLeft
• slide (same as slideLeft)
• slideLeft
• slideRight
• slideTop
• slideBottom
Different transitions can be set
for iOS and Android
{demo}
Basic Data Binding
Data binding
{{ newTodo }}
{demo}
Data binding improved
Data binding lists
<Page>
<StackLayout>
<ListView items="{{ items }}" height="200">
<ListView.itemTemplate>
<Label text="{{ $value }}" />
</ListView.itemTemplate>
</ListView>
</StackLayout>
</Page>
• Bind to array or
collection of data
• Access named
properties or
$value
• Access parent
binding context
with $parents
• EX: OrderID in list of
Order Details
{{ todos }}
{{ $value }}
{demo}
Data binding expressions
Static Expression
<TextField text="{{ sourceProperty, sourceProperty + ' some static text' }}" />
Ternary Operator
<TextField class="{{ isConditionTrue ? 'myClass true' : 'myClass false' }}" />
Converter
<TextField text="{{ testDate, testDate | dateConverter('DD.MM.YYYY') }}" />
Execute expressions during data binding to
determine visual state
Source Property Binding Expression
Converters
var dateConverter = {
toView: function (value, format) {
var result = format;
var day = value.getDate();
...
//Return formatted model value
return result;
},
toModel: function (value, format) {
//Convert value from UI format to model format
return result;
}
}
• Encapsulate more
complex data
binding formatting
rules
• Can be one-way or
two-way
• Add to page
binding context OR
global application
context
Data binding expressions
Feature Example
property access obj1.obj2.prop1
array access arrayVar[indexVar]
logical operators !var1
unary operators +var1, -var2
binary operators var1 + var2
comparison operators var1 > var2
logical comparison operators var1>1 && var2>1.
ternary operator var1 ? var2 : var3
grouping parenthesis (a + b) * (c + d)
function calls myFunc(var1, var2, ..., varN)
filters expression | filter1(param1, ...) | filter 2
{{ total, total +' items left' }}
{demo}
Basic Styling with CSS
CSS
Convention:
app.css <-- Global styles
[viewName].css <-- View styles
[viewName].[platform].css
Supported Properties
• color
• background-color
• background-image
• background-repeat
• background-position
• background-size
• border-color
• border-width
• border-radius
• font
• font-family
• font-size
• font-style
• font-weight
• text-align
• text-decoration
• text-transform
• vertical-align
• horizontal-align
• margin
• margin-top
• margin-right
• margin-bottom
• margin-left
• width
• height
• min-width
• min-height
• padding
• padding-top
• padding-right
• padding-bottom
• padding-left
• visibility
• opacity
Supported Selectors
• Type
• button { color: red; }
• Class
• .mybutton { color: green; }
• ID
• #myButton { color: #FFF; }
{demo}
Custom Fonts
1. Use TTF or OTF fonts
2. Put fonts in: app > fonts
3. Use in CSS
.icon {
font-size: 30;
font-family: 'FontAwesome';
}
{demo}
Sass & LESS
• Use Sass or LESS syntax
• Auto-compiled
$ tns install sass
OR
$tns install less
Pre-lunch Wrap-up
Bottom line
• Access all native APIs with JavaScript
• 0-day support for new APIs
• Use modules to increase cross-platform “write
once”
• Use CSS to style native UI
• Use XML markup to define views
• Use CLI (+ IDE integrations) or Telerik Platform to
build and debug
Lunch Break Resume @ 1PM
Workshop Agenda
• Intro to NativeScript
• NativeScript core concepts
• “Hello World”
• Defining Views
• Debugging JavaScript
• Basic data binding
• Styling views with CSS
• Intro to Angular 2 concepts
• Angular 2 + NativeScript
• Navigating views
• BONUS
• Extending with plugins
• Adding animations
• Using Telerik Platform
Ante Meridiem (9AM to Noon) Post Meridiem (1PM to 4PM)
Adoption trends
Warm the brains-up after lunch
Adoption Goals (2016)
Goal for 2016: Grow NativeScript adoption by 15x
Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov DecAug Sept Oct Nov Dec
2x
2016
5x
3x
Google Angular2 event (“ngConf”);
NativeScript Angular2 push begins
Measured* active developers
(via NativeScript CLI)
• Active monthly
CLI users doubled
Aug to Dec ‘15
• Doubled again
Dec to Feb ‘16
• On track to
double again by
end of April
60% increase in
new users since
January
Developer Comments
Join the growing
NativeScript
community on Slack
bit.ly/nativescript-slack
Integrations & Ecosystem
Plugin Ecosystem
Plugin Ecosystem
Reusable libraries IDEs Verified Plugins
Modulus Sachse Construction Day Care This or That!
PocketSmith
“With NativeScript it became apparent
quickly that we would no longer have a
need for iOS and Android specialists—
our Microsoft .NET team became fully
functional—fast.”
Allan Kreyer, CIM Mobility Founder
Angular 2 & NativeScript
One framework. Mobile & desktop.
Mobile
Responsive
PWA (Progressive Web Apps)
Native Mobile
Why Angular 2?
Template
< ... >
Component
{ ... }
Metadata
Directive
{ ... }
Injector
Service A
Service B
Renderer
Template
< ... >
Renderer
Template
< ... >
An Intro to Angular 2
Template
< ... >
Component
{ ... }
Metadata
Directive
{ ... }
Injector
Service A
Service B
Template
< ... >
Component
{ ... }
Metadata
<!DOCTYPE html>
<html>
<head>
<base href="/">
</head>
<body ng-app=”app">
<app>Loading...</app>
<script src="bundle.js"></script>
</body>
</html>
index.html
const AppComponent = {
template: `
<h1>Root Component</h1>
`
};
angular
.module('app', [])
.component('app', AppCompon3ent);
app.js
Root Component
const AppComponent = {
template: `
<h1>Root Component</h1>
`
};
angular
.module('app', [])
.component('app', AppComponent);
app.js
const AppComponent = {
template: `
<h1>Root Component</h1>
`
};
angular
.module('app', [])
.component('app', AppComponent);
app.component.ts
import { Component } from ”@angular/core”
const AppComponent = {
template: `
<h1>Root Component</h1>
`
};
angular
.module('app', [])
.component('app', AppComponent);
app.component.ts
import { Component } from ”@angular/core”
@Component({
template: `
<h1>Root Component</h1>
`
});
angular
.module('app', [])
.component('app', AppComponent);
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>Root Component</h1>
`
});
angular
.module('app', [])
.component('app', AppComponent);
app.component.ts
<!DOCTYPE html>
<html>
<head>
<base href="/">
</head>
<body ng-app=”app">
<app>Loading...</app>
<script src="bundle.js"></script>
</body>
</html>
index.html
<!DOCTYPE html>
<html>
<head>
<base href="/">
</head>
<body>
<app>Loading...</app>
<script src="bundle.js"></script>
</body>
</html>
index.html
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>Root Component</h1>
`
});
angular
.module('app', [])
.component('app', AppComponent);
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>Root Component</h1>
`
});
export class AppComponent {}
app.component.ts
Root Component
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>Root Component</h1>
`
});
export class AppComponent {}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>Root Component</h1>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>{{ message }}</h1>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
Root Component
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<h1>{{ message }}</h1>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input value=”{{ message }}”>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [value]=”message”>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
[ value ] or {{ value }} = One way binding from
class to view
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [value]=”message”>
`
});
export class AppComponent {
message: 'Root Component'
}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [value]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: 'Root Component’;
showMessage() {
alert(this.message);
}
}
app.component.ts
Root Component Show Me
The page at http://localhost/3000 says:
Root Component
( event ) = Binds an event to a function
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [value]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: 'Root Component’;
showMessage() {
alert(this.message);
}
}
app.component.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: 'Root Component’;
showMessage() {
alert(this.message);
}
}
app.component.ts
[(ngModel)] = Two way binding
Services And Injection
export class MessageService {
message: string = ”Service Message”
}
message.service.ts
import { Injectable } from ”@angular/core”
export class MessageService {
message: string = ”Service Message”
}
message.service.ts
import { Injectable } from ”@angular/core”
@Injectable()
export class MessageService {
message: string = ”Service Message”
}
message.service.ts
import { Component } from ”@angular/core”
@Component({
selector: 'app',
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: 'Root Component’;
showMessage() {
alert(this.message);
}
}
app.component.ts
import { Component } from ”@angular/core”
import { MessageService } from ”./message.service”
@Component({
selector: 'app',
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: 'Root Component’;
showMessage() {
alert(this.message);
}
} app.component.ts
@Component({
selector: 'app',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
} app.component.ts
Service Message Show Me
The page at http://localhost/3000 says:
Service Message
Directives
import { Component } from ”@angular/core”
import { MessageService } from ”./message.service.ts”
@Component({
selector: 'app',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
app.component.ts
import { MessageService } from ”./message.service.ts”
export class MessageDirective {
}
message.directive.ts
import { MessageService } from ”./message.service.ts”
@Component({
selector: ’message',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class MessageDirective {
}
message.directive.ts
import { MessageService } from ”./message.service.ts”
@Component({
selector: ’message',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class MessageDirective {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
message.directive.ts
import { Component } from ”@angular/core”
import { MessageService } from ”./message.service.ts”
@Component({
selector: 'app',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
app.component.ts
import { Component } from ”@angular/core”
import { MessageDirective } from ”./message.directive.ts”
@Component({
selector: 'app',
providers: [MessageService]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
app.component.ts
import { Component } from ”@angular/core”
import { MessageDirective } from ”./message.directive.ts”
@Component({
selector: 'app',
directives: [MessageDirective]
template: `
<input [(ngModel)]=”message”>
<button (click)=“showMessage()”>Show Message</button>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
app.component.ts
import { Component } from ”@angular/core”
import { MessageDirective } from ”./message.directive.ts”
@Component({
selector: 'app',
directives: [MessageDirective]
template: `
<message></message>
`
});
export class AppComponent {
message: string;
showMessage() {
alert(this.message);
}
constructor(MessageService _messageService) {
this.message = _messageService.message;
}
}
app.component.ts
import { Component } from ”@angular/core”
import { MessageDirective } from ”./message.directive.ts”
@Component({
selector: 'app',
directives: [MessageDirective]
template: `
<message></message>
`
});
export class AppComponent {}
app.component.ts
Service Message Show Me
The page at http://localhost/3000 says:
Service Message
{demo}
Let’s Code
an open source framework for building truly
native mobile apps with JavaScript. Use web
skills, like Angular and CSS, and get native UI
and performance on iOS and Android.
NativeScript is…
NativeScript
delivers the promises
of “hybrid.”
APENDIX
Adding TypeScript
tns install typescript
{demo}
Common App Patterns
• Services
• An object that is responsible for getting and setting data
• Models
• Super dumb objects that define the structure of the data
• ViewModels
• AKA Controllers. Controls the state of the UI and performs when
changes are made to model objects.
Angular 2
Data binding with Angular
• {{ }} – still works!
• You can still use {N}'s standard binding…
• But you can do it even better.
• [] – Property binding
• One way.
• Like array notation in JavaScript. One way
• () – Event Binding
• When you want to bind to an event.
• Two Way – [(ngModel)]
• Almost always used with ngModel
Extra Angular Goodies
• Dependency Injection
• Routing
• Components
• Pipes
• Services
• FAST
Using Telerik Platform
Cloud-based tooling for NativeScript
Why?
• Cloud based, zero setup
• Build for iOS from Windows
• Deploy to device without provisioning profiles
• Manage app properties faster
AppBuilder
Screen Builder
Companion App
{demo}
Animations
Animation basics
Animate:
• opacity
• backgroundColor
• translateX and translateY
• scaleX and scaleY
• rotate
Configure:
• target (UI element)
• duration (in ms)
• delay
• iterations
• curve
Simple animation
var view = page.getViewById("myLabel");
view.animate({
translate: { x: 0, y: 100},
duration: 1000,
curve: enums.AnimationCurve.easeIn
});
• Animations can be
chained together
• Multiple
properties and
elements can be
animated
• Return a promise
that can be
canceled
{demo}

Más contenido relacionado

La actualidad más candente

Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Native Script Overview
Native Script OverviewNative Script Overview
Native Script OverviewBaskar rao Dsn
 
React native-meetup-talk
React native-meetup-talkReact native-meetup-talk
React native-meetup-talkkiranabburi
 
Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Fwdays
 
React Native Intro
React Native IntroReact Native Intro
React Native IntroJulia Vi
 
Cross-Platform Mobile Development with Ionic Framework and Angular
Cross-Platform Mobile Development with Ionic Framework and AngularCross-Platform Mobile Development with Ionic Framework and Angular
Cross-Platform Mobile Development with Ionic Framework and AngularMovel
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeSambhu Lakshmanan
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic frameworkShyjal Raazi
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react nativeModusJesus
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsAndreas Sahle
 
React Native in a nutshell
React Native in a nutshellReact Native in a nutshell
React Native in a nutshellBrainhub
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Devin Abbott
 
When to (use / not use) React Native.
When to (use / not use) React Native.When to (use / not use) React Native.
When to (use / not use) React Native.Bobby Schultz
 
Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)Mark Leusink
 
An iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React NativeAn iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React NativeAleksandras Smirnovas
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Native script overview
Native script overviewNative script overview
Native script overviewBaskar rao Dsn
 

La actualidad más candente (20)

React Native
React NativeReact Native
React Native
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Native Script Overview
Native Script OverviewNative Script Overview
Native Script Overview
 
React native-meetup-talk
React native-meetup-talkReact native-meetup-talk
React native-meetup-talk
 
Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"
 
React Native Intro
React Native IntroReact Native Intro
React Native Intro
 
Cross-Platform Mobile Development with Ionic Framework and Angular
Cross-Platform Mobile Development with Ionic Framework and AngularCross-Platform Mobile Development with Ionic Framework and Angular
Cross-Platform Mobile Development with Ionic Framework and Angular
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic framework
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile apps
 
React Native in a nutshell
React Native in a nutshellReact Native in a nutshell
React Native in a nutshell
 
Cross-Platform Development
Cross-Platform DevelopmentCross-Platform Development
Cross-Platform Development
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)
 
When to (use / not use) React Native.
When to (use / not use) React Native.When to (use / not use) React Native.
When to (use / not use) React Native.
 
Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)
 
An iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React NativeAn iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React Native
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Native script overview
Native script overviewNative script overview
Native script overview
 

Destacado

Nativescript
NativescriptNativescript
NativescriptAutentia
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSSTodd Anglin
 
PUG Challenge 2016 - The nativescript pug app challenge
PUG Challenge 2016 -  The nativescript pug app challengePUG Challenge 2016 -  The nativescript pug app challenge
PUG Challenge 2016 - The nativescript pug app challengeBronco Oostermeyer
 
[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache CordovaHazem Saleh
 
Cordova: APIs and instruments
Cordova: APIs and instrumentsCordova: APIs and instruments
Cordova: APIs and instrumentsIvano Malavolta
 
Muammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne BuchMuammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne BuchMCExorzist
 
Politische Ponerologie
Politische PonerologiePolitische Ponerologie
Politische PonerologieMCExorzist
 
Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)MCExorzist
 
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233SGerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233SMCExorzist
 
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi GermanyThomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi GermanyMCExorzist
 
JavaScript - The Universal Platform?
JavaScript - The Universal Platform?JavaScript - The Universal Platform?
JavaScript - The Universal Platform?Jonas Bandi
 
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewFrom Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewItalo Mairo
 
Angela Merkel - Doktorarbeit
Angela Merkel - DoktorarbeitAngela Merkel - Doktorarbeit
Angela Merkel - DoktorarbeitMCExorzist
 
Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)David Neal
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)David Neal
 

Destacado (20)

Nativescript with angular 2
Nativescript with angular 2Nativescript with angular 2
Nativescript with angular 2
 
Native Script by Sebastian Witalec
Native Script by Sebastian WitalecNative Script by Sebastian Witalec
Native Script by Sebastian Witalec
 
Nativescript
NativescriptNativescript
Nativescript
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSS
 
PUG Challenge 2016 - The nativescript pug app challenge
PUG Challenge 2016 -  The nativescript pug app challengePUG Challenge 2016 -  The nativescript pug app challenge
PUG Challenge 2016 - The nativescript pug app challenge
 
[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova
 
Cordova: APIs and instruments
Cordova: APIs and instrumentsCordova: APIs and instruments
Cordova: APIs and instruments
 
JS Class 2016
JS Class 2016JS Class 2016
JS Class 2016
 
Muammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne BuchMuammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne Buch
 
Politische Ponerologie
Politische PonerologiePolitische Ponerologie
Politische Ponerologie
 
Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)
 
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233SGerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
 
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi GermanyThomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
 
JavaScript - The Universal Platform?
JavaScript - The Universal Platform?JavaScript - The Universal Platform?
JavaScript - The Universal Platform?
 
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewFrom Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
 
Angela Merkel - Doktorarbeit
Angela Merkel - DoktorarbeitAngela Merkel - Doktorarbeit
Angela Merkel - Doktorarbeit
 
Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
 
Electron
ElectronElectron
Electron
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 

Similar a NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular

NativeScript and Angular
NativeScript and AngularNativeScript and Angular
NativeScript and AngularJen Looper
 
Universal Applications with Universal JavaScript
Universal Applications with Universal JavaScriptUniversal Applications with Universal JavaScript
Universal Applications with Universal JavaScriptThomas Joseph
 
Ignite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseIgnite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseJen Looper
 
Angular 2 and NativeScript
Angular 2 and NativeScriptAngular 2 and NativeScript
Angular 2 and NativeScriptJen Looper
 
NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行Osamu Monoe
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedsparkfabrik
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyNick Landry
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Applitools
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_uDoris Chen
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo SurabayaDILo Surabaya
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkTroy Miles
 
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-Platform
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-PlatformVisual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-Platform
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-PlatformStefano Ottaviani
 
Cross-Platform Development using Angulr JS in Visual Studio
Cross-Platform Development using Angulr JS in Visual StudioCross-Platform Development using Angulr JS in Visual Studio
Cross-Platform Development using Angulr JS in Visual StudioMizanur Sarker
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsJohn M. Wargo
 
The Great Mobile Debate: Native vs. Hybrid App Development
The Great Mobile Debate: Native vs. Hybrid App DevelopmentThe Great Mobile Debate: Native vs. Hybrid App Development
The Great Mobile Debate: Native vs. Hybrid App DevelopmentNick Landry
 
Mono for Android... for Google Devs
Mono for Android... for Google DevsMono for Android... for Google Devs
Mono for Android... for Google DevsCraig Dunn
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React NativeDarren Cruse
 
Build Your First iPhone or Android App with Telerik AppBuilder
Build Your First iPhone or Android App with Telerik AppBuilderBuild Your First iPhone or Android App with Telerik AppBuilder
Build Your First iPhone or Android App with Telerik AppBuilderJeffrey T. Fritz
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinPranav Ainavolu
 

Similar a NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular (20)

NativeScript and Angular
NativeScript and AngularNativeScript and Angular
NativeScript and Angular
 
Universal Applications with Universal JavaScript
Universal Applications with Universal JavaScriptUniversal Applications with Universal JavaScript
Universal Applications with Universal JavaScript
 
Ignite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseIgnite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and Firebase
 
Angular 2 and NativeScript
Angular 2 and NativeScriptAngular 2 and NativeScript
Angular 2 and NativeScript
 
NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET Guy
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo Surabaya
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-Platform
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-PlatformVisual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-Platform
Visual Studio 2015: novità per gli sviluppatori iOS, Android e Cross-Platform
 
Cross-Platform Development using Angulr JS in Visual Studio
Cross-Platform Development using Angulr JS in Visual StudioCross-Platform Development using Angulr JS in Visual Studio
Cross-Platform Development using Angulr JS in Visual Studio
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile Apps
 
The Great Mobile Debate: Native vs. Hybrid App Development
The Great Mobile Debate: Native vs. Hybrid App DevelopmentThe Great Mobile Debate: Native vs. Hybrid App Development
The Great Mobile Debate: Native vs. Hybrid App Development
 
Mono for Android... for Google Devs
Mono for Android... for Google DevsMono for Android... for Google Devs
Mono for Android... for Google Devs
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
 
Build Your First iPhone or Android App with Telerik AppBuilder
Build Your First iPhone or Android App with Telerik AppBuilderBuild Your First iPhone or Android App with Telerik AppBuilder
Build Your First iPhone or Android App with Telerik AppBuilder
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with Xamarin
 

Más de Todd Anglin

Making HTML5 Work Everywhere
Making HTML5 Work EverywhereMaking HTML5 Work Everywhere
Making HTML5 Work EverywhereTodd Anglin
 
Developing a Modern Mobile App Strategy
Developing a Modern Mobile App StrategyDeveloping a Modern Mobile App Strategy
Developing a Modern Mobile App StrategyTodd Anglin
 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptTodd Anglin
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationTodd Anglin
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScriptTodd Anglin
 
50in50: Resources for HTML5, CSS3, & JavaScript Developers
50in50: Resources for HTML5, CSS3, & JavaScript Developers50in50: Resources for HTML5, CSS3, & JavaScript Developers
50in50: Resources for HTML5, CSS3, & JavaScript DevelopersTodd Anglin
 
Using HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile AppsUsing HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile AppsTodd Anglin
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayTodd Anglin
 
HTML5 for Tablets and Mobile
HTML5 for Tablets and MobileHTML5 for Tablets and Mobile
HTML5 for Tablets and MobileTodd Anglin
 
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET DevelopersAccelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET DevelopersTodd Anglin
 
Building RESTful Applications with OData
Building RESTful Applications with ODataBuilding RESTful Applications with OData
Building RESTful Applications with ODataTodd Anglin
 
Building a Testable Data Access Layer
Building a Testable Data Access LayerBuilding a Testable Data Access Layer
Building a Testable Data Access LayerTodd Anglin
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayTodd Anglin
 
The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5Todd Anglin
 
What’s New in ASP.NET 4
What’s New in ASP.NET 4What’s New in ASP.NET 4
What’s New in ASP.NET 4Todd Anglin
 

Más de Todd Anglin (15)

Making HTML5 Work Everywhere
Making HTML5 Work EverywhereMaking HTML5 Work Everywhere
Making HTML5 Work Everywhere
 
Developing a Modern Mobile App Strategy
Developing a Modern Mobile App StrategyDeveloping a Modern Mobile App Strategy
Developing a Modern Mobile App Strategy
 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScript
 
50in50: Resources for HTML5, CSS3, & JavaScript Developers
50in50: Resources for HTML5, CSS3, & JavaScript Developers50in50: Resources for HTML5, CSS3, & JavaScript Developers
50in50: Resources for HTML5, CSS3, & JavaScript Developers
 
Using HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile AppsUsing HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile Apps
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use Today
 
HTML5 for Tablets and Mobile
HTML5 for Tablets and MobileHTML5 for Tablets and Mobile
HTML5 for Tablets and Mobile
 
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET DevelopersAccelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
 
Building RESTful Applications with OData
Building RESTful Applications with ODataBuilding RESTful Applications with OData
Building RESTful Applications with OData
 
Building a Testable Data Access Layer
Building a Testable Data Access LayerBuilding a Testable Data Access Layer
Building a Testable Data Access Layer
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use Today
 
The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5
 
What’s New in ASP.NET 4
What’s New in ASP.NET 4What’s New in ASP.NET 4
What’s New in ASP.NET 4
 

Último

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 

Último (20)

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 

NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular

  • 3. Workshop Agenda • Intro to NativeScript • NativeScript core concepts • “Hello World” • Defining Views • Debugging JavaScript • Basic data binding • Styling views with CSS • Intro to Angular 2 concepts • Angular 2 + NativeScript • Navigating views • BONUS • Extending with plugins • Adding animations • Using Telerik Platform Ante Meridiem (9AM to Noon) Post Meridiem (1PM to 4PM)
  • 4. Intro to NativeScript ”How did we get here?”
  • 5. 2013 2014 2015 2016 2017 Early prototypes “Core” engineering Public launch Adoption ramp-up Mass adoption Project Timeline
  • 6. Delivering on the overdue promise of “hybrid.”
  • 9. We ❤ Web. But… We need: • Better offline support • Access to device APIs • Home screen icons • Push notifications • App monetization • …
  • 12. 80% coded 20% remaining 80% of dev time Hybrid Reality
  • 13. 80% coded 20% remaining 80% of dev time 80% of dev time Hybrid Reality
  • 16. Binary Choice NativeHybrid 😎 Best experience 🐢 One platform at a time 🔥 Fast to market 😭 Compromise on UX
  • 17. Binary Choice NativeHybrid 🔥 Fast to market 😎 Best experience
  • 18. JavaScript- driven native 🔥 Fast to market 😎 Best experience
  • 19. "Hybrid" Web UI with limited access to native APIs Native App Shell WebView Plugins Plugins Entire app lives here
  • 20. Native App "JavaScript-driven Native" Native UI driven by JavaScript Native UI JavaScript-to-Native bridge JavaScript Engine (Your app code runs here) Native APIs
  • 21. NativeScript (by Telerik) React Native (by Facebook) “JavaScript-drive Native”
  • 22. Native App Native UI JavaScript-to-Native runtime JavaScript Engine (Your app code runs here) Native APIs Native App Native UI JavaScript Engine (Your app code runs here) Native APIs API Wrapper API Wrapper PluginsPlugins API Wrapper API Wrapper API Wrapper API Wrapper Plugins created with JS/TypeScript Plugins created with native code
  • 23. “JavaScript-driven Native” • Share code • Reuse existing skills/teams • Reuse existing libraries • Native UI (no WebView!) • Full access to device APIs • Immediate access to new OS features 🔥 Fast to market 😎 Best experience
  • 24. What is NativeScript? • Open source framework (ASLv2) • Create native mobile apps for iOS, Android (and eventually Windows 10) • Use JavaScript (“web skills”) • Write once, run everywhere • Share 100% code between iOS/Android • Share 80% code with web • Reuse popular plugins from NodeJS/iOS/Android • Integrates deeply with Angular and TypeScript
  • 25. With NativeScript… • No web views (platform native UI) • Use JavaScript (or TypeScript) • 100% access to ALL native APIs (even new APIs) • Made for “web developers” (JS, CSS, XML) • Use Angular for web AND native mobile • Reuse thousands of libraries from Node/iOS/Android/Web
  • 27. Demo available in the app stores in May Rich, animated, “no compromise” native UI (with shared UI code) 1
  • 29. Maximum code and skill reusability 3 Video credit: Nathan Walker, {N} community member
  • 31.
  • 32. Generated at build time for OS & 3rd party native libraries
  • 35.
  • 36. Runs on V8 JavaScript VM Runs on JavaScriptCore VM
  • 37.
  • 38. NativeScript Module Layer (NML) • Abstractions on native APIs that provide unified, cross-platform API • Dozens available out of the box • Easy for developers to add • IMPORTANT: All native APIs still available at JavaScript layer for platform-specific scenarios • NativeScript modules follow Node module’s conventions (CommonJS).
  • 40.
  • 41.
  • 42. Putting it all together Style with CSSDefine UI with XML Logic with JavaScript
  • 43.
  • 45. Two ways to use NativeScript 1) 2)
  • 46. Command Line Interface (CLI) • Use Command Prompt (Win) or Terminal (Mac, Linux) • Free, Part of open source project • Requires installation, local environment setup to build for iOS/Android (requires Mac for iOS) • Integrates with Visual Studio Code (via plugin) WHY: More control, Free, Integrate with existing IDEs/code editors WHO: More technical developers used to using CLI, Open source developers
  • 47. Telerik Platform • Use AppBuilder or Screen Builder • Subscription required • Build in the cloud (no local install required) • Easiest way to get started WHY: Richer tooling, Easier setup, Platform integrated WHO: Less technical developers, Prefer Platform integrations, Windows developers targeting iOS
  • 48. Telerik Platform Powerful visual tooling, cloud builds and more for NativeScript app developers.
  • 49. NativeScript CLI requirements https://github.com/nativescript/nativescript-cli#system-requirements Xcode, Xcode CLI tools, iOS SDK JDK, Apache Ant, Android SDK $ tns doctor
  • 50. Choice in Architecture JavaScript Write your application using plain JavaScript TypeScript Use TypeScript to get Object Oriented features and compile time error checking Angular Use Angular to architect application. Reuse almost all code between web and mobile
  • 51. Angular & TypeScript • Created by Google • Open source • Popular JavaScript framework for building complex web apps • “Angular 2” ships in May • Created by Microsoft • Open source • Popular compiler for JavaScript that adds powerful language features • Used to create Angular 2 and {N}
  • 52. Starting a new project
  • 54. Running on iOS or $ tns emulate ios
  • 55. Running on Android or $ tns emulate android
  • 56. A better Android emulator Visual Studio Android Emulator Genymotion
  • 57. NativeScript LiveSync $ tns livesync //For all connected devices/emulators $ tns livesync android //Target specific platform $ tns livesync ios --emulator $ tns livesync ios --emulator --watch • Refresh app with latest changes to JS, CSS, XML • No re-build • Works with emulators AND device
  • 58.
  • 61. Pages • XML markup structure • Elements (e.g. <Page>, <Label>) are NativeScript modules
  • 64.
  • 65. UI Widgets • Button • Label • TextField • TextView • SearchBar • Switch • Slider • Progress • ActivityIndicator • Image • ListView • HtmlView • WebView • TabView • SegmentedBar • DatePicker • TimePicker • ListPicker • Dialogs Out-of-the-box Native UI widgets means… • Native behavior • Native perf • Native accessibility • Parity with “native”
  • 66. Native UI widgets Native API {N} Module button android.widget.Button UIButton
  • 70. Targeting Views • Target based on: • screens size • minWH<X>, minW<X>, minH<X> • platform • ios, android, windows • Orientation • land, port <file-name>[.<qualifier>]*.<extension> styles.android.css styles.ios.css mypage.minWH600.xml mypage.xml
  • 71. TIP • Platform specific capabilities are always available • JavaScript: <view>.android or <view>.ios • Markup: <android></android> or <ios></ios> • Attributes: android:<attribute> or ios:<attribute> • Ex: <label android:class="…" ios:class="…" /> Write once by default. Target specific platform capabilities when needed.
  • 73. Handling Events XML <button text="Click Me" tap="{{ onTap }}" ... JS (ViewModel) function pageViewModel() { var viewModel; viewModel.onTap = function() { alert("You tapped me!"); } return viewModel; } exports.pageViewModel = pageViewModel; JS (View) function onViewLoad(args) { var page = args.object; page.bindingContext = pageViewModel(); } • Create event handlers in JavaScript • Bind to event names
  • 74. Handling Events tap label.on(gestures.GestureTypes.tap, function (args) { console.log("Tap"); }); swipe label.on(gestures.GestureTypes.swipe, function (args) { console.log("Swipe Direction: " + args.direction); }); Multiple events label.on("tap, doubleTap, longPress", function (args) { console.log("Event: " + args.eventName); }); • Tap • Double Tap • Long Press • Swipe • Pan • Pinch • Rotation • Touch
  • 77. “If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra
  • 78. Debugging Strategies • Debug by alert (no really) • Debug by console.log • Debug by Developer Tools • Debug by IDE • Visual Studio • Visual Studio Code
  • 81. Telerik UI for NativeScript - Open source - Widgets: ListView, SlideDrawer - No support UI for {N} - Widgets: Chart, Calendar, DataForm - No support in entry pricing - UI for {N} can buy this version for support UI for {N} PRO FREE $199/$599 (with support) Advanced, rich, native UI widgets for iOS and Android
  • 82. Telerik UI for NativeScript npm install nativescript-telerik-ui --save • Add powerful ListView, SlideDrawer to apps • Free native widgets • Support available with PRO license
  • 83. Custom XML Components <page xmlns:custom="modules/mymodule"> <custom:MyCustomControl /> </page> • Encapsulate reusable UI in components • JS only, OR • XML + CSS + JS • Add to pages with xmlns modules mymodule .XML MyCustomControl.js MyCustomControl.css MyCustomControl.xml
  • 84.
  • 87. Basics • Topmost frame is root- level container • Facilitates navigation between views "topmost frame" var frameModule = require("ui/frame"); var topmost = frameModule.topmost();
  • 88. Navigating with "topmost" 1. By File Name topmost.navigate("details-page"); 2. With Navigation Entry var navigationEntry = { moduleName: "details-page", context: {info: "something"}, animated: false }; topmost.navigate(navigationEntry); 3. Dynamically with Function var factoryFunc = function () { var page = new pagesModule.Page(); page.content = ... return page; }; topmost.navigate(factoryFunc); • Always navigating with topmost.navigate() • Pass context to views and parse in onNavigatedTo event • Go back with: • topmost.goBack();
  • 89. View transitions var navigationEntry = { moduleName: "main-page", animated: true, transition: { name: "slide", duration: 380, curve: "easeIn" } }; topmost.navigate(navigationEntry); • curl (same as curlUp) (iOS only) • curlUp (iOS only) • curlDown (iOS only) • explode (Android Lollipop and later) • fade • flip (same as flipRight) • flipRight • flipLeft • slide (same as slideLeft) • slideLeft • slideRight • slideTop • slideBottom Different transitions can be set for iOS and Android
  • 96. Data binding lists <Page> <StackLayout> <ListView items="{{ items }}" height="200"> <ListView.itemTemplate> <Label text="{{ $value }}" /> </ListView.itemTemplate> </ListView> </StackLayout> </Page> • Bind to array or collection of data • Access named properties or $value • Access parent binding context with $parents • EX: OrderID in list of Order Details
  • 97. {{ todos }} {{ $value }}
  • 99. Data binding expressions Static Expression <TextField text="{{ sourceProperty, sourceProperty + ' some static text' }}" /> Ternary Operator <TextField class="{{ isConditionTrue ? 'myClass true' : 'myClass false' }}" /> Converter <TextField text="{{ testDate, testDate | dateConverter('DD.MM.YYYY') }}" /> Execute expressions during data binding to determine visual state Source Property Binding Expression
  • 100. Converters var dateConverter = { toView: function (value, format) { var result = format; var day = value.getDate(); ... //Return formatted model value return result; }, toModel: function (value, format) { //Convert value from UI format to model format return result; } } • Encapsulate more complex data binding formatting rules • Can be one-way or two-way • Add to page binding context OR global application context
  • 101. Data binding expressions Feature Example property access obj1.obj2.prop1 array access arrayVar[indexVar] logical operators !var1 unary operators +var1, -var2 binary operators var1 + var2 comparison operators var1 > var2 logical comparison operators var1>1 && var2>1. ternary operator var1 ? var2 : var3 grouping parenthesis (a + b) * (c + d) function calls myFunc(var1, var2, ..., varN) filters expression | filter1(param1, ...) | filter 2
  • 102. {{ total, total +' items left' }}
  • 103. {demo}
  • 105. CSS Convention: app.css <-- Global styles [viewName].css <-- View styles [viewName].[platform].css
  • 106. Supported Properties • color • background-color • background-image • background-repeat • background-position • background-size • border-color • border-width • border-radius • font • font-family • font-size • font-style • font-weight • text-align • text-decoration • text-transform • vertical-align • horizontal-align • margin • margin-top • margin-right • margin-bottom • margin-left • width • height • min-width • min-height • padding • padding-top • padding-right • padding-bottom • padding-left • visibility • opacity
  • 107. Supported Selectors • Type • button { color: red; } • Class • .mybutton { color: green; } • ID • #myButton { color: #FFF; }
  • 108. {demo}
  • 109. Custom Fonts 1. Use TTF or OTF fonts 2. Put fonts in: app > fonts 3. Use in CSS .icon { font-size: 30; font-family: 'FontAwesome'; }
  • 110. {demo}
  • 111. Sass & LESS • Use Sass or LESS syntax • Auto-compiled $ tns install sass OR $tns install less
  • 113.
  • 114. Bottom line • Access all native APIs with JavaScript • 0-day support for new APIs • Use modules to increase cross-platform “write once” • Use CSS to style native UI • Use XML markup to define views • Use CLI (+ IDE integrations) or Telerik Platform to build and debug
  • 116. Workshop Agenda • Intro to NativeScript • NativeScript core concepts • “Hello World” • Defining Views • Debugging JavaScript • Basic data binding • Styling views with CSS • Intro to Angular 2 concepts • Angular 2 + NativeScript • Navigating views • BONUS • Extending with plugins • Adding animations • Using Telerik Platform Ante Meridiem (9AM to Noon) Post Meridiem (1PM to 4PM)
  • 117.
  • 118. Adoption trends Warm the brains-up after lunch
  • 119. Adoption Goals (2016) Goal for 2016: Grow NativeScript adoption by 15x Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov DecAug Sept Oct Nov Dec 2x 2016 5x 3x Google Angular2 event (“ngConf”); NativeScript Angular2 push begins Measured* active developers (via NativeScript CLI)
  • 120. • Active monthly CLI users doubled Aug to Dec ‘15 • Doubled again Dec to Feb ‘16 • On track to double again by end of April 60% increase in new users since January
  • 121.
  • 123. Join the growing NativeScript community on Slack bit.ly/nativescript-slack
  • 126. Plugin Ecosystem Reusable libraries IDEs Verified Plugins
  • 127.
  • 128.
  • 129. Modulus Sachse Construction Day Care This or That! PocketSmith
  • 130. “With NativeScript it became apparent quickly that we would no longer have a need for iOS and Android specialists— our Microsoft .NET team became fully functional—fast.” Allan Kreyer, CIM Mobility Founder
  • 131. Angular 2 & NativeScript
  • 132.
  • 133.
  • 134. One framework. Mobile & desktop.
  • 135. Mobile
  • 136. Responsive PWA (Progressive Web Apps) Native Mobile
  • 138. Template < ... > Component { ... } Metadata Directive { ... } Injector Service A Service B
  • 141. An Intro to Angular 2
  • 142.
  • 143.
  • 144. Template < ... > Component { ... } Metadata Directive { ... } Injector Service A Service B
  • 145. Template < ... > Component { ... } Metadata
  • 146. <!DOCTYPE html> <html> <head> <base href="/"> </head> <body ng-app=”app"> <app>Loading...</app> <script src="bundle.js"></script> </body> </html> index.html
  • 147. const AppComponent = { template: ` <h1>Root Component</h1> ` }; angular .module('app', []) .component('app', AppCompon3ent); app.js
  • 149. const AppComponent = { template: ` <h1>Root Component</h1> ` }; angular .module('app', []) .component('app', AppComponent); app.js
  • 150. const AppComponent = { template: ` <h1>Root Component</h1> ` }; angular .module('app', []) .component('app', AppComponent); app.component.ts
  • 151. import { Component } from ”@angular/core” const AppComponent = { template: ` <h1>Root Component</h1> ` }; angular .module('app', []) .component('app', AppComponent); app.component.ts
  • 152. import { Component } from ”@angular/core” @Component({ template: ` <h1>Root Component</h1> ` }); angular .module('app', []) .component('app', AppComponent); app.component.ts
  • 153. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>Root Component</h1> ` }); angular .module('app', []) .component('app', AppComponent); app.component.ts
  • 154. <!DOCTYPE html> <html> <head> <base href="/"> </head> <body ng-app=”app"> <app>Loading...</app> <script src="bundle.js"></script> </body> </html> index.html
  • 156. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>Root Component</h1> ` }); angular .module('app', []) .component('app', AppComponent); app.component.ts
  • 157. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>Root Component</h1> ` }); export class AppComponent {} app.component.ts
  • 159. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>Root Component</h1> ` }); export class AppComponent {} app.component.ts
  • 160. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>Root Component</h1> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 161. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>{{ message }}</h1> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 163. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <h1>{{ message }}</h1> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 164. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input value=”{{ message }}”> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 165. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [value]=”message”> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 166. [ value ] or {{ value }} = One way binding from class to view
  • 167. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [value]=”message”> ` }); export class AppComponent { message: 'Root Component' } app.component.ts
  • 168. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [value]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: 'Root Component’; showMessage() { alert(this.message); } } app.component.ts
  • 169. Root Component Show Me The page at http://localhost/3000 says: Root Component
  • 170. ( event ) = Binds an event to a function
  • 171. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [value]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: 'Root Component’; showMessage() { alert(this.message); } } app.component.ts
  • 172. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: 'Root Component’; showMessage() { alert(this.message); } } app.component.ts
  • 173. [(ngModel)] = Two way binding
  • 175. export class MessageService { message: string = ”Service Message” } message.service.ts
  • 176. import { Injectable } from ”@angular/core” export class MessageService { message: string = ”Service Message” } message.service.ts
  • 177. import { Injectable } from ”@angular/core” @Injectable() export class MessageService { message: string = ”Service Message” } message.service.ts
  • 178. import { Component } from ”@angular/core” @Component({ selector: 'app', template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: 'Root Component’; showMessage() { alert(this.message); } } app.component.ts
  • 179. import { Component } from ”@angular/core” import { MessageService } from ”./message.service” @Component({ selector: 'app', template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: 'Root Component’; showMessage() { alert(this.message); } } app.component.ts
  • 180. @Component({ selector: 'app', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } app.component.ts
  • 181. Service Message Show Me The page at http://localhost/3000 says: Service Message
  • 183. import { Component } from ”@angular/core” import { MessageService } from ”./message.service.ts” @Component({ selector: 'app', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } app.component.ts
  • 184. import { MessageService } from ”./message.service.ts” export class MessageDirective { } message.directive.ts
  • 185. import { MessageService } from ”./message.service.ts” @Component({ selector: ’message', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class MessageDirective { } message.directive.ts
  • 186. import { MessageService } from ”./message.service.ts” @Component({ selector: ’message', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class MessageDirective { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } message.directive.ts
  • 187. import { Component } from ”@angular/core” import { MessageService } from ”./message.service.ts” @Component({ selector: 'app', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } app.component.ts
  • 188. import { Component } from ”@angular/core” import { MessageDirective } from ”./message.directive.ts” @Component({ selector: 'app', providers: [MessageService] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } app.component.ts
  • 189. import { Component } from ”@angular/core” import { MessageDirective } from ”./message.directive.ts” @Component({ selector: 'app', directives: [MessageDirective] template: ` <input [(ngModel)]=”message”> <button (click)=“showMessage()”>Show Message</button> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } app.component.ts
  • 190. import { Component } from ”@angular/core” import { MessageDirective } from ”./message.directive.ts” @Component({ selector: 'app', directives: [MessageDirective] template: ` <message></message> ` }); export class AppComponent { message: string; showMessage() { alert(this.message); } constructor(MessageService _messageService) { this.message = _messageService.message; } } app.component.ts
  • 191. import { Component } from ”@angular/core” import { MessageDirective } from ”./message.directive.ts” @Component({ selector: 'app', directives: [MessageDirective] template: ` <message></message> ` }); export class AppComponent {} app.component.ts
  • 192. Service Message Show Me The page at http://localhost/3000 says: Service Message
  • 194. an open source framework for building truly native mobile apps with JavaScript. Use web skills, like Angular and CSS, and get native UI and performance on iOS and Android. NativeScript is…
  • 196.
  • 198.
  • 199.
  • 201. {demo}
  • 202. Common App Patterns • Services • An object that is responsible for getting and setting data • Models • Super dumb objects that define the structure of the data • ViewModels • AKA Controllers. Controls the state of the UI and performs when changes are made to model objects.
  • 204. Data binding with Angular • {{ }} – still works! • You can still use {N}'s standard binding… • But you can do it even better. • [] – Property binding • One way. • Like array notation in JavaScript. One way • () – Event Binding • When you want to bind to an event. • Two Way – [(ngModel)] • Almost always used with ngModel
  • 205. Extra Angular Goodies • Dependency Injection • Routing • Components • Pipes • Services • FAST
  • 206. Using Telerik Platform Cloud-based tooling for NativeScript
  • 207.
  • 208. Why? • Cloud based, zero setup • Build for iOS from Windows • Deploy to device without provisioning profiles • Manage app properties faster
  • 212. {demo}
  • 214. Animation basics Animate: • opacity • backgroundColor • translateX and translateY • scaleX and scaleY • rotate Configure: • target (UI element) • duration (in ms) • delay • iterations • curve
  • 215. Simple animation var view = page.getViewById("myLabel"); view.animate({ translate: { x: 0, y: 100}, duration: 1000, curve: enums.AnimationCurve.easeIn }); • Animations can be chained together • Multiple properties and elements can be animated • Return a promise that can be canceled
  • 216. {demo}