Skip to content

Commit 9eb341b

Browse files
authored
adding backStackEntry example, including missing import md file text field (NativeScript#5319)
1 parent b492996 commit 9eb341b

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

tests/app/ui/frame/frame.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,33 @@ To perform navigation, you will need a reference to the topmost frame of the app
2020

2121
### Navigating Back
2222
{%snippet frame-back%}
23+
24+
### Back Navigation with BackstackEntry
25+
Using the `BackstackEntry` allows us to navigate back to a specific page.
26+
27+
```XML
28+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
29+
30+
<Page.actionBar>
31+
<ActionBar title="Page 5" icon="" class="action-bar">
32+
</ActionBar>
33+
</Page.actionBar>
34+
35+
<StackLayout class="p-20">
36+
<Label text="Page 5" class="h1 text-center"/>
37+
<Button text="back to the first page" tap="onTap" class="btn btn-primary btn-active"/>
38+
</StackLayout>
39+
</Page>
40+
```
41+
```TypeScript
42+
import {BackstackEntry, Frame} from "ui/frame"
43+
44+
export function backNavigation(args){
45+
const backstackEntryFirstPage = args.object.page.frame.backStack[0];
46+
const frame = args.object.page.frame;
47+
frame.goBack(backstackEntryFirstPage);
48+
}
49+
```
50+
With the help of the Frame we access the page's BackstackEntry by providing the the sequence number - `backStack[<page number>]`. In the example above we will navigate back to the initial page and to do that we need to take the first BackstackEntry as follow: `topmost().backStack[0]`
51+
52+
> NB: We start counting the pages from 0. If we need to take the entry for the first page we need to take the it while using the 0 index, for the second 1 index, etc.

tests/app/ui/text-field/text-field-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { Span } from "tns-core-modules/text/span";
1616
import { TextField } from "tns-core-modules/ui/text-field";
1717
// << require-textfield
1818
// Other frequently used modules when working with buttons include:
19-
19+
// >> require-observable-binding-options-textfield
2020
import { BindingOptions } from "tns-core-modules/ui/core/bindable";
21-
// >> require-observable-textfield
21+
2222
import { Observable } from "tns-core-modules/data/observable";
23-
// << require-observable-textfield
23+
// << require-observable-binding-options-textfield
2424

2525
// ### Binding two TextFields text property to observable view-model property.
2626
// >> binding-text-property-textfield

tests/app/ui/text-field/text-field.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Using a TextField requires the text-field module.
1313
{%raw%}<TextField text="{{ someProperty }}" />
1414
<TextField text="{{ someProperty }}" />{%endraw%}
1515
```
16-
{%snippet binding-text-property-textfield%}
16+
{%snippet require-observable-binding-options-textfield%}
1717
## Creating a TextField
1818
{%snippet creating-textfield%}
1919
### Setting the text of a TextField

0 commit comments

Comments
 (0)