Getting started with Tabris.js Tutorial Ebook

Similar documents
Ionic Tutorial. For Cross Platform Mobile Software Development

International Research Journal of Engineering and Technology (IRJET) e-issn: Volume: 05 Issue: 05 May p-issn:

IBM Image-Analysis Node.js

Ionic CLI is the default and easiest way to work with ionic projects. In this tutorial we will learn the ins and outs of Ionic CLI.

By Stephen Cavell, Kerry Ellwanger, and Jack Livingston

There are two main workflows for working with Cordova projects, Web focused and Platform focused.

5th April Installation Manual. Department of Computing and Networking Software Development Degree

CSS JavaScript General Implementation Preloading Preloading in the Design Thinking Process Preloading in the Summary View Android UI Design Design

Hands-on Lab Session 9011 Working with Node.js Apps in IBM Bluemix. Pam Geiger, Bluemix Enablement

Chapter 1 - Development Setup of Angular

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

Choose OS and click on it

Mobile Development June 2015, TEIATH, Greece

WebSphere Puts Business In Motion. Put People In Motion With Mobile Apps

I, J, K. Eclipse, 156

Mobile Web Appplications Development with HTML5

MicroStrategy Academic Program

Adobe Marketing Cloud Bloodhound for Mac 3.0

Kivy Designer Documentation

2015 NALIT Professional Development Seminar September 30, Tools for Mobile App Development

Mobile Applications 2013/2014

Installation Guide - Windows

Software Architecture Documentation for the JRC MYGEOSS app for Invasive Species project

Quick Desktop Application Development Using Electron

Tools. SWE 432, Fall Design and Implementation of Software for the Web

Lab 3: Using Worklight Server and Environment Optimization Lab Exercise

Lab Android Development Environment

Live Guide Co-browsing

Aware IM Version 8.2 Aware IM for Mobile Devices

HTML5 Applications Made Easy on Tizen IVI. Brian Jones / Jimmy Huang

Mobile Application Development

Full Stack boot camp

Getting started with Convertigo Mobilizer

JavaScript Fundamentals_

Lab 1 - Introduction to Angular

Copyright

Salesforce Classic Guide for iphone

Hello World. Lesson 1. Create your first Android. Android Developer Fundamentals. Android Developer Fundamentals

8.0 Help for End Users About Jive for SharePoint System Requirements Using Jive for SharePoint... 6

Getting Started With NodeJS Feature Flags

Advance Mobile& Web Application development using Angular and Native Script

The Basics of Visual Studio Code

MFA (Multi-Factor Authentication) Enrollment Guide

IGME-330. Rich Media Web Application Development I Week 1

HPE ilo mobile app for ios

RapidIdentity Mobile Guide

Installation Guide - Mac

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

SAS Visual Analytics 7.3 for SAS Cloud: Onboarding Guide

How to Convert a Simple Web Site into a Mobile App. Using PhoneGap Build, PhoneGap Desktop, PhoneGap CLI. Use Android Studio

Ten interesting features of Google s Angular Project

Building Native Mapping Apps with PhoneGap: Advanced Techniques Andy

Copyright

Salesforce Classic Mobile Guide for iphone

Lab 1: Getting Started with IBM Worklight Lab Exercise

Hello! ios Development

!!! !!!!!!!!!!! Help Documentation. Copyright V1.7. Copyright 2014, FormConnections, Inc. All rights reserved.

Firefox for Android. Reviewer s Guide. Contact us:

Embedding Medial Media Library Videos in Blackboard or a Web Page. Version 5

Salesforce Classic Mobile User Guide for Android

Develop using the BlackBerry WebWorks SDK for BlackBerry Tablets (1 of 4)

This document explains how to obtain a direct link from within an existing Facebook page to the hotel s booking

Oracle Utilities Customer Self Service

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

(Refer Slide Time: 1:12)

Upon completion of the second part of the lab the students will have:

2015 Beta 2 Tutorials

Human-Computer Interaction Design

WebKit ; FOR : DUMMIES. by Chris Minnick WILEY. John Wiley & Sons, Inc.

Setting up to download Grants Group Application Forms

How to Access Your Digital Member Magazine

Dreamweaver Basics Workshop

Journey Group Leaders Seraphim Training

Sample Spark Web-App. Overview. Prerequisites

WolkAbout IoT Tool Mobile Application v2.2. User Manual

Android App Development

Having Fun with Social Coding. Sean Handley. February 25, 2010

Exercise 1. Bluemix and the Cloud Foundry command-line interface (CLI)

TalkToMe: A beginner App Inventor app

Salesforce Classic User Guide for Android

WebEx. Web Conferencing Tool. Fordham IT

Version Android User's Guide. May-02-13

Copyright

Android Programming Family Fun Day using AppInventor

Client Side JavaScript and AJAX

The paper shows how to realize write-once-run-anywhere for such apps, and what are important lessons learned from our experience.

We are assuming you have node installed!

Native Mobile Apps in JavaScript

Index. Alessandro Del Sole 2017 A. Del Sole, Beginning Visual Studio for Mac,

TangeloHub Documentation

MANAGING ANDROID DEVICES: VMWARE WORKSPACE ONE OPERATIONAL TUTORIAL VMware Workspace ONE

Highland Libraries ebook Download Service. User Guide

FROM VSTS TO AZURE DEVOPS

POWER BI BOOTCAMP. COURSE INCLUDES: 4-days of instructor led discussion, Hands-on Office labs and ebook.

Assistant Professor Computer Science. Introduction to Human-Computer Interaction

WebEx. Web Conferencing Tool. Fordham IT

For detailed technical instructions refer to the documentation provided inside the SDK and updated samples.

Oracle Utilities Customer Self Service

Nexonia Expense Reporting: Mobile. A Quickstart Guide to using Nexonia on the Mobile App

Index. Elad Elrom 2016 E. Elrom, Pro MEAN Stack Development, DOI /

Transcription:

Getting started with Tabris.js 2.3.0 Tutorial Ebook

Table of contents Introduction...3 1 Get started...4 2 Tabris.js in action...5 2.1 Try the examples...5 2.2 Play with the examples...7 2.3 Write your first own code...10 3 Create your first app...15 3.1 Set up your project by using a template...16 3.2 Run your app...20 3.3 Develop-deploy-test cycle...21 3.4 Extend your app with libraries and plug-ins...25 4 Build your app...27 4.1 Build service...28 5 Conclusion...32

Introduction Tabris.js is a framework for developing mobile apps in JavaScript. With Tabris.js you can develop native ios, Android and Windows apps with a single code base. The code is written entirely in JavaScript. So you don t have to manage code for different platforms individually. Tabris.js gives you native performance and native look & feel. And you can leverage your existing JavaScript know-how. In this ebook, you learn how to get started with Tabris.js, how to create your first app, and how to build your app.

1 Get started 1 Get started Get started with Tabris.js To get started with Tabris.js you only need a mobile device and the Tabris.js 2 Developer App! You can write your code right away by using the playground on tabrisjs.com. Set up your mobile device To set up your mobile device, follow these steps: 1. Download the Tabris.js 2 Developer App from the Google Play Store, the Microsoft Store or the Apple App Store. They are available for free. Follow the links below or search for Tabris.js 2 in the store on your mobile device. 2. Start the app. 4

2 Tabris.js in action 2 Tabris.js in action 2.1 Try the examples Explore widgets and layouts To see the power and flexibility of the framework, try the Tabris.js examples: In the Developer App switch to the Examples tab. The Examples tab 5

2 Tabris.js in action The Tabris.js examples The examples are a collection of small apps. They are part of the open source Tabris.js GitHub repository and they are written in JavaScript. You can see the source code when you tap the JS icon on the right side of the screen. Run the examples Tap an example to run it. 6

2 Tabris.js in action 2.2 Play with the examples Navigate between the examples You can navigate between the examples by using the developer console in your Developer App. After you have started an example, you can go back to the examples overview: use the back button on Android use the home symbol in the developer console on both platforms. Go back to the examples overview 7

2 Tabris.js in action Open the developer console To open the developer console, slide from the right edge of the screen to the left. Tip for ios tablet devices If you have problems opening the developer console: double-tap with four fingers on the screen. 8

2 Tabris.js in action Functions of the developer console You can use the interactive developer console to: go back to the home screen of the Developer App, or reload your code view log messages and errors that occur when you run your code. You can filter the log and share it, for example by email interact with the running app by executing JavaScript code from the developer console like in browsers. Here is something to try: tabris.device.platform Run JavaScript code from the console 9

2 Tabris.js in action 2.3 Write your first own code Ways to execute code on a mobile device The Tabris.js 2 Developer App can execute JavaScript code directly on your mobile device. The code can be loaded from within the App (for example the Tabris.js examples), or from a remote location (for example your development machine). To make it really easy to write your first own code, you can use the online playground on tabrisjs.com. The "Hello, World!" example To try your code directly on your mobile device: On tabrisjs.com go to the Playground tab. Here you find a simple Tabris.js script. It is the Hello, World! example. 10

2 Tabris.js in action The Tabris.js playground Run the "Hello, World!" example You can run this script immediately in the Tabris.js 2 Developer App on your mobile device: Scan the code from the playground. You can find a QR code reader in the URL tab of the Developer App. P Now the example runs on your mobile device. 11

2 Tabris.js in action View the "Hello, World!" example Edit the "Hello, World!" example The Hello, World! example is fully functional and directly loaded from the playground. You can edit the code in the playground, and reload to see the changes in action: Use the developer console for reloading. You can also reload by scanning the barcode again. Try to change a few things: the title of the page, the button, and the text. 12

2 Tabris.js in action View your changes P Now you can see in your Developer App what you changed in the playground. Your changes in the playground and on the mobile device 13

2 Tabris.js in action Tabris.js snippets In the Tabris.js GitHub repository, you can find code snippets for nearly every feature in Tabris.js. Copy the JavaScript from one of the snippets, and paste it in the playground. P Now you can run it from there. 14

3 Create your first app 3 Create your first app Before you start developing Before you start developing your first app, you need to set up your development machine and your project. You will also learn how to run your app, and how Tabris.js apps can be structured. Set up your development machine To set up your development machine, install the following software: Node.js For more information see nodejs.org the Tabris CLI In your Terminal type: npm install -g tabris-cli A Terminal is a command-line interpreter such as Terminal (Mac), Gnome Terminal (Linux) or Command Prompt (Windows). a text editor or a JavaScript IDE. Your mobile device must be connected to the same Wi-Fi network as your development machine. 15

3.1 Set up your project by using a template The easiest way to create your project is using Tabris CLI. 3 Create your first app Functions of Tabris CLI Tabris CLI can: create the basic files that you need to develop your first local app serve your project files to the Developer App build an app on your local machine. Initialize your project To initialize your project: Type cd to an empty project directory. Type tabris init. Enter app information You need to enter some information, like: project name project version project type: JavaScript App or TypeScript App. This ebook describes a JavaScript App; therefore you should choose "JavaScript App" in project type. 16

3 Create your first app The basic files The Tabris CLI creates a basic example app. The most important files are: a package.json and a src/app.js. The package.json package.json { } "main": "src/app.js", "dependencies": { "tabris": "^2.3.0" } The package.json is a manifest file that describes your application and its dependencies. For more information on how to use a package.json, see: https://docs.npmjs.com/getting-started/using-a-package.json 17

3 Create your first app The src/app.js The src/app.js file contains the code of your application. src/app.js const {Button, TextView, ui} = require('tabris'); let button = new Button({ centerx: 0, top: 100, text: 'Show message' }).appendto(ui.contentview); let textview = new TextView({ centerx: 0, top: [button, 50], font: '24px' }).appendto(ui.contentview); button.on('select', () => { textview.text = 'Tabris.js rocks!'; }); 18

3 Create your first app The config.xml Tabris CLI also creates a config.xml file for you. Every Tabris.js project that you want to build needs a config.xml file. This file describes your app. A minimal config.xml A minimal config.xml looks similar to this: <?xml version='1.0' encoding='utf-8'?> <widget id="my.first.app" version="1.0.0"> <name>helloworld</name> <description> A sample Tabris.js application. </description> <author email="dev@example.com" href="https://example.com"> Tabris.js Team </author> </widget> 19

3 Create your first app 3.2 Run your app Run your app With this basic structure in place, you can now run your app for the first time: 1. In the project directory type tabris serve, this will start an HTTP server. The server outputs the IP address of your machine on start up. Let the server run as long as you develop/test your app. To stop the server, hit CTRL-C. 2. In the Developer App, type in the URL tab http://<development-machine-ip-address>:8080/. 3. Tap Connect to run your app. P The Developer App now downloads the script and executes it on your mobile device. Open the developer console Swipe from the right edge of the screen to the left, to open the developer console. You can reload the script or go back to the home screen of the Developer App. P Now you can continue developing. 20

3 Create your first app 3.3 Develop-deploy-test cycle Develop, deploy, test The develop-deploy-test cycle is very fast with Tabris.js apps: 1. Just edit the JavaScript files that make up your code base in a text editor, and save them. 2. On your mobile device open the developer console, and tap the reload button. If you need to debug your app, you need an Android device (or an emulator) and a Chrome browser. A detailed description of debugging Tabris.js can be found online. Debugging for ios is possible using the Safari Web Inspector. It works in the same way as debugging of websites with Safari on ios. Add more pages Let's continue developing your app by adding a navigation view and some pages. Apps with multiple pages should be split into several files. Use src/app.js as an entry point, and create a seperate file for each page. See the example below. 21

3 Create your first app Sample app structure As an example, let s create a News page. This is how you can create page modules and use them: src/app.js const {Button, NavigationView, Page, ui} = require('tabris'); const NewsPage = require('./pages/newspage'); // Create a full-size navigation view to contain //pages let navigationview = new NavigationView({ left: 0, top: 0, right: 0, bottom: 0 }).appendto(ui.contentview); // Create a main page and add it to the navigation //view let mainpage = new Page({ title: 'Main Page' }).appendto(navigationview); new Button({ centerx: 0, top: 100, text: 'Open another page' }).on('select', () => { new NewsPage().appendTo(navigationView); }).appendto(mainpage); 22

3 Create your first app Sample app structure src/pages/newspage.js const {Page, TextView} = require('tabris'); module.exports = class NewsPage extends Page { constructor() { super({title: 'News'}); new TextView({ centerx: 0, centery: 0, text: 'No news yet!' }).appendto(this); } }; 23

3 Create your first app Switch between the pages Directory structure Tabris.js does not force a directory structure upon your JavaScript sources. You can use the project layout as described above or any structure you like. Just make sure that you reference modules with a relative path (for example./newspage if NewsPage.js is in the same directory as src/app.js). 24

3 Create your first app 3.4 Extend your app with libraries and plug-ins Extend Tabris.js You can extend Tabris.js with existing JavaScript libraries and native extensions. For an example of how to add an existing library from npm, see the Chart.js and Timezones examples on GitHub. The Tabris.js framework supports many W3C APIs out of the box, such as web APIs, Canvas for drawing, and localstorage. Libraries that depend on these APIs will work as long as they don t use the DOM. Use Cordova plug-ins Other features, including native device features like sensors or camera, can be added with Apache Cordova plug-ins. To add Apache Cordova plug-ins to your app, you need to add them to the config.xml. 25

3 Create your first app Add plug-ins The online build service supports the Cordova <plugin /> tag. With this tag, you can add plug-ins by using their ID, an HTTP URL or a git URL. A config.xml with plug-ins A sample config.xml with a Cordova plug-in could look like this: <?xml version='1.0' encoding='utf-8'?> <widget id="my.first.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">... <plugin name="cordova-plugin-camera" spec="2.3.1" /> </widget> 26

4 Build your app 4 Build your app Bundle, brand and build your app Build without local setup Local build To publish your app in the Apple App Store, the Microsoft Store or the Google Play Store, you need to bundle, brand and build the app. Tabris.js uses Apache Cordova to build and package apps. To build an app without any local setup or hardware, you can use the online build service on tabrisjs.com. You need to store the source code of your app in a GitHub repository to make it available for the build service. For the local build, you can use local tools on your development machine. This ebook describes how to build your app with the online build service. The online build service is free for unlimited public GitHub repositories and one private repository. To build from unlimited private repositories, you need a Pro account. The local build is free for everyone. 27

4 Build your app 4.1 Build service Provide access to the source code The build service needs access to the source code of your app to package it into a native app. The easiest way is to push your code to a GitHub repository. The build service installs the dependencies specified in your package.json from npm on the fly. As a result, you don't have to put the node_modules folder under version control. become mobile 28

4 Build your app Use the build service To use the build service: 1. Go to tabrisjs.com and sign in with your GitHub account. 2. Go to the My Apps section. 3. Click Create App. 4. In the list of repositories, select the GitHub repository that contains a Tabris.js app. If it is not visible, then you may need to click the synchronize button. 29

4 Build your app Execute the first build To create a debug Android app, that means an app containing the developer console, follow these steps: 1. Select the newly created app. 2. Click the Build Android App button. Install the.apk file A few minutes later you can download an Android.apk file, and install this file on your mobile device. 30

4 Build your app Advanced build configuration To configure debug builds or release builds on ios, you need a signing key. The same is true for release builds on Android. Signing keys are important to secure your app. Because creating signing keys is rather a complex process, it is out of the scope of this ebook. You can find detailed guides for signing keys online. 31

5 Conclusion 5 Conclusion Tabris.js blog By the end of this ebook, you successfully created your first Tabris.js 2 app! If you like to learn more about the Tabris.js platform, its features and possibilities, then have a look at our blog posts on: http://eclipsesource.com/blogs/tag/tabris-js/ Feedback Help us improve Tabris.js! Feedback is always welcome. Feel free to invite your friends if you find Tabris.js interesting. Copyright 2017 by EclipseSource 32