Skip to content

Commit 96b14e7

Browse files
committed
Tweaking the end of chapter 6
1 parent 3c28ee3 commit 96b14e7

File tree

2 files changed

+89
-6
lines changed

2 files changed

+89
-6
lines changed

index.html

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,18 +1791,52 @@ <h4 class="exercise-start">
17911791
setStatusBarColors();
17921792
nativeScriptBootstrap(AppComponent);
17931793
</code></pre>
1794-
<p>Finally, because a translucent status bar continues to take up space on iOS, open <code>app/platform.ios.css</code> and paste in the following code, which bumps the content of the page on top of the status bar.</p>
1794+
<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>
17951795
<pre><code class="lang-CSS">Page {
17961796
margin-top: -20;
17971797
}
17981798
</code></pre>
1799+
<p>Next, open <code>app/pages/list/list.ios.css</code> and paste in the following code, which moves the add bar down from underneath the list page’s <code>&lt;ActionBar&gt;</code>:</p>
1800+
<pre><code class="lang-CSS">.add-bar {
1801+
margin-top: 20;
1802+
}
1803+
</code></pre>
1804+
<p>On Android a translucent does not take up space, so you need to add a bit of padding to the top of the list page so the status bar and <code>&lt;ActionBar&gt;</code> don’t sit on top of one another. To do so, open <code>app/pages/list/list.android.css</code> and paste in the following code:</p>
1805+
<pre><code class="lang-CSS">ActionBar {
1806+
padding-top: 10;
1807+
}
1808+
</code></pre>
17991809
<div class="exercise-end"></div>
18001810

1801-
<p>And with that, your status bar is now translucent on iOS and Android:</p>
1811+
<p>And with that, your status bar is now translucent and properly spaced on iOS and Android:</p>
18021812
<p><img src="images/chapter6/android/3.png" alt="Updated status bar on Android">
18031813
<img src="images/chapter6/ios/3.png" alt="Updated status bar on iOS"></p>
1804-
<p>And... that&#39;s it! You&#39;ve created a functional, cross-platform, backend-driven app to manage your grocery list. In the process you&#39;ve created a unique UI for Android and iOS, leveraged NativeScript plugins and npm modules, learned how to log in and register, managed backend services, created a list with add and delete functionality, and more. </p>
1814+
<p>And... that&#39;s it! You&#39;ve created a functional, cross-platform, backend-driven app to manage your grocery list. In the process you&#39;ve created a unique UI for Android and iOS, leveraged NativeScript plugins and npm modules, learned how to log in and register, managed backend services, created a list, and more. </p>
18051815
<p>Congratulations! Feel free to <a href="https://twitter.com/intent/tweet?text=I%20just%20built%20an%20iOS%20and%20Android%20app%20using%20@NativeScript%20%F0%9F%8E%89.%20You%20can%20too!%20http://docs.nativescript.org/start/getting-started%20%23opensource">share your accomplishment on Twitter</a> or <a href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fdocs.nativescript.org%2Fstart%2Fgetting-started&amp;p%5B">Facebook</a> to impress your friends 😀.</p>
1816+
<h4 class="exercise-start">
1817+
<b>Challenge</b>: Add the ability to delete groceries
1818+
</h4>
1819+
1820+
<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>
1821+
<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>
1822+
<pre><code class="lang-TypeScript">delete(id: string) {
1823+
var headers = new Headers();
1824+
headers.append(&quot;Authorization&quot;, &quot;Bearer &quot; + Config.token);
1825+
headers.append(&quot;Content-Type&quot;, &quot;application/json&quot;);
1826+
1827+
return this._http.delete(
1828+
Config.apiUrl + &quot;Groceries/&quot; + id,
1829+
{ headers: headers }
1830+
)
1831+
.map(res =&gt; res.json())
1832+
.catch(this.handleErrors);
1833+
}
1834+
</code></pre>
1835+
<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>
1836+
<pre><code class="lang-XML">&lt;Image src=&quot;res://delete&quot;&gt;&lt;/Image&gt;
1837+
</code></pre>
1838+
<p>If you get stuck the Groceries app’s <a href="https://github.com/NativeScript/sample-Groceries/tree/angular-end">“angular-end” branch</a> has a solution you can check.</p>
1839+
<div class="exercise-end"></div>
18061840

