mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Resolved Issue #1021: The navigatedTo event is called twice for the first application page.
This commit is contained in:
@ -5,20 +5,18 @@ import tests = require("../testRunner");
|
|||||||
trace.enable();
|
trace.enable();
|
||||||
trace.addCategories(trace.categories.Test + "," + trace.categories.Error);
|
trace.addCategories(trace.categories.Test + "," + trace.categories.Error);
|
||||||
|
|
||||||
let started = false;
|
|
||||||
let page = new Page();
|
let page = new Page();
|
||||||
page.id = "mainPage";
|
page.id = "mainPage";
|
||||||
|
|
||||||
page.on(Page.navigatedToEvent, function () {
|
page.on(Page.navigatedToEvent, onNavigatedTo);
|
||||||
if (!started) {
|
|
||||||
started = true;
|
|
||||||
setTimeout(function () {
|
|
||||||
tests.runAll();
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
function onNavigatedTo(args) {
|
||||||
|
args.object.off(Page.navigatedToEvent, onNavigatedTo);
|
||||||
|
setTimeout(function () {
|
||||||
|
tests.runAll();
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
}
|
||||||
export function createPage() {
|
export function createPage() {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
@ -356,6 +356,7 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
|
|||||||
}
|
}
|
||||||
|
|
||||||
public navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
|
public navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
|
||||||
|
trace.write(`UINavigationControllerImpl.navigationControllerWillShowViewControllerAnimated(${navigationController}, ${viewController}, ${animated})`, trace.categories.NativeLifecycle);
|
||||||
// In this method we need to layout the new page otherwise page will be shown empty and update after that which is bad UX.
|
// In this method we need to layout the new page otherwise page will be shown empty and update after that which is bad UX.
|
||||||
let frame = this._owner.get();
|
let frame = this._owner.get();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
@ -381,9 +382,22 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
|
|||||||
}
|
}
|
||||||
|
|
||||||
newPage.actionBar.update();
|
newPage.actionBar.update();
|
||||||
|
|
||||||
|
//HACK: https://github.com/NativeScript/NativeScript/issues/1021
|
||||||
|
viewController["willShowCalled"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
|
public navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
|
||||||
|
trace.write(`UINavigationControllerImpl.navigationControllerDidShowViewControllerAnimated(${navigationController}, ${viewController}, ${animated})`, trace.categories.NativeLifecycle);
|
||||||
|
|
||||||
|
//HACK: https://github.com/NativeScript/NativeScript/issues/1021
|
||||||
|
if (viewController["willShowCalled"] === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
viewController["willShowCalled"] = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
let frame = this._owner.get();
|
let frame = this._owner.get();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user