Skip to content

Commit d27576a

Browse files
committed
Finishing a second pass through the animation section
1 parent 551e4dc commit d27576a

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

images/chapter4/android/2.gif

735 KB
Loading

images/chapter4/ios/2.gif

1.32 MB
Loading

index.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h3 id="what-is-nativescript-what-is-angular-2-">What is NativeScript? What is A
4949
</div>
5050

5151
<blockquote>
52-
<p><strong>TIP</strong>: Using Angular 2 with NativeScript is optional. If you’re looking for a guide on how to use NativeScript without Angular 2, head over to our other <a href="http://docs.nativescript.org/start/getting-started">Getting Started Guide</a>.</p>
52+
<p><strong>TIP</strong>: Using Angular 2 with NativeScript is optional. If you’re looking for a tutorial on how to use NativeScript without Angular 2, head over to our other <a href="http://docs.nativescript.org/start/getting-started">Getting Started Guide</a>.</p>
5353
</blockquote>
5454
<h3 id="what-you-re-building">What you&#39;re building</h3>
5555
<p>This guide will walk you through building <a href="https://github.com/NativeScript/sample-Groceries">Groceries</a>, a groceries management app that does the following things:</p>
@@ -1095,17 +1095,18 @@ <h3 id="animations">Animations</h3>
10951095
<li><a href="{{site.baseurl}}/ui/animation#scale">Scaling</a></li>
10961096
<li><a href="{{site.baseurl}}/ui/animation#rotate">Rotating</a></li>
10971097
</ul>
1098+
<p>Let’s add a simple animation so you can see how they work.</p>
10981099
<h4 class="exercise-start">
1099-
<b>Exercise</b>: ???
1100+
<b>Exercise</b>: Add a color animation
11001101
</h4>
11011102

1102-
<p>Open <code>app/pages/login/login.html</code> and add an <code>id</code> to the <code>&lt;StackLayout&gt;</code>:</p>
1103+
<p>Open <code>app/pages/login/login.html</code> and add an <code>id</code> to the existing <code>&lt;StackLayout&gt;</code>:</p>
11031104
<pre><code class="lang-XML">&lt;StackLayout id=&quot;container&quot;&gt;
11041105
</code></pre>
1105-
<p>Open <code>app/pages/login/login.component.ts</code> and add the following line at the top:</p>
1106+
<p>Next, open <code>app/pages/login/login.component.ts</code> and add the following line at the top, which imports the <a href="http://docs.nativescript.org/ApiReference/color/Color.html"><code>Color</code> class</a> from the NativeScript color module:</p>
11061107
<pre><code class="lang-TypeScript">import {Color} from &quot;color&quot;;
11071108
</code></pre>
1108-
<p>Change the <code>toggleDisplay()</code> function in the same file to look like this:</p>
1109+
<p>Finally, change the <code>LoginPage</code>’s <code>toggleDisplay()</code> function in the same file to use this code:</p>
11091110
<pre><code class="lang-TypeScript">toggleDisplay() {
11101111
this.isLoggingIn = !this.isLoggingIn;
11111112
this.page.getViewById(&quot;container&quot;).animate({
@@ -1116,7 +1117,15 @@ <h4 class="exercise-start">
11161117
</code></pre>
11171118
<div class="exercise-end"></div>
11181119

1119-
<p>Talk about the color module and animation module. Have gifs. Mention that the hint color looks bad, but that we’ll address that later. Transition to talking about the list page.</p>
1120+
<p>All NativeScript UI elements inherit from a base <a href="http://docs.nativescript.org/ApiReference/ui/core/view/View.html"><code>View</code> class</a>, which contains a number of useful methods—including the <code>getViewById()</code> and <code>animate()</code> methods used in the previous example. The <code>getViewById()</code> method, as its name implies, allows you to get a reference to a child view by its <code>id</code> attribute.</p>
1121+
<p>One you have a reference to a UI element, you can call any of the methods that element inherits from <code>View</code>. In this case, you call the <code>&lt;StackLayout id=&quot;container&quot;&gt;</code> element’s <code>animate()</code> method to change its background color over a duration of <code>200</code>, or 2/10 of a second. The effect is a subtle color change that helps user differentiate between the “Sign In” and “Sign Up” functionality that your form provides.</p>
1122+
<p><img src="images/chapter4/android/2.gif" alt="Color animation on Android">
1123+
<img src="images/chapter4/ios/2.gif" alt="Color animation on iOS"></p>
1124+
<blockquote>
1125+
<p><strong>NOTE</strong>: You may notice that the text color is off with the brown background. Don’t worry about that for now; we’ll address that in chapter 6.</p>
1126+
</blockquote>
1127+
<p>The animation module is a lot of fun to play with, and it’s easy to use too. All you need to do is get a reference to an element using <code>getViewById()</code>, and then call that element’s <code>animate()</code> method. You may want to take a few minutes to look through our <a href="{{site.baseurl}}/ui/animation#examples">animation samples</a> and try a few of these animations for yourself in Groceries.</p>
1128+
<p>For now, let’s move on to another commonly used NativeScript UI element: the <code>&lt;ListView&gt;</code>.</p>
11201129
<h3 id="listview">ListView</h3>
11211130
<p>Talk about what list views are.</p>
11221131
<h4 class="exercise-start">

src/chapters/chapter0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Welcome to the NativeScript & Angular 2 getting started guide 📚. In this hand
2121
<p>The result is a software architecture that allows you to build mobile apps using the same framework—and in some cases the same code—that you use to build Angular 2 web apps, with the performance you’d expect from native code. Let’s look at how it all works by building an app.</p>
2222
</div>
2323

24-
> **TIP**: Using Angular 2 with NativeScript is optional. If you’re looking for a guide on how to use NativeScript without Angular 2, head over to our other [Getting Started Guide](http://docs.nativescript.org/start/getting-started).
24+
> **TIP**: Using Angular 2 with NativeScript is optional. If you’re looking for a tutorial on how to use NativeScript without Angular 2, head over to our other [Getting Started Guide](http://docs.nativescript.org/start/getting-started).
2525
2626
### What you're building
2727

src/chapters/chapter4.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,25 @@ The ability to run robust and performant animations is the one of the biggest re
9393
- [Scaling]({{site.baseurl}}/ui/animation#scale)
9494
- [Rotating]({{site.baseurl}}/ui/animation#rotate)
9595

96+
Lets add a simple animation so you can see how they work.
97+
9698
<h4 class="exercise-start">
97-
<b>Exercise</b>: ???
99+
<b>Exercise</b>: Add a color animation
98100
</h4>
99101

100-
Open `app/pages/login/login.html` and add an `id` to the `<StackLayout>`:
102+
Open `app/pages/login/login.html` and add an `id` to the existing `<StackLayout>`:
101103

102104
``` XML
103105
<StackLayout id="container">
104106
```
105107

106-
Open `app/pages/login/login.component.ts` and add the following line at the top:
108+
Next, open `app/pages/login/login.component.ts` and add the following line at the top, which imports the [`Color` class](http://docs.nativescript.org/ApiReference/color/Color.html) from the NativeScript color module:
107109

108110
``` TypeScript
109111
import {Color} from "color";
110112
```
111113

112-
Change the `toggleDisplay()` function in the same file to look like this:
114+
Finally, change the `LoginPage`s `toggleDisplay()` function in the same file to use this code:
113115

114116
``` TypeScript
115117
toggleDisplay() {
@@ -123,7 +125,18 @@ toggleDisplay() {
123125

124126
<div class="exercise-end"></div>
125127

126-
Talk about the color module and animation module. Have gifs. Mention that the hint color looks bad, but that well address that later. Transition to talking about the list page.
128+
All NativeScript UI elements inherit from a base [`View` class](http://docs.nativescript.org/ApiReference/ui/core/view/View.html), which contains a number of useful methods—including the `getViewById()` and `animate()` methods used in the previous example. The `getViewById()` method, as its name implies, allows you to get a reference to a child view by its `id` attribute.
129+
130+
One you have a reference to a UI element, you can call any of the methods that element inherits from `View`. In this case, you call the `<StackLayout id="container">` elements `animate()` method to change its background color over a duration of `200`, or 2/10 of a second. The effect is a subtle color change that helps user differentiate between theSign InandSign Upfunctionality that your form provides.
131+
132+
![Color animation on Android](images/chapter4/android/2.gif)
133+
![Color animation on iOS](images/chapter4/ios/2.gif)
134+
135+
> **NOTE**: You may notice that the text color is off with the brown background. Dont worry about that for now; well address that in chapter 6.
136+
137+
The animation module is a lot of fun to play with, and its easy to use too. All you need to do is get a reference to an element using `getViewById()`, and then call that elements `animate()` method. You may want to take a few minutes to look through our [animation samples]({{site.baseurl}}/ui/animation#examples) and try a few of these animations for yourself in Groceries.
138+
139+
For now, lets move on to another commonly used NativeScript UI element: the `<ListView>`.
127140

128141
### ListView
129142

0 commit comments

Comments
 (0)