|
| 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 | + |
| 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 | +|  |  |  | |
| 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 | +``` |
0 commit comments