Skip to content

Commit ab14144

Browse files
ikoevskarigor789
authored andcommitted
Added more styling to the tutorial (#137)
* Advanced styling: Styled tabs * Changed font size for tab titles * Styled active tasks * Fixed table layout issue * Fixed table issues * Update 2-playground-tutorial.md
1 parent 83d7c60 commit ab14144

File tree

6 files changed

+93
-13
lines changed

6 files changed

+93
-13
lines changed

content/docs/en/getting-started/2-playground-tutorial.md

Lines changed: 93 additions & 13 deletions
Original file line numberDiff line numberDiff 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
2121
* [Basic functionality: View, complete, and delete tasks from the To Do tab](#basic-functionality-view-complete-and-delete-tasks-from-the-to-do-tab)
2222
* [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)
2323
* [Advanced design: Styled input field and button](#advanced-design-styled-input-field-and-button)
24+
* [Advanced design: Styled tab navigation](#advanced-design-styled-tab-navigation)
25+
* [Advanced design: Styled active tasks](#advanced-design-styled-active-tasks)
2426

2527

2628
# Part 1: Getting familiar with the Playground
@@ -96,7 +98,8 @@ If you want to explore the [NativeScript Playground](https://play.nativescript.o
9698
* Delete tasks: Tapping an active or completed task shows an action dialog with options
9799
* (In progress) Advanced design
98100
* Input and button for adding tasks are styled
99-
* (Coming soon) Active tasks are styled
101+
* Tabs are styled
102+
* Active tasks are styled
100103
* (Coming soon) Completed tasks are styled
101104
* (Coming soon) Advanced functionality
102105
* (Coming soon) Store timestamp data for each task
@@ -226,7 +229,7 @@ new Vue({
226229
}
227230
},
228231
methods: {
229-
onItemTap: function (args) {
232+
onItemTap(args) {
230233
console.log('Task with index: ' + args.index + ' tapped'); // Logs tapped tasks in the console for debugging.
231234
},
232235
onButtonTap() {
@@ -302,7 +305,7 @@ Out-of-the-box, the `<ListView>` component detects a tap gesture for every item
302305
* 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.
303306

304307
```JavaScript
305-
onItemTap: function (args) {
308+
onItemTap(args) {
306309
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
307310
.then(result => {
308311
console.log(result); // Logs the selected option for debugging.
@@ -335,7 +338,7 @@ new Vue({
335338
}
336339
},
337340
methods: {
338-
onItemTap: function (args) {
341+
onItemTap(args) {
339342
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
340343
.then(result => {
341344
console.log(result); // Logs the selected option for debugging.
@@ -417,7 +420,7 @@ For the second tab, modify the `onDoneTap` method:
417420
* 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.
418421

419422
```JavaScript
420-
onDoneTap: function (args) {
423+
onDoneTap(args) {
421424
action('What do you want to do with this task?', 'Cancel', ['Mark to do', 'Delete forever'])
422425
.then(result => {
423426
console.log(result); // Logs the selected option for debugging.
@@ -450,7 +453,7 @@ new Vue({
450453
}
451454
},
452455
methods: {
453-
onItemTap: function (args) {
456+
onItemTap(args) {
454457
action('What do you want to do with this task?', 'Cancel', ['Mark completed', 'Delete forever'])
455458
.then(result => {
456459
console.log(result); // Logs the selected option for debugging.
@@ -467,7 +470,7 @@ new Vue({
467470
}
468471
})
469472
},
470-
onDoneTap: function (args) {
473+
onDoneTap(args) {
471474
action('What do you want to do with this task?', 'Cancel', ['Mark to do', 'Delete forever'])
472475
.then(result => {
473476
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
544547

545548
### Requirement implementation
546549

547-
#### Input field
550+
#### Style the input field
548551

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>`.
550553

551554
```CSS
552555
TextField {
@@ -555,11 +558,11 @@ TextField {
555558
margin-top: 10;
556559
margin-bottom: 10;
557560
margin-right: 5;
558-
margin-left: 10;
561+
margin-left: 20;
559562
}
560563
```
561564

562-
#### Button
565+
#### Style the button
563566

564567
1. In `app.js` on line 63, add an `id` for the button.
565568

@@ -574,10 +577,87 @@ TextField {
574577
font-weight: bold;
575578
color: white;
576579
background-color: #53ba82;
577-
margin-top: 10;
580+
margin-top: 20;
578581
margin-bottom: 10;
579-
margin-right: 10;
582+
margin-right: 20;
580583
margin-left: 5;
581584
border-radius: 20px;
582585
}
583586
```
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.
593+
594+
| Tabs - No style | Tabs Styled
595+
|-----|-------------|
596+
| ![Unstyled tabs](/screenshots/ns-playground/styled-button.jpg) | ![Styled tabs](/screenshots/ns-playground/styled-tabs.jpg) |
597+
598+
### Some NativeScript basics
599+
600+
`<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.
609+
610+
```HTML
611+
<TabView height="100%" selectedTabTextColor="#53ba82" tabTextFontSize="20" >
612+
```
613+
614+
#### Transform text
615+
616+
In `app.js`, on lines 58 and 73, apply the `textTransform` property. You can use this property only on the `<TabViewItem>` level.
617+
618+
```HTML
619+
<TabViewItem title="To Do" textTransform="uppercase" >
620+
```
621+
622+
```HTML
623+
<TabViewItem title="Completed" textTransform="uppercase">
624+
```
625+
626+
## Advanced design: Styled active tasks
627+
628+
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+
| ![Unstyled active tasks](/screenshots/ns-playground/styled-tabs.jpg) | ![No separator](/screenshots/ns-playground/styled-list-view-no-separator.jpg) | ![Styled list](/screenshots/ns-playground/styled-list-view-added-tasks.jpg) |
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
643+
644+
```HTML
645+
<Label id="active-task" :text="todo.name" textWrap="true" >
646+
```
647+
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+
<ListView for="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.
653+
654+
```CSS
655+
#active-task {
656+
font-size: 20;
657+
font-weight: bold;
658+
color: #53ba82;
659+
margin-left: 20;
660+
padding-top: 5;
661+
padding-bottom: 10;
662+
}
663+
```
-106 Bytes
Loading
-214 Bytes
Loading
Loading
Loading
20.5 KB
Loading

0 commit comments

Comments
 (0)