Fixed #727: Provide a way to get a reference to the currently showing modal page instance.

This commit is contained in:
Rossen Hristov
2015-10-21 11:54:09 +03:00
parent e8332854f7
commit 8dc0e810e8
7 changed files with 33 additions and 4 deletions

View File

@@ -44,6 +44,8 @@ export class Page extends ContentView implements dts.Page {
private _styleScope: styleScope.StyleScope = new styleScope.StyleScope();
private _actionBar: ActionBar;
private _modal: Page;
constructor(options?: dts.Options) {
super(options);
this.actionBar = new ActionBar();
@@ -217,6 +219,10 @@ export class Page extends ContentView implements dts.Page {
}
}
public get modal(): Page {
return this._modal;
}
public _addChildFromBuilder(name: string, value: any) {
if (value instanceof ActionBar) {
this.actionBar = value;
@@ -227,6 +233,7 @@ export class Page extends ContentView implements dts.Page {
}
protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) {
parent._modal = this;
var that = this;
this._closeModalCallback = function () {
if (that._closeModalCallback) {
@@ -240,7 +247,7 @@ export class Page extends ContentView implements dts.Page {
}
protected _hideNativeModalView(parent: Page) {
//
parent._modal = undefined;
}
protected _raiseShownModallyEvent(parent: Page, context: any, closeCallback: Function) {

View File

@@ -137,6 +137,8 @@ export class Page extends pageCommon.Page {
this.onUnloaded();
this._isAddedToNativeVisualTree = false;
this._onDetached(true);
super._hideNativeModalView(parent);
}
public _updateActionBar(hidden: boolean) {

7
ui/page/page.d.ts vendored
View File

@@ -173,9 +173,14 @@ declare module "ui/page" {
showModal();
/**
* Closes the current modal dialog that this page is showing.
* Closes the current modal view that this page is showing.
*/
closeModal();
/**
* Returns the current modal view that this page is showing (is parent of), if any.
*/
modal: Page;
//@private

View File

@@ -226,6 +226,8 @@ export class Page extends pageCommon.Page {
this._UIModalPresentationFormSheet = false;
parent.requestLayout();
parent._ios.dismissModalViewControllerAnimated(false);
super._hideNativeModalView(parent);
}
public _updateActionBar(hidden: boolean) {