@@ -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 "> <ListView [items]="groceryList" class="small-spacing">
1003+ < pre > < code class ="lang-XML "> <ListView [items]="groceryList" id="grocery-list" class="small-spacing">
10041004 <template #item="item">
10051005 <Label [text]="item.name" class="medium-spacing"></Label>
10061006 </template>
@@ -1172,7 +1172,7 @@ <h4 class="exercise-start">
11721172 <Image src="res://add" col="1"></Image>
11731173 </GridLayout>
11741174
1175- <ListView [items]="groceryList" row="1" class="small-spacing">
1175+ <ListView [items]="groceryList" id="grocery-list" row="1" class="small-spacing">
11761176 <template #item="item">
11771177 <Label [text]="item.name" class="medium-spacing"></Label>
11781178 </template>
@@ -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 > </GridLayout></ code > :</ p >
1262+ < pre > < code class ="lang-XML "> <ActivityIndicator [busy]="isLoading" row="1"></ActivityIndicator>
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 => {
1272+ loadedGroceries.forEach((groceryObject) => {
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 => {
1296+ loadedGroceries.forEach((groceryObject) => {
1297+ this.groceryList.unshift(groceryObject);
1298+ });
1299+ this.isLoading = false;
1300+ var groceryList = topmost().currentPage.getViewById("grocery-list");
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 ">
0 commit comments