mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Resolved Issue #1242: Add Page showingModally
event.
This commit is contained in:
@ -9,6 +9,15 @@ var page: pages.Page;
|
||||
var usernameTextField: textField.TextField;
|
||||
var passwordTextField: textField.TextField;
|
||||
|
||||
export function onShowingModally(args: observable.EventData) {
|
||||
console.log(">>> login-page.onShowingModally");
|
||||
var modalPage = <pages.Page>args.object;
|
||||
if (modalPage.ios && modalPage.ios.modalPresentationStyle === UIModalPresentationStyle.UIModalPresentationFullScreen) {
|
||||
console.log(">>> Setting modalPage.ios.modalPresentationStyle to UIModalPresentationStyle.UIModalPresentationOverFullScreen");
|
||||
modalPage.ios.modalPresentationStyle = UIModalPresentationStyle.UIModalPresentationOverFullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
export function onShownModally(args: pages.ShownModallyData) {
|
||||
console.log(">>> login-page.onShownModally, context: " + args.context);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
showingModally="onShowingModally"
|
||||
shownModally="onShownModally"
|
||||
navigatingTo="onNavigatingTo"
|
||||
loaded="onLoaded"
|
||||
|
@ -3,9 +3,15 @@ import TKUnit = require("../../TKUnit");
|
||||
import frame = require("ui/frame");
|
||||
import page = require("ui/page");
|
||||
|
||||
var modalPage: page.Page;
|
||||
|
||||
export function onShowingModally(args) {
|
||||
modalPage = <page.Page>args.object;
|
||||
}
|
||||
|
||||
export function onShownModally(args: ShownModallyData) {
|
||||
TKUnit.assertNotNull(modalPage);
|
||||
TKUnit.wait(0.100);
|
||||
var modalPage = <page.Page>args.object;
|
||||
if (args.context) {
|
||||
args.context.shownModally = true;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Page shownModally="onShownModally">
|
||||
<Page showingModally="onShowingModally" shownModally="onShownModally">
|
||||
<StackLayout>
|
||||
<Label text="Modal Page" />
|
||||
</StackLayout>
|
||||
|
@ -35,6 +35,7 @@ export class Page extends ContentView implements dts.Page {
|
||||
public static navigatingFromEvent = "navigatingFrom";
|
||||
public static navigatedFromEvent = "navigatedFrom";
|
||||
public static shownModallyEvent = "shownModally";
|
||||
public static showingModallyEvent = "showingModally";
|
||||
|
||||
protected _closeModalCallback: Function;
|
||||
|
||||
@ -251,6 +252,13 @@ export class Page extends ContentView implements dts.Page {
|
||||
});
|
||||
}
|
||||
|
||||
protected _raiseShowingModallyEvent() {
|
||||
this.notify({
|
||||
eventName: Page.showingModallyEvent,
|
||||
object: this
|
||||
});
|
||||
}
|
||||
|
||||
public _getStyleScope(): styleScope.StyleScope {
|
||||
return this._styleScope;
|
||||
}
|
||||
|
@ -125,8 +125,9 @@ export class Page extends pageCommon.Page {
|
||||
this._dialogFragment = new DialogFragmentClass(this, fullscreen, function () {
|
||||
that.closeModal();
|
||||
});
|
||||
this._dialogFragment.show(parent.frame.android.activity.getFragmentManager(), "dialog");
|
||||
|
||||
super._raiseShowingModallyEvent();
|
||||
this._dialogFragment.show(parent.frame.android.activity.getFragmentManager(), "dialog");
|
||||
super._raiseShownModallyEvent(parent, context, closeCallback);
|
||||
}
|
||||
|
||||
|
12
ui/page/page.d.ts
vendored
12
ui/page/page.d.ts
vendored
@ -61,6 +61,11 @@ declare module "ui/page" {
|
||||
*/
|
||||
public static actionBarHiddenProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* String value used when hooking to showingModally event.
|
||||
*/
|
||||
public static showingModallyEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to shownModally event.
|
||||
*/
|
||||
@ -159,7 +164,12 @@ declare module "ui/page" {
|
||||
on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when the page is shown as a modal dialog.
|
||||
* Raised before the page is shown as a modal dialog.
|
||||
*/
|
||||
on(event: "showingModally", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised after the page is shown as a modal dialog.
|
||||
*/
|
||||
on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any);
|
||||
|
||||
|
@ -241,6 +241,7 @@ export class Page extends pageCommon.Page {
|
||||
this._UIModalPresentationFormSheet = true;
|
||||
}
|
||||
|
||||
super._raiseShowingModallyEvent();
|
||||
var that = this;
|
||||
parent.ios.presentViewControllerAnimatedCompletion(this._ios, false, function completion() {
|
||||
that._raiseShownModallyEvent(parent, context, closeCallback);
|
||||
|
Reference in New Issue
Block a user