Skip to content

Commit 04281e9

Browse files
committed
Completing my first pass through chapter 4
1 parent 34b430c commit 04281e9

File tree

2 files changed

+131
-4
lines changed

2 files changed

+131
-4
lines changed

index.html

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ <h4 class="exercise-start">
10001000
</h4>
10011001

10021002
<p>Open <code>app/pages/list/list.html</code> and paste in the following code:</p>
1003-
<pre><code class="lang-XML">&lt;ListView [items]=&quot;groceryList&quot; class=&quot;small-spacing&quot;&gt;
1003+
<pre><code class="lang-XML">&lt;ListView [items]=&quot;groceryList&quot; id=&quot;grocery-list&quot; class=&quot;small-spacing&quot;&gt;
10041004
&lt;template #item=&quot;item&quot;&gt;
10051005
&lt;Label [text]=&quot;item.name&quot; class=&quot;medium-spacing&quot;&gt;&lt;/Label&gt;
10061006
&lt;/template&gt;
@@ -1172,7 +1172,7 @@ <h4 class="exercise-start">
11721172
&lt;Image src=&quot;res://add&quot; col=&quot;1&quot;&gt;&lt;/Image&gt;
11731173
&lt;/GridLayout&gt;
11741174

1175-
&lt;ListView [items]=&quot;groceryList&quot; row=&quot;1&quot; class=&quot;small-spacing&quot;&gt;
1175+
&lt;ListView [items]=&quot;groceryList&quot; id=&quot;grocery-list&quot; row=&quot;1&quot; class=&quot;small-spacing&quot;&gt;
11761176
&lt;template #item=&quot;item&quot;&gt;
11771177
&lt;Label [text]=&quot;item.name&quot; class=&quot;medium-spacing&quot;&gt;&lt;/Label&gt;
11781178
&lt;/template&gt;
@@ -1251,7 +1251,63 @@ <h4 class="exercise-start">
12511251
<p>Remind people that the final code for the tutorial is up on GitHub.</p>
12521252
<p>Talk about the code you just wrote.</p>
12531253
<p>Show a gif of the page in action.</p>
1254+
<p>Let’s make the page look a little nicer.</p>
12541255
<h3 id="activityindicator">ActivityIndicator</h3>
1256+
<p>Introduce the activity indicator.</p>
1257+
<h4 class="exercise-start">
1258+
<b>Exercise</b>: ???
1259+
</h4>
1260+
1261+
<p>Open up <code>app/pages/list/list.html</code> and paste the following line immediately before the final <code>&lt;/GridLayout&gt;</code>:</p>
1262+
<pre><code class="lang-XML">&lt;ActivityIndicator [busy]=&quot;isLoading&quot; row=&quot;1&quot;&gt;&lt;/ActivityIndicator&gt;
1263+
</code></pre>
1264+
<p>Next, open <code>app/pages/list/list.component.ts</code> and add the following property to the <code>ListPage</code> class (immediately under <code>grocery: string</code>):</p>
1265+
<pre><code class="lang-TypeScript">isLoading = false;
1266+
</code></pre>
1267+
<p>Then, change the existing <code>ngOnInit()</code> function to use the code below:</p>
1268+
<pre><code class="lang-TypeScript">ngOnInit() {
1269+
this.isLoading = true;
1270+
this._groceryListService.load()
1271+
.subscribe(loadedGroceries =&gt; {
1272+
loadedGroceries.forEach((groceryObject) =&gt; {
1273+
this.groceryList.unshift(groceryObject);
1274+
});
1275+
this.isLoading = false;
1276+
});
1277+
}
1278+
</code></pre>
1279+
<div class="exercise-end"></div>
1280+
1281+
<p>Talk about how that works, then introduce how an animation can add a little polish.</p>
1282+
<h4 class="exercise-start">
1283+
<b>Exercise</b>: ???
1284+
</h4>
1285+
1286+
<p>Open <code>app/pages/list/list-common.css</code> and paste the following CSS at the top of the file:</p>
1287+
<pre><code class="lang-CSS">ListView {
1288+
opacity: 0;
1289+
}
1290+
</code></pre>
1291+
<p>Next, open <code>app/pages/list/list-component.ts</code> and add replace the existing <code>ngOnInit()</code> function with the following code:</p>
1292+
<pre><code class="lang-TypeScript">ngOnInit() {
1293+
this.isLoading = true;
1294+
this._groceryListService.load()
1295+
.subscribe(loadedGroceries =&gt; {
1296+
loadedGroceries.forEach((groceryObject) =&gt; {
1297+
this.groceryList.unshift(groceryObject);
1298+
});
1299+
this.isLoading = false;
1300+
var groceryList = topmost().currentPage.getViewById(&quot;grocery-list&quot;);
1301+
groceryList.animate({
1302+
opacity: 1,
1303+
duration: 1000
1304+
});
1305+
});
1306+
}
1307+
</code></pre>
1308+
<div class="exercise-end"></div>
1309+
1310+
<p>Talk about what happened. Include a gif. Transition to talking about npm modules and {N} plugins.</p>
12551311

