You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.html
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1568,7 +1568,7 @@ <h4 class="exercise-start">
1568
1568
<imgsrc="images/chapter4/ios/8.gif" alt="Loading animation on iOS"></p>
1569
1569
<p>Now that you have functional login and list pages, let’s enhance the app’s functionality as a grocery list management tool. In the next chapters you'll add functionality such as email validation, social sharing, and more. And you’ll use one of NativeScript's most useful features to do so: npm modules.</p>
1570
1570
<blockquote>
1571
-
<p><strong>TIP</strong>: There are several modules that come out of the box with your NativeScript installation that we did not have time to cover in this guide—including a <ahref="https://docs.nativescript.org/ApiReference/location/HOW-TO">location service</a>, a <ahref="https://docs.nativescript.org/ApiReference/file-system/HOW-TO">file-system helper</a>, a <ahref="https://docs.nativescript.org/ApiReference/timer/HOW-TO">timer module</a>, a <ahref="https://docs.nativescript.org/ApiReference/camera/HOW-TO">camera module</a>, and a whole lot more. Make sure to peruse the “Modules API” of the docs, or just look around <code>node_modules/tns-core-modules</code> to see all of what’s available.</p>
1571
+
<p><strong>TIP</strong>: There are several modules that come out of the box with your NativeScript installation that we did not have time to cover in this guide—including a <ahref="https://docs.nativescript.org/ApiReference/location/HOW-TO">location service</a>, a <ahref="https://docs.nativescript.org/ApiReference/file-system/HOW-TO">file-system helper</a>, a <ahref="https://docs.nativescript.org/ApiReference/timer/HOW-TO">timer module</a>, a <ahref="https://docs.nativescript.org/ApiReference/camera/HOW-TO">camera module</a>, and a whole lot more. Make sure to peruse the “Modules API” of the NativeScript documentation, or just look around your <code>node_modules/tns-core-modules</code> folder to see all of what’s available.</p>
1572
1572
</blockquote>
1573
1573
1574
1574
</div>
@@ -1637,7 +1637,7 @@ <h4 class="exercise-start">
1637
1637
<b>Exercise</b>: Rebuild your app
1638
1638
</h4>
1639
1639
1640
-
<p>As we mentioned in chapter 1.4, although the <code>tns livesync</code> command is smart enough to reload your app for most changes you make to your app, the command cannot hot reload your app for all changes—most notably, changes to native files in <code>app/App_Resources</code>, new modules installed with <code>npm install</code>, and new NativeScript plugins.</p>
1640
+
<p>As we mentioned in chapter 1.4, although the <code>tns livesync</code> command is smart enough to reload your app for most changes you make to your app, certain changes require a full build—most notably, changes to native files in <code>app/App_Resources</code>, new modules installed with <code>npm install</code>, and new NativeScript plugins.</p>
1641
1641
<p>For NativeScript to recognize this new email-validator npm module, type <code>Ctrl+C</code> in your terminal to kill the existing <code>tns livesync</code> watcher if it’s still running, and then use <code>tns run</code> to rebuild your application and deploy it to an emulator or device.</p>
<imgsrc="images/chapter5/ios/2.gif" alt="Social sharing on iOS"></p>
1712
1712
<p>Pretty cool, huh? The ability to use npm modules greatly expands the number of things you're able to do in a NativeScript app. Need to compose emails in your app? Try out the <ahref="https://www.npmjs.com/package/nativescript-email">NativeScript email plugin</a>. Need to use the clipboard in your app? Try out the <ahref="https://www.npmjs.com/package/nativescript-clipboard">NativeScript clipboard plugin</a>.</p>
1713
1713
<p>If you're looking for NativeScript plugins start by searching both the <ahref="http://plugins.telerik.com/nativescript">Telerik NativeScript Plugins Marketplace</a> and our <ahref="http://plugins.nativescript.rocks">community-curated list of plugins on npm</a>. If you don't find the plugin you need, you can <ahref="https://nativescript.ideas.aha.io/">request the plugin on our ideas portal</a>, or you can take a stab at <ahref="https://docs.nativescript.org/plugins">creating the plugin yourself</a>.</p>
1714
-
<p>Between NativeScript modules, npm modules, and NativeScript plugins, the NativeScript framework provides a lot of functionality you can use to build your next app. However, we've yet to talk about NativeScript's most powerful feature: the ability to directly access iOS and Android APIs in JavaScript. Let's look at how it works.</p>
1714
+
<p>Between NativeScript modules, npm modules, and NativeScript plugins, the NativeScript framework provides a lot of functionality you can use to build your next app. However, we've yet to talk about NativeScript's most powerful feature: the ability to directly access iOS and Android APIs in TypeScript. Let's look at how it works.</p>
<p>The beauty of NativeScript is that you can write a native iOS or Android app in JavaScript, XML, and CSS without touching Swift, Objective-C, or Java, if you choose. But what if you want to present a different, more platform-specific UI to your users? Or if you want to access an iOS or Android API that NativeScript doesn't expose through a NativeScript module or plugin?</p>
1720
-
<p>NativeScript gives you the option to dig into native code as needed, and to do so without leaving JavaScript. To show how this works in action, let's tweak a few of the UI elements in your app using native code.</p>
1719
+
<p>The beauty of NativeScript is that you can write a native iOS or Android app in TypeScript, XML, and CSS without touching Swift, Objective-C, or Java, if you choose. But what if you want to present a different, more platform-specific UI to your users? Or if you want to access an iOS or Android API that NativeScript doesn't expose through a NativeScript module or plugin?</p>
1720
+
<p>NativeScript gives you the option to dig into native code as needed, and to do so without leaving TypeScript. To show how this works in action, let's tweak a few of the UI elements in your app using native code.</p>
<p>You may recall from earlier chapters that the hint color on your sign up screen could use a little more contrast. Notice the unappealing black on brown color of the text in the images below (if you can see the text at all).</p>
1723
1723
<p><imgsrc="images/chapter6/android/1.png" alt="Bad contrast on Android">
@@ -1745,7 +1745,7 @@ <h4 class="exercise-start">
1745
1745
args.view.hint, dictionary);
1746
1746
}
1747
1747
</code></pre>
1748
-
<p>This creates a function called <code>setHintColor()</code> that accepts a <code><TextField></code> and <code>Color</code>. We’ll talk about the contents of this function momentarily; first let’s look at how to use it.</p>
1748
+
<p>This code creates a function called <code>setHintColor()</code> that accepts a <code><TextField></code> and <code>Color</code>. We’ll talk about the contents of this function momentarily; first let’s look at how to use it.</p>
1749
1749
<p>Open up <code>app/pages/login/login.component.ts</code> and add the following two imports to the top of the file:</p>
1750
1750
<pre><codeclass="lang-TypeScript">import {setHintColor} from "../../utils/hint-util";
1751
1751
import {TextField} from "ui/text-field";
@@ -1781,7 +1781,7 @@ <h4 class="exercise-start">
1781
1781
</code></pre>
1782
1782
<p>By convention, NativeScript controls make their iOS and Android native implementations available via <code>ios</code> and <code>android</code> properties, respectively. In this code that means that <code>args.color.ios</code> resolves to a <ahref="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/"><code>UIColor</code></a>, and <code>args.view.ios</code> resolves to a <ahref="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/"><code>UITextField</code></a>. Once you have a reference to these controls you can set native properties on them directly in TypeScript, which this code does with the <code>UITextField</code>’s <ahref="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/#//apple_ref/occ/instp/UITextField/attributedPlaceholder"><code>attributedPlaceholder</code> property</a>.</p>
1783
1783
<p>The power with NativeScript is you can perform these customizations in TypeScript—there’s no need to jump into Xcode and write Objective-C or Swift. And this doesn’t apply just to attributes. Notice the global <code>NSDictionary</code>, <code>NSAttributedString</code>, and <code>NSForegroundColorAttributeName</code> attributes. In NativeScript, all iOS and Android APIs are globally available to use—again, directly in TypeScript code.</p>
1784
-
<p>Admittedly, this code can seem a bit arcane if you’ve never written an iOS app before, but the key here is that you’re never limited by the APIs that NativeScript provides out of the box. Most of the time you’ll be able to solve problems using the NativeScript module APIs, but if you hit a scenario your app needs that NativeScript doesn’t provide a module for, you can always hit the native APIs directly.</p>
1784
+
<p>Admittedly, this code can seem a bit arcane if you’ve never written an iOS app before, but the key here is that you’re never limited by the APIs that NativeScript provides out of the box. Most of the time you’ll be able to solve problems using the NativeScript module APIs or NativeScript plugins, but if you hit a scenario your app needs that NativeScript doesn’t provide a module for, you can always hit the native APIs directly.</p>
1785
1785
<blockquote>
1786
1786
<p><strong>TIP</strong>:</p>
1787
1787
<ul>
@@ -1834,7 +1834,7 @@ <h4 class="exercise-start">
1834
1834
<b>Exercise</b>: Making translucent status bars
1835
1835
</h4>
1836
1836
1837
-
<p>Sometimes accomplishing tasks with native code is simple, as it was with setting hint text on Android, and sometimes it takes a little more work. Because setting a status bar’s appearance is slightly more involved, the code has been prepopulated in <code>app/utils/status-bar-util.ts</code>. There are a few comments the link to detailed information on the techniques used, if you’re curious about how it all works.</p>
1837
+
<p>Sometimes accomplishing tasks with native code is simple, as it was with setting hint text on Android, and sometimes it takes a little more work. Because setting a status bar’s appearance is slightly more involved, the code has been prepopulated in <code>app/utils/status-bar-util.ts</code>. There are a few comments that link to detailed information on the techniques used, if you’re curious about how it all works.</p>
1838
1838
<p>Because this code changes the appearance of the status bar, we’ll want to call this method as soon as possible, so that the status bar doesn’t awkwardly update after the app has already loaded. Therefore to use this new utility, open <code>app/main.ts</code> and replace the contents of the file with the following code, which calls a new <code>setStatusBarColors()</code> before the app is bootstrapped.</p>
1839
1839
<pre><codeclass="lang-TypeScript">import {nativeScriptBootstrap} from "nativescript-angular/application";
1840
1840
import {AppComponent} from "./app.component";
@@ -1843,7 +1843,7 @@ <h4 class="exercise-start">
1843
1843
setStatusBarColors();
1844
1844
nativeScriptBootstrap(AppComponent);
1845
1845
</code></pre>
1846
-
<p>Finally, there are a few last CSS tweaks you to make to account for the now translucent status bars. On iOS a translucent status bar continues to take up space open, so you need to adjust the content of the page to sit on top of the status bar’s location. To do so, open <code>app/platform.ios.css</code> and paste in the following code:</p>
1846
+
<p>Finally, there are a few last CSS tweaks you to make to account for the now translucent status bars. On iOS a translucent status bar continues to take up space, so you need to adjust the content of the page to sit on top of the status bar’s location. To do so, open <code>app/platform.ios.css</code> and paste in the following code:</p>
1847
1847
<pre><codeclass="lang-CSS">Page {
1848
1848
margin-top: -20;
1849
1849
}
@@ -1870,7 +1870,7 @@ <h4 class="exercise-start">
1870
1870
</h4>
1871
1871
1872
1872
<p>As cool as Groceries is, it’s currently missing one crucial feature for a grocery management app: the ability to delete groceries from the list.</p>
1873
-
<p>The Groceries backend already supports deleting, but it’s up to you to implement the feature in the app. You do get two hints though. First, this is a function you can use in the <code>GroceryListService</code> for performing the necessary HTTP call to delete a grocery:</p>
1873
+
<p>The Groceries backend already supports deleting, but it’s up to you to implement the feature in the app. You do get two hints though. First, below is a function you can use in the <code>GroceryListService</code> for performing the necessary HTTP call to delete a grocery:</p>
<p>Second, here’s an image you can use in your template for users to tap to delete items. One note though: the image is a white “X”, so you’ll have to find a way to create a non-white background in order to see the image.</p>
<p>If you get stuck the Groceries app’s <ahref="https://github.com/NativeScript/sample-Groceries/tree/angular-end">“angular-end” branch</a> has a solution you can check.</p>
1890
+
<p>If you get stuck, the Groceries app’s <ahref="https://github.com/NativeScript/sample-Groceries/tree/angular-end">“angular-end” branch</a> has a solution you can check.</p>
1891
1891
<divclass="exercise-end"></div>
1892
1892
1893
1893
</div>
1894
1894
<divclass="chapter">
1895
1895
<h2id="next-steps">Next steps</h2>
1896
-
<p>Sadly our tutorial is now complete, but your journey with NativeScript is just beginning. Let’s look at the next steps you can take to build your next app with NativeScript.</p>
1896
+
<p>Sadly our tutorial is now complete, but your journey with NativeScript is just beginning. Let’s look at the some steps you can take to build your next app with NativeScript.</p>
1897
1897
<h3id="join-the-nativescript-community">Join the NativeScript community</h3>
1898
1898
<p>Regardless of what you choose to do next with NativeScript, joining the NativeScript community is a great way to keep up with the latest and greatest in the NativeScript world. Here are some ways you can get involved:</p>
<li>The NativeScript team provides a series of <ahref="https://www.nativescript.org/app-samples-with-code">real-world app samples</a> that are all open source on GitHub. These samples are great to reference as you’re developing your application.</li>
1917
1917
<li>The <ahref="https://www.nativescript.org/resources">NativeScript resources page</a> lists further NativeScript learning material, such as training, books, and screencasts.</li>
1918
1918
<li><ahref="http://www.nativescriptsnacks.com/">NativeScript Snacks</a> is a collection of bite-sized video tutorials—perfect for learning how a NativeScript concept works quickly.</li>
1919
-
<li>This NativeScript documentation site has detailed guides on topics that were out of scope for this guide, including <ahref="http://docs.nativescript.org/core-concepts/testing">unit testing</a>, <ahref="http://docs.nativescript.org/core-concepts/debugging">debugging</a>, <ahref="http://docs.nativescript.org/core-concepts/transpilers">transpiling Babel or TypeScript code</a>, and <ahref="http://docs.nativescript.org/core-concepts/publishing-ios-apps">publishing to the iOS App Store</a> and <ahref="http://docs.nativescript.org/core-concepts/publishing-android-apps">Google Play</a>.</li>
1919
+
<li>The NativeScript documentation site has detailed guides on topics that were out of scope for this guide, including <ahref="http://docs.nativescript.org/core-concepts/testing">unit testing</a>, <ahref="http://docs.nativescript.org/core-concepts/debugging">debugging</a>, <ahref="http://docs.nativescript.org/core-concepts/transpilers">transpiling Babel or TypeScript code</a>, and <ahref="http://docs.nativescript.org/core-concepts/publishing-ios-apps">publishing to the iOS App Store</a> and <ahref="http://docs.nativescript.org/core-concepts/publishing-android-apps">Google Play</a>.</li>
1920
1920
</ul>
1921
1921
<h3id="let-us-know-what-you-think">Let us know what you think</h3>
1922
1922
<p>Finally, we’d love if you could take a minute to tell us what you thought about the this guide. Your feedback helps us make this tutorial better.</p>
Copy file name to clipboardExpand all lines: src/chapters/chapter4.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -662,4 +662,4 @@ The result of this code is a nice fade-in animation:
662
662
663
663
Nowthatyouhavefunctionalloginandlistpages, let’senhancetheapp’sfunctionalityasagrocerylistmanagement tool. Inthenextchaptersyou'll add functionality such as email validation, social sharing, and more. And you’ll use one of NativeScript'smostusefulfeaturestodoso:npmmodules.
664
664
665
-
> **TIP**:ThereareseveralmodulesthatcomeoutoftheboxwithyourNativeScriptinstallationthatwedidnothavetimetocoverinthisguide—includinga [locationservice](https://docs.nativescript.org/ApiReference/location/HOW-TO), a [file-system helper](https://docs.nativescript.org/ApiReference/file-system/HOW-TO), a [timer module](https://docs.nativescript.org/ApiReference/timer/HOW-TO), a [camera module](https://docs.nativescript.org/ApiReference/camera/HOW-TO), and a whole lot more. Make sure to peruse the “Modules API” of the docs, or just look around `node_modules/tns-core-modules` to see all of what’s available.
665
+
> **TIP**:ThereareseveralmodulesthatcomeoutoftheboxwithyourNativeScriptinstallationthatwedidnothavetimetocoverinthisguide—includinga [locationservice](https://docs.nativescript.org/ApiReference/location/HOW-TO), a [file-system helper](https://docs.nativescript.org/ApiReference/file-system/HOW-TO), a [timer module](https://docs.nativescript.org/ApiReference/timer/HOW-TO), a [camera module](https://docs.nativescript.org/ApiReference/camera/HOW-TO), and a whole lot more. Make sure to peruse the “Modules API” of the NativeScript documentation, or just look around your `node_modules/tns-core-modules` folder to see all of what’s available.
0 commit comments