Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork158
[WIP] docs(navigation): initial rewrite of Navigation docs (#330)#331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
rigor789 wants to merge1 commit intov2Choose a base branch fromrigor789/navigation
base:v2
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 5 additions & 1 deletionbuild/plugins/remark.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletionscontent/docs/en/routing/navigation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: Navigation | ||
contributors: [rigor789] | ||
--- | ||
Most apps are made of multiple screens the users can interact with. In order to present these different screens to the user, we need a way to navigate between them. NativeScript-Vue provides the following methods to achieve this: | ||
* [`$navigateTo`](#) | ||
* [`$navigateBack`](#) | ||
* [`$showModal`](#) | ||
In NativeScript-Vue different screens are denoted by the [`<Page>`](#) tag. | ||
// todo: emphasize early on that `<Page>` tags are mandatory | ||
## A basic scenario: navigating to a different `<Page>` | ||
Let's say the user is presented with the default `<Page>` in our `Home.vue` component and we would like to navigate to a component we defined in `Settings.vue`: | ||
```vue | ||
<template> | ||
<Page> | ||
<ActionBar title="Settings" /> | ||
<StackLayout> | ||
<!-- page content goes here --> | ||
</StackLayout> | ||
</Page> | ||
</template> | ||
``` | ||
In our Home component, we first need to import the `<Settings>` component. Most navigation is triggered by the user, in this case we will attach a `@tap` handler to a `<Button>` and call our navigation in the handler. | ||
```vue | ||
<template> | ||
<Page> | ||
<ActionBar title="Home" /> | ||
<StackLayout> | ||
<Button text="Go to Settings" @tap="onSettingsTap" /> | ||
<!-- page content goes here --> | ||
</StackLayout> | ||
</Page> | ||
</template> | ||
<script> | ||
import Settings from './Settings' | ||
export default { | ||
methods: { | ||
onSettingsTap() { | ||
this.$navigateTo(Settings) | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
[You can try this example in the Playground](https://play.nativescript.org/?template=play-vue&id=Gsxbge) | ||
// todo: incorporate $navigateBack into the basic guide | ||
## A basic scenario: showing a modal `<Page>` | ||
Often times, we need to present the user with data that doesn't fit in the navigation flow. In these cases we can show a `<Page>` in a modal, completely independent of the current navigation history. | ||
// todo: create example and walkthrough | ||
# Troubleshooting | ||
// todo | ||
```js | ||
this.$navigateTo(Component).catch(error => console.log(error)) | ||
``` | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.