Nativescript-Vue
Native Mobile Apps without the Hard Parts™
Slide 2
Slide 2 text
Arnav Gupta
Co Founder, Coding Blocks
● Author of vuex-persist – 2nd most popular
Vuex plugin
● Coding Blocks has built
ide.codingblocks.com – an online IDE in
Vue
● Currently developing HasGeek’s new
mobile app in Nativescript-Vue!!!
Slide 3
Slide 3 text
What is Nativescript-Vue ? ? ?
Slide 4
Slide 4 text
A quick tour of Nativescript
Slide 5
Slide 5 text
A quick tour of Nativescript
“
An open source framework for building
truly native mobile apps with JavaScript.
Use web skills, like TypeScript, Angular and
CSS, and get native UI and performance on iOS
and Android
”
Slide 6
Slide 6 text
. . . unlike
● Cordova – not a webview
● PhoneGap – not a webview
● Ionic – not a just web framework
● React Native – WORA, not LOWA (100% code sharing)
● Xamarin – no cross-compile or bindings
● Flutter – uses OEM widgets, not render graphics itself
Slide 7
Slide 7 text
Layout System
● AbsoluteLayout
x,y co-ordinate based positioning
Slide 8
Slide 8 text
Layout System
● DockLayout
arranges children on outer edges
Slide 9
Slide 9 text
Layout System
● GridLayout
Slide 10
Slide 10 text
Layout System
● Stack Layout
Slide 11
Slide 11 text
Layout System
● WrapLayout
Slide 12
Slide 12 text
Extendable
● Android Libraries – via Gradle
● iOS Libraries – via CocoaPods
● JS Libraries – via NPM
Slide 13
Slide 13 text
Runtime Engine
JavaScriptCore V8
Slide 14
Slide 14 text
Full Native API access.
Call Swift/Kotlin/Java/ObjC code directly from JS
Slide 15
Slide 15 text
// custom-plugins/device.ios.js
module.exports = {
version: UIDevice.currentDevice().systemVersion
}
// custom-plugins/device.android.js
module.exports = {
version: Build.VERSION.RELEASE
}
// app.js
import device from ‘./custom-plugins/device’;
console.log(device.version);
Device Specific Code in JS
Slide 16
Slide 16 text
Multiple ways to use
Slide 17
Slide 17 text
Vanilla
● Templates = XML
● Logic – JS or TS
Slide 18
Slide 18 text
Angular
● Templates = XML-like, in template literals : ``
● Logic – Typescript (just like any Angular 4 app)
Slide 19
Slide 19 text
Vue (tns)
● Templates = XML-like, in template literals : ``
● Logic – JS (or TS)
● Only .js/.ts files, no .vue files
● Global Stylesheet
Slide 20
Slide 20 text
Vue (vue-cli)
● Single File Components `, , <style>`
● Templates in HTML/Pug/Jade/EJS
● Code in JS/TS/Coffee
● Scoped + Global styles
Slide 21
Slide 21 text
What’s the difference ?
vue-cli-template
● Nativescript in Vue
● Tooling = vue-cli
● Your own webpack.config
● .vue files, just the way you like
● Vue-loader awesomeness (use any
styling/scripting/template language)
● Double build step. Hot warm reload
nativescript-vue-template
● Vue in Nativescript
● Tooling = tns cli
● Nativescript build + bundle JS/TS itself
● .js files, add tempalate = `` in export
● Only Sass/JS/TS/HTML support
● Single build step. Blazing fast hot reload
Slide 22
Slide 22 text
Getting Started
vue-cli-template
$ npm install -g @vue/cli @vue/cli-init
$ vue init nativescript-vue/vue-cli-template
$ cd
$ npm install
$ npm run watch:ios
$ npm run watch:android
nativescript-vue-template
$ npm install -g nativescript
$ tns create --template nativescript-vue-template
$ cd
$ tns run android
$ tns run ios
Gotchas
● Don’t stroll into Nativescript with your DOM mentality
● DOM DOM buggy buggy DOM DOM
● We use Axios http
● DON’T move fast and break things. (3 layer dependencies)
● We actually have threads !!!
● Read NS/Angular docs and translate into Vue (shit!)
Slide 26
Slide 26 text
Taking Care of The Ugly Things ™
●
Install Xcode (just CLI is ok)
●
Install Cocoa Pods
●
Enable iOS Simulator
● Install Android SDK
● Install Android Emulator
(Genymotion recommended)
● Keep Java 8, Gradle updated