Skip to content

Commit 9c2fa7f

Browse files
ikoevskarigor789
authored andcommitted
Playground tutorial (#58)
* Added placeholder page for the tutorial * Added placeholder page for the tutorial * Renamed other pages for reordering purposes * Completed overview of template * Completed first self-contained section of the tutorial * Linked from Quick Start to the Tutorial * Basic design implementation * Added section about the basic design * Added some screenshots for progress * Added tip in quic start about making the payground and preview apps work again * How to enable device logs * Removed huge screenshot
1 parent af2036c commit 9c2fa7f

File tree

9 files changed

+88
-0
lines changed

9 files changed

+88
-0
lines changed

content/docs/en/getting-started/1-quick-start.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ It's a place in the cloud where you can just play around with NativeScript and V
1111

1212
Firing [this link](https://play.nativescript.org/?template=play-vue) gets you to a simple code editor in the cloud where a very basic NativeScript + Vue.js template is pre-loaded for you.
1313

14+
> **TIP:** Head to [Sample Tasks for the Playground](/en/docs/getting-started/playground-tutorial) for ideas about how to get started in the Playground.
15+
1416
### Before you start
1517

1618
![](/screenshots/ns-playground/playground-home.png)
@@ -46,6 +48,8 @@ Just click a component from the **Components** panel and drag it to the code edi
4648
For most UI components to work, you need to drop them inside the `<Page>` block, preferably inside a layout component. Layouts tell your app how to position the UI components on the screen.
4749

4850
> **NOTE:** Right now, there's nothing stopping you from dropping the code at a place that will cause your app to crash or simply not load. In those cases, check the **Errors** and **Device Logs** tabs for more information.
51+
>
52+
> If the **Device Logs** tab shows `"NativeScript-Vue has "Vue.config.silent" set to true, to see output logs set it to false."`, go to `nativescript-vue` > `index.js`, hit `Ctrl+F` or `Cmd+F` and look for `Vue.config.silent = false;`. Set it to `true` to enable device logs.
4953
5054
### Check it out real-time
5155

@@ -55,6 +59,8 @@ After you place the code in a valid spot, hit **Preview** (or `Ctrl+S` or `Cmd+S
5559

5660
In some cases, when you interact with the app, it will close unexpectedly. Just fire it up again and inspect the crash report.
5761

62+
If at any point you stop seeing your changes applied on the device, click **QR code** and re-scan the QR code with the *Playground* app.
63+
5864
### Configure your code
5965

6066
So, the component runs and shows on your screen. You're excited but you want to make it your own. Hack away at the default code suggested by the Playground. Fix sizes and labels, remove or add elements.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Sample Tasks for the Playground
3+
contributors: [ikoevska]
4+
---
5+
6+
If you want to explore the [NativeScript Playground](https://play.nativescript.org?template=play-vue), you can start by creating a simple to-do app with the following requirements:
7+
8+
* Basic design
9+
* Two-tab layout
10+
* One tab shows active tasks and lets you add new tasks
11+
* Second tab lists completed tasks
12+
* (Coming soon) Basic functionality
13+
* (Coming soon) Add tasks: Users can add tasks as text
14+
* (Coming soon) View tasks
15+
* (Coming soon) Newly added tasks are listed as active and can be tapped
16+
* (Coming soon) Completed tasks are listed on a separate tab
17+
* (Coming soon) Complete tasks: Tapping an active task completes it and moves it to the other tab
18+
* (Coming soon) Delete tasks: Tapping an "X" button removes active or completed tasks
19+
* (Coming soon) Advanced functionality
20+
* (Coming soon) Schedule tasks: Users can set deadlines for tasks by picking a date from a calendar widget
21+
* (Coming soon) Manage tasks in bulk
22+
23+
> **TIP:** All sections of this tutorial contain a *Some NativeScript basics* and *Requirement implementation* sub-sections. You can skip the basics sub-section and jump straight to the implementation for a more hands-on approach.
24+
25+
## The bare Vue.js template
26+
27+
![](/screenshots/ns-playground/playground-home.png)
28+
29+
All development effort for this tutorial happens in `app.js` and `app.css`, containing the app functionality and taking care of the app styles, respectively.
30+
31+
The `app.js` for your newly created Vue.js project consists of a simple `template` declaration without any functionality. As you drag and drop user interface components to the app, the Playground also adds a `methods` block and populates it with code containing actual app functionality.
32+
33+
In `app.js`, you'll be working in the `template` block to design the user interface or in the `methods` block to build the app functionality. The `template` block requires NativeScript-compatible XML. The `methods` block accepts both Vue.js and NativeScript JavaScript code.
34+
35+
## Basic design
36+
37+
### Section progress
38+
39+
Here's how your app will look at the start and at the end of this section.
40+
41+
| Initial screen | Tab 1 | Tab 2 |
42+
|-------|-----|-----|
43+
| ![Bare Vue.js template](/screenshots/ns-playground/two-tabs-start.jpg) | ![First tab](/screenshots/ns-playground/two-tabs-tab-1.jpg) | ![Second tab](/screenshots/ns-playground/two-tabs-tab-2.jpg) |
44+
45+
### Some NativeScript basics
46+
47+
The `<Page>` element is the top-level user interface element of every NativeScript+Vue.js app. All other user interface elements are nested within.
48+
49+
The `<ActionBar>` element shows an action bar for the `<Page>`. A `<Page>` cannot contain more than one `<ActionBar>`.
50+
51+
Typically, after the `<ActionBar>`, you will have navigation components (such as a drawer or a tab view) or layout components. These elements control the layout of your app and let you determine how to place other user interface elements inside.
52+
53+
### Requirement implementation
54+
55+
Use the `<TabView>` component to create a two-tab app.
56+
57+
1. Remove the default `<ScrollView>` block and all its contents that come with the template.<br/>`<ScrollView>` components are top-level layout containers for scrollable content.
58+
1. Drag and drop the `<TabView>` component in its place.<br/>The Playground doesn't apply code formatting and doesn't take care of indentation when inserting new components.
59+
1. Configure the height of the `<TabView>` to fill the screen (set it to 100%).<br/>On an iOS device the default height setting causes the tabs to show somewhere around the middle of the screen.
60+
1. Change the titles of the `<TabViewItem>` elements and their contents to reflect their purpose.<br/>At this point, text content for the tabs is shown in `<Label>` components with no styling and formatting. Apply the `textWrap="true"` property to the respective `<Label>` components to improve the visualization of the text.
61+
62+
```JavaScript
63+
new Vue({
64+
65+
template: `
66+
<Page class="page">
67+
<ActionBar title="My Tasks" class="action-bar" />
68+
69+
<TabView height="100%">
70+
<TabViewItem title="To Do">
71+
<Label text="This tab will list active tasks and will let users add new tasks." textWrap="true" />
72+
</TabViewItem>
73+
<TabViewItem title="Completed">
74+
<Label text="This tab will list completed tasks for tracking." textWrap="true" />
75+
</TabViewItem>
76+
</TabView>
77+
78+
</Page>
79+
`,
80+
81+
}).$start();
82+
```
Loading
Loading
Loading

0 commit comments

Comments
 (0)