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: content/docs/en/getting-started/2-playground-tutorial.md
+93-13Lines changed: 93 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ You can work in the Playground for as long as you like. You can use it to just g
21
21
*[Basic functionality: View, complete, and delete tasks from the To Do tab](#basic-functionality-view-complete-and-delete-tasks-from-the-to-do-tab)
22
22
*[Basic functionality: View, return to active tasks, and delete tasks from the Completed tab](#basic-functionality-view-return-to-active-tasks-and-delete-tasks-from-the-completed-tab)
23
23
*[Advanced design: Styled input field and button](#advanced-design-styled-input-field-and-button)
*[Advanced design: Styled active tasks](#advanced-design-styled-active-tasks)
24
26
25
27
26
28
# Part 1: Getting familiar with the Playground
@@ -96,7 +98,8 @@ If you want to explore the [NativeScript Playground](https://play.nativescript.o
96
98
* Delete tasks: Tapping an active or completed task shows an action dialog with options
97
99
* (In progress) Advanced design
98
100
* Input and button for adding tasks are styled
99
-
* (Coming soon) Active tasks are styled
101
+
* Tabs are styled
102
+
* Active tasks are styled
100
103
* (Coming soon) Completed tasks are styled
101
104
* (Coming soon) Advanced functionality
102
105
* (Coming soon) Store timestamp data for each task
@@ -226,7 +229,7 @@ new Vue({
226
229
}
227
230
},
228
231
methods: {
229
-
onItemTap:function(args) {
232
+
onItemTap(args) {
230
233
console.log('Task with index: '+args.index+' tapped'); // Logs tapped tasks in the console for debugging.
231
234
},
232
235
onButtonTap() {
@@ -302,7 +305,7 @@ Out-of-the-box, the `<ListView>` component detects a tap gesture for every item
302
305
* Based on user selection, the method moves elements from the `todos` array to the `dones` array, deletes elements from the `todos` array, or dismisses the dialog. Use `splice()` to avoid leaving holes in the array and `unshift()` to make sure that recently completed tasks are shown on top.
303
306
304
307
```JavaScript
305
-
onItemTap:function(args) {
308
+
onItemTap(args) {
306
309
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
307
310
.then(result=> {
308
311
console.log(result); // Logs the selected option for debugging.
@@ -335,7 +338,7 @@ new Vue({
335
338
}
336
339
},
337
340
methods: {
338
-
onItemTap:function(args) {
341
+
onItemTap(args) {
339
342
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
340
343
.then(result=> {
341
344
console.log(result); // Logs the selected option for debugging.
@@ -417,7 +420,7 @@ For the second tab, modify the `onDoneTap` method:
417
420
* Based on user selection, the method moves elements from the `dones` array to the `todos` array, deletes elements from the `dones` array, or dismisses the dialog. Use `splice()` to avoid leaving holes in the array and `unshift()` to make sure that recently completed tasks are shown on top.
418
421
419
422
```JavaScript
420
-
onDoneTap:function(args) {
423
+
onDoneTap(args) {
421
424
action('What do you want to do with this task?', 'Cancel', ['Mark to do', 'Delete forever'])
422
425
.then(result=> {
423
426
console.log(result); // Logs the selected option for debugging.
@@ -450,7 +453,7 @@ new Vue({
450
453
}
451
454
},
452
455
methods: {
453
-
onItemTap:function(args) {
456
+
onItemTap(args) {
454
457
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
455
458
.then(result=> {
456
459
console.log(result); // Logs the selected option for debugging.
@@ -467,7 +470,7 @@ new Vue({
467
470
}
468
471
})
469
472
},
470
-
onDoneTap:function(args) {
473
+
onDoneTap(args) {
471
474
action('What do you want to do with this task?', 'Cancel', ['Mark to do', 'Delete forever'])
472
475
.then(result=> {
473
476
console.log(result); // Logs the selected option for debugging.
@@ -544,9 +547,9 @@ With type selectors, you can select a UI component and apply styling to it. To s
544
547
545
548
### Requirement implementation
546
549
547
-
#### Input field
550
+
#### Style the input field
548
551
549
-
In `app.css`, change the font size and the color and the margins around the `<TextField>`.
552
+
In `app.css`, change the font size, the color, and the margins around the `<TextField>`.
550
553
551
554
```CSS
552
555
TextField {
@@ -555,11 +558,11 @@ TextField {
555
558
margin-top: 10;
556
559
margin-bottom: 10;
557
560
margin-right: 5;
558
-
margin-left: 10;
561
+
margin-left: 20;
559
562
}
560
563
```
561
564
562
-
#### Button
565
+
#### Style the button
563
566
564
567
1. In `app.js` on line 63, add an `id` for the button.
565
568
@@ -574,10 +577,87 @@ TextField {
574
577
font-weight: bold;
575
578
color: white;
576
579
background-color: #53ba82;
577
-
margin-top: 10;
580
+
margin-top: 20;
578
581
margin-bottom: 10;
579
-
margin-right: 10;
582
+
margin-right: 20;
580
583
margin-left: 5;
581
584
border-radius: 20px;
582
585
}
583
586
```
587
+
588
+
## Advanced design: Styled tab navigation
589
+
590
+
### Section progress
591
+
592
+
Here's how your app will look at the start and at the end of this section.
`<TabView>` provides some styling properties out of the box. You can apply a text transform to each tab titles (`textTransform`) and change the font size and color globally (`tabTextFontSize`, `tabTextColor`, `selectedTabTextColor`). You can also change the background color of your tabs (`tabBackgroundColor`).
601
+
602
+
> **NOTE:** Currently, `tabTextFontSize` does not work on iOS and you cannot change the font size of tab titles on iOS.
603
+
604
+
### Requirement implementation
605
+
606
+
#### Change color and font size of selected tab title
607
+
608
+
In `app.js`, on line 57, add the `selectedTabTextColor` and `tabTextFontSize` property. If you're testing this on iOS, the font size will not change but should work fine on Android.
Here's how your app will look at the start and at the end of this section.
629
+
630
+
| Active tasks - No style | Active tasks - no separator | Active tasks - styled active tasks |
631
+
|-----|-------------|---|
632
+
||||
633
+
634
+
### Some NativeScript basics
635
+
636
+
`<ListView>` and `<Label>` have out of the box style properties that you can use to control elements such as the list separator or the text wrap from `app.js`. To change the font style, color, and positioning of text, you need to use CSS in `app.css`.
637
+
638
+
To implement a style particularly for the text of active tasks, you can set an `id` for the `<Label>` element.
639
+
640
+
### Requirement implementation
641
+
642
+
1. In `app.js`, on line 67, set an `id` for the `<Label>` that represents active tasks and enable text wrapping. Enabling text wrapping ensures that longer text shows properly in your list
1. On line 65, add the `separatorColor` property and set it to `transparent`. This way, the separator will no longer appear in your list.
648
+
649
+
```HTML
650
+
<ListViewfor="todo in todos"@itemTap="onItemTap"height="100%"separatorColor="transparent">
651
+
```
652
+
1. In `app.css`, create the style for active tasks. Set font size, color, and some padding to position the text on the page. Play with margins and paddings until you get a result that works for you.
0 commit comments