18071841
</div>
18081842
<div class="chapter">

src/chapters/chapter6.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,70 @@ setStatusBarColors();
166166
nativeScriptBootstrap(AppComponent);
167167
```
168168

169-
Finally, because a translucent status bar continues to take up space on iOS, open `app/platform.ios.css` and paste in the following code, which bumps the content of the page on top of the status bar.
169+
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 `app/platform.ios.css` and paste in the following code:
170170

171171
``` CSS
172172
Page {
173173
margin-top: -20;
174174
}
175175
```
176176

177+
Next, open `app/pages/list/list.ios.css` and paste in the following code, which moves the add bar down from underneath the list page’s `<ActionBar>`:
178+
179+
``` CSS
180+
.add-bar {
181+
margin-top: 20;
182+
}
183+
```
184+
185+
On Android a translucent does not take up space, so you need to add a bit of padding to the top of the list page so the status bar and `<ActionBar>` don’t sit on top of one another. To do so, open `app/pages/list/list.android.css` and paste in the following code:
186+
187+
``` CSS
188+
ActionBar {
189+
padding-top: 10;
190+
}
191+
```
192+
177193
<div class="exercise-end"></div>
178194

179-
And with that, your status bar is now translucent on iOS and Android:
195+
And with that, your status bar is now translucent and properly spaced on iOS and Android:
180196

181197
![Updated status bar on Android](images/chapter6/android/3.png)
182198
![Updated status bar on iOS](images/chapter6/ios/3.png)
183199

184-
And... that's it! You've created a functional, cross-platform, backend-driven app to manage your grocery list. In the process you've created a unique UI for Android and iOS, leveraged NativeScript plugins and npm modules, learned how to log in and register, managed backend services, created a list with add and delete functionality, and more.
200+
And... that's it! You've created a functional, cross-platform, backend-driven app to manage your grocery list. In the process you've created a unique UI for Android and iOS, leveraged NativeScript plugins and npm modules, learned how to log in and register, managed backend services, created a list, and more.
185201

186202
Congratulations! Feel free to [share your accomplishment on Twitter](https://twitter.com/intent/tweet?text=I%20just%20built%20an%20iOS%20and%20Android%20app%20using%20@NativeScript%20%F0%9F%8E%89.%20You%20can%20too!%20http://docs.nativescript.org/start/getting-started%20%23opensource) or [Facebook](https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fdocs.nativescript.org%2Fstart%2Fgetting-started&p%5B) to impress your friends 😀.
203+
204+
<h4 class="exercise-start">
205+
<b>Challenge</b>: Add the ability to delete groceries
206+
</h4>
207+
208+
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.
209+
210+
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 `GroceryListService` for performing the necessary HTTP call to delete a grocery:
211+
212+
``` TypeScript
213+
delete(id: string) {
214+
var headers = new Headers();
215+
headers.append("Authorization", "Bearer " + Config.token);
216+
headers.append("Content-Type", "application/json");
217+
218+
return this._http.delete(
219+
Config.apiUrl + "Groceries/" + id,
220+
{ headers: headers }
221+
)
222+
.map(res => res.json())
223+
.catch(this.handleErrors);
224+
}
225+
```
226+
227+
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.
228+
229+
``` XML
230+
<Image src="res://delete"></Image>
231+
```
232+
233+
If you get stuck the Groceries app’s [“angular-end” branch](https://github.com/NativeScript/sample-Groceries/tree/angular-end) has a solution you can check.
234+
235+
<div class="exercise-end"></div>

0 commit comments

Comments
 (0)