Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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!

Arrow left icon
Profile Icon Anderson
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2 (9 Ratings)
Paperback Jan 2016 168 pages 1st Edition
eBook
NZ$26.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
Arrow left icon
Profile Icon Anderson
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2 (9 Ratings)
Paperback Jan 2016 168 pages 1st Edition
eBook
NZ$26.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
eBook
NZ$26.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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

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 a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

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
$19.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
$199.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 NZ$7 each
Feature tick icon Exclusive print discounts
$279.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 NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 120.98
Getting Started with NativeScript
NZ$48.99
NativeScript for Angular Mobile Development
NZ$71.99
Total NZ$ 120.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 included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.