Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1793 from NativeScript/hhristov/navigation-events
Fix navigation events #1570
- Loading branch information
Showing
19 changed files
with
408 additions
and
236 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,2 @@ | ||
import application = require("application"); | ||
application.start({ moduleName: "page1" }); |
This file contains 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,4 @@ | ||
{ | ||
"name": "navigation-events-demo", | ||
"main": "app.js" | ||
} |
This file contains 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,38 @@ | ||
import {Frame, topmost} from "ui/frame"; | ||
|
||
export function loaded(args) { | ||
console.log("+++Page 1 - LOADED"); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function unloaded(args) { | ||
console.log("+++Page 1 - UNLOADED"); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatingTo(args) { | ||
console.log(`+++Page 1 - navigatingTo(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatedTo(args) { | ||
console.log(`+++Page 1 - navigatedTo(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatingFrom(args) { | ||
console.log(`+++Page 1 - navigatingFrom(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatedFrom(args) { | ||
console.log(`+++Page 1 - navigatedFrom(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function onTap(args) { | ||
let frame: Frame = args.object.page.frame; | ||
frame.navigate({ | ||
moduleName: "page2" | ||
}); | ||
} |
This file contains 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,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" | ||
loaded="loaded" | ||
unloaded="unloaded" | ||
navigatingFrom="navigatingFrom" | ||
navigatingTo="navigatingTo" | ||
navigatedFrom="navigatedFrom" | ||
navigatedTo="navigatedTo"> | ||
<Button text="Navigate forward" tap="onTap" /> | ||
</Page> |
This file contains 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,36 @@ | ||
import {Frame, topmost} from "ui/frame"; | ||
|
||
export function loaded(args) { | ||
console.log("+++Page 2 - LOADED"); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function unloaded(args) { | ||
console.log("+++Page 2 - UNLOADED"); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatingTo(args) { | ||
console.log(`+++Page 2 - navigatingTo(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatedTo(args) { | ||
console.log(`+++Page 2 - navigatedTo(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatingFrom(args) { | ||
console.log(`+++Page 2 - navigatingFrom(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function navigatedFrom(args) { | ||
console.log(`+++Page 2 - navigatedFrom(isBack: ${args.isBackNavigation})`); | ||
console.log(`backStack.length=${topmost().backStack.length}`); | ||
} | ||
|
||
export function onTap(args) { | ||
let frame: Frame = args.object.page.frame; | ||
frame.goBack(); | ||
} |
This file contains 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,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" | ||
loaded="loaded" | ||
unloaded="unloaded" | ||
navigatingFrom="navigatingFrom" | ||
navigatingTo="navigatingTo" | ||
navigatedFrom="navigatedFrom" | ||
navigatedTo="navigatedTo"> | ||
<Button text="Navigate back" tap="onTap" /> | ||
</Page> |
This file contains 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import {ShownModallyData} from "ui/page"; | ||
import {topmost} from "ui/frame"; | ||
import TKUnit = require("../../TKUnit"); | ||
import frame = require("ui/frame"); | ||
import page = require("ui/page"); | ||
|
||
var modalPage: page.Page; | ||
import {Page, ShownModallyData} from "ui/page"; | ||
|
||
export var modalPage: Page; | ||
export function onShowingModally(args) { | ||
modalPage = <page.Page>args.object; | ||
modalPage = <Page>args.object; | ||
args.object.showingModally = true; | ||
} | ||
|
||
export function onShownModally(args: ShownModallyData) { | ||
TKUnit.assertNotNull(modalPage); | ||
TKUnit.wait(0.100); | ||
let page = <Page>args.object; | ||
TKUnit.assertNotNull(page); | ||
if (args.context) { | ||
args.context.shownModally = true; | ||
} | ||
TKUnit.assert(frame.topmost().currentPage.modal = modalPage, "frame.topmost().currentPage.modal should be equal to the page instance on page.shownModally event handler."); | ||
|
||
TKUnit.assertEqual(topmost().currentPage.modal, page, "frame.topmost().currentPage.modal should be equal to the page instance on page.shownModally event handler."); | ||
args.closeCallback("return value"); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.