12561312
</div>
12571313
<div class="chapter">

src/chapters/chapter4.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Talk about what list views are.
9494
Open `app/pages/list/list.html` and paste in the following code:
9595

9696
``` XML
97-
<ListView [items]="groceryList" class="small-spacing">
97+
<ListView [items]="groceryList" id="grocery-list" class="small-spacing">
9898
<template #item="item">
9999
<Label [text]="item.name" class="medium-spacing"></Label>
100100
</template>
@@ -317,7 +317,7 @@ Open `app/pages/list/list.html` and paste in the following code:
317317
<Image src="res://add" col="1"></Image>
318318
</GridLayout>
319319

320-
<ListView [items]="groceryList" row="1" class="small-spacing">
320+
<ListView [items]="groceryList" id="grocery-list" row="1" class="small-spacing">
321321
<template #item="item">
322322
<Label [text]="item.name" class="medium-spacing"></Label>
323323
</template>
@@ -420,8 +420,79 @@ Talk about the code you just wrote.
420420

421421
Show a gif of the page in action.
422422

423+
Let’s make the page look a little nicer.
424+
423425
### ActivityIndicator
424426

427+
Introduce the activity indicator.
428+
429+
<h4 class="exercise-start">
430+
<b>Exercise</b>: ???
431+
</h4>
432+
433+
Open up `app/pages/list/list.html` and paste the following line immediately before the final `</GridLayout>`:
434+
435+
``` XML
436+
<ActivityIndicator [busy]="isLoading" row="1"></ActivityIndicator>
437+
```
438+
439+
Next, open `app/pages/list/list.component.ts` and add the following property to the `ListPage` class (immediately under `grocery: string`):
440+
441+
``` TypeScript
442+
isLoading = false;
443+
```
444+
445+
Then, change the existing `ngOnInit()` function to use the code below:
446+
447+
``` TypeScript
448+
ngOnInit() {
449+
this.isLoading = true;
450+
this._groceryListService.load()
451+
.subscribe(loadedGroceries => {
452+
loadedGroceries.forEach((groceryObject) => {
453+
this.groceryList.unshift(groceryObject);
454+
});
455+
this.isLoading = false;
456+
});
457+
}
458+
```
459+
460+
<div class="exercise-end"></div>
461+
462+
Talk about how that works, then introduce how an animation can add a little polish.
463+
464+
<h4 class="exercise-start">
465+
<b>Exercise</b>: ???
466+
</h4>
425467

468+
Open `app/pages/list/list-common.css` and paste the following CSS at the top of the file:
426469

470+
``` CSS
471+
ListView {
472+
opacity: 0;
473+
}
474+
```
475+
476+
Next, open `app/pages/list/list-component.ts` and add replace the existing `ngOnInit()` function with the following code:
477+
478+
``` TypeScript
479+
ngOnInit() {
480+
this.isLoading = true;
481+
this._groceryListService.load()
482+
.subscribe(loadedGroceries => {
483+
loadedGroceries.forEach((groceryObject) => {
484+
this.groceryList.unshift(groceryObject);
485+
});
486+
this.isLoading = false;
487+
var groceryList = topmost().currentPage.getViewById("grocery-list");
488+
groceryList.animate({
489+
opacity: 1,
490+
duration: 1000
491+
});
492+
});
493+
}
494+
```
495+
496+
<div class="exercise-end"></div>
427497

498+
Talk about what happened. Include a gif. Transition to talking about npm modules and {N} plugins.

0 commit comments

Comments
 (0)