Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Getting Started with NativeScript
Getting Started with NativeScript

Getting Started with NativeScript: Explore the possibility of building truly native, cross-platform mobile applications using your JavaScript skill—NativeScript!

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Getting Started with NativeScript

Chapter 2. The Project Structure

In this chapter, I am going to show you how to navigate your new project and its full structure. I will explain each of the files that are automatically created and where you create your own files. Then, we will proceed to gain a deeper understanding of some of the base components of your application, and finally, learn how to change screens.

In this chapter, we will be covering the following topics:

  • Project directory overview
  • App directory overview
  • NativeScript common core files
  • Your application files
  • An application page
  • Foundational components
  • Creating a second page
  • Navigating between screens

Project directory overview

By running the nativescript create crossCommunicator command in the previous chapter, it created a nice structure of files and folders for us to explore.

Note

If the NativeScript team has replaced the default project template since this book was written, the actual source code as it existed at the time of publishing is located in the book's source code repository found at https://github.com/GettingStartedWithNativeScript/Chapter_1. The Example_1 folder contains the entire default template when this book was written. And you can clone it to your hard drive by running the git clone https://github.com/GettingStartedWithNativeScript/Chapter_1 command and then proceeding to follow along inside the Example_1 folder.

First, we will do a high-level overview of the different folders and their purposes and touch on any important files in those folders. Then, we will finish the overview by going into depth with the App directory, which is where you will spend pretty much...

The app folder

Wow! As you can see, a lot of stuff goes on just to create an application. Now, we are going to finally discuss the App folder structure; this folder is where we will spend the majority of our development time. We shall explore what the different types of files are for and how they are used to create an application. Since this is the primary development folder and contains your entire code base for your application, I would highly recommend you put this folder under source control and/or maintain backups of this folder. The App folder already contains a couple folders and a few files that are mentioned under the App folder files subsection. Let's look at both of these folders first and the files contained in them, and finally, we will look at each of the individual files in the App folder.

The .gradle folder

This folder is for the gradle build system; it basically only contains cache and data items that are used while the application is being built. This folder might be...

Foundational components

Now that we have explored all the project files that were automatically created for you, let's examine several foundational components that have already been referenced in the main page. These components are the glue of the application, and without them, we would have no application.

Application component

If you recall, earlier in the chapter, we discussed the app.js file. It basically contains only the code that is responsible for setting up the properties of your application and then finally, it starts the application component. So, you probably have guessed that this is the primary component for your entire application lifecycle. Part of the features that this component provides us with is access to all the application-wide events. Frequently, in an app, you will want to know when your app is no longer the foreground application or when it finally returns to being the foreground application. To get this information, you can attach to two of the events that...

Creating a second page

Now that we have an idea of all the project files and foundational components, why don't we do something cool and finish off this chapter by creating a brand new page and then using our newfound skills to navigate to it?

Creating additional files and pages

Some people might prefer individual subdirectories per page or some other project layout scheme. NativeScript has no issues with you creating your project system the way you want. For our project, and to keep things simple, we are just going to add any new files to our main app directory. To create a new page, we just need to create the files associated with a page. So, in this case, we need to create a single new file called settings.js in our main App folder. And then, finally, we need to make a change to the main-view-model.js file to show our new page.

Creating settings.js

In our application, we are going to need a settings page, so we are going to create the framework for our application settings page right...

Summary

We have covered a large amount of foundational information in this chapter. Not only did we go through all the project files that were created by the tns create crossCommunicator command, but we also covered which files are used for your application and where to find and make any changes to the project control files. In addition, we also covered several foundational components such as the Application, Frame, and Page components. And we walked through the three different files that make up an application page. Finally, we created a new page and navigated to it and back from it.

In the next chapter, we are going to cover several more components and explore the XML Declarative UI and flesh out binding and observables, working with events, and styling your application with CSS.

Left arrow icon Right arrow icon

Key benefits

  • Save your marketing time by building for iOS, Android, and Windows Mobile platforms simultaneously
  • Be an ace at utilizing the features of NativeScript and its ability to communicate with each of the host device libraries natively
  • Proficiently, build your fully cross-platform communication application exhibiting the fundamentals of NativeScript

Description

NativeScript allows you to build a fast cross-platform application that has a native UI. NativeScript is a true cross-platform framework that generates native speed applications using the native components of the host platform, all using JavaScript. Although NativeScript allows you to build your application in JavaScript, you have full access to the host OS from your code, allowing you to easily tweak or use new platform features instantly at native code speeds. Whether you have already developed multiple applications or zero applications, this book will help you to develop your next application in a cross-platform framework quickly, saving you a massive amount of time and money. This book concisely shows you NativeScript’s built-in framework that allows you to rapidly develop a fully-working compiled cross-platform application in just a few chapters. It starts by laying the foundation of NativeScript and working through the fundamentals to create a basic shell of the application. Moving on, you’ll see how to build a full-fledged application step by step. We’ll show you how to use plugins, and how to communicate with the native OS libraries easily so that you can customize your application as if your app was created in Java or Objective C. We then deal with the issues that arise from being cross platform and compensate for the different screen sizes, screen resolutions, and device abilities. Finally, we progress to testing and deploying your app.

Who is this book for?

If you are a JavaScript developer and want to build cross-platform applications, then this book is just the right one for you!

What you will learn

  • Install and compile your application in NativeScript
  • Get important know-how on the NativeScript project structure
  • Develop and style your screens for multiple platforms
  • Create a full-featured cross-platform communication application
  • Import and use several third-party components
  • Simplify and deal with device resolution and cross-platform issues
  • Test and deploy your application
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 28, 2016
Length: 168 pages
Edition : 1st
Language : English
ISBN-13 : 9781785888656
Vendor :
Progress
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Jan 28, 2016
Length: 168 pages
Edition : 1st
Language : English
ISBN-13 : 9781785888656
Vendor :
Progress
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 61.98
Getting Started with NativeScript
€24.99
NativeScript for Angular Mobile Development
€36.99
Total 61.98 Stars icon

Table of Contents

8 Chapters
1. Introduction to NativeScript Chevron down icon Chevron up icon
2. The Project Structure Chevron down icon Chevron up icon
3. Declarative UI, Styling, and Events Chevron down icon Chevron up icon
4. Building a Featured Application Chevron down icon Chevron up icon
5. Installing Third-Party Components Chevron down icon Chevron up icon
6. Platform Differences Chevron down icon Chevron up icon
7. Testing and Deploying Your App Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2
(9 Ratings)
5 star 33.3%
4 star 22.2%
3 star 11.1%
2 star 0%
1 star 33.3%
Filter icon Filter
Top Reviews

Filter reviews by




Alex Jun 17, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The author, being one of the leading community developers with NativeScript, clearly and logically take the reader on a real learning journey. What I love about this book is that it not only covers the essentials, but also goes deeper with some tried and tested real world knowledge, including tips and tricks, as well as different caveats that could potentially catch a freshman NativeScriptie off-guard. Looking forward to the next one!
Amazon Verified review Amazon
stevescotthome Jun 01, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great primer!l
Amazon Verified review Amazon
Ehrlichwährtamlängsten Mar 24, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Ich finde das Buch klasse. Es ist kompakt geschrieben, hat einen roten Faden und führt vollständig in NativeScript ein. Zudem schafft es der Autor immer wieder, zur rechten Zeit einen erfrischenden und gelungenen Joke einzuwerfen und den Leser bei Laune zu halten; eigentlich mag ich so was gar nicht, aber hier ist der Schreibstil definitiv gelungen und überaus informativ. Auch die Code-Beispiele sind exzellent; sie sind aufs wesentliche beschränkt und ohne Probleme nachfollziehbar.Sollte eine Neuauflage zur bevorstehenden Version 3 erscheinen, würde ich mir dies ebenfalls noch einmal und schnellstmöglichst bestellen. Ansonsten fühle ich mich mit diesem Buch bestens gerüstet und danke dem Autor für dieses liebevolle Werk.Ich wüsste nicht, warum ich stattdessen 400 oder 500 Seiten mit gleichem, dafür in die Länge gezogenen Inhalt lesen sollte. Sollte der Autor es jedoch schaffen, in einer Folgeauflage 400 oder 500 Seiten bei gleicher Qualität zu schreiben und diese eventuell sogar in ein farbig gedrucktes Buch zu stecken, dann würde ich auch ohne zögern den doppelten Preis zahlen (28 Euro aktuell / 50 dann o.ä.) ;-)Die 5 Sterne vergebe ich trotzdem schon, weil es sich eben um knapp 170 absolut informative und gut geschriebene Seiten zu einem noch akzeptablen Preis handelt und weil mir der Einstieg hiermit mehr als gut gelungen ist :-)
Amazon Verified review Amazon
Ahmed B. Feb 17, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good book for a getting started book, but I was looking for a real-life examples such as Instagram/snap/YouTube.
Amazon Verified review Amazon
Joshie wah wah Sep 11, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I built a cross communicator and chatted between my mobile device and browser which is pretty cool! Certainly feel more comfortable building mobile chat apps. It is outdated now so took some work as some of the library's have changed etc. I love the way this guy has a laugh whilst teaching this stuff, after all web sockets and all that jazz can get a little tiresome.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela