fix: expose orientation to application module (#7832)

This commit is contained in:
Vasil Chimev
2019-09-19 18:49:07 +03:00
committed by Manol Donev
parent 25046c7f94
commit 4166e2d966
4 changed files with 20 additions and 2 deletions

View File

@@ -21,3 +21,7 @@ export function testDisplayedEvent() {
// global.isDisplayedEventFired flag is set in app.ts application.displayedEvent handler
TKUnit.assert((<any>global).isDisplayedEventFired, "application.displayedEvent not fired");
}
export function testOrientation() {
TKUnit.assert(app.orientation, "Orientation not initialized.");
}

View File

@@ -248,6 +248,10 @@ export function getNativeApplication(): android.app.Application {
return nativeApp;
}
export function orientation(): "portrait" | "landscape" | "unknown" {
return androidApp.orientation;
}
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
const rootView = getRootView();
if (rootView) {

View File

@@ -285,6 +285,12 @@ export function on(event: "discardedError", callback: (args: DiscardedErrorEvent
*/
export function on(event: "orientationChanged", callback: (args: OrientationChangedEventData) => void, thisArg?: any);
/**
* Gets the orientation of the application.
* Available values: "portrait", "landscape", "unknown".
*/
export function orientation(): "portrait" | "landscape" | "unknown";
/**
* This is the Android-specific application object instance.
* Encapsulates methods and properties specific to the Android platform.

View File

@@ -415,6 +415,10 @@ function setViewControllerView(view: View): void {
}
}
export function orientation(): "portrait" | "landscape" | "unknown" {
return iosApp.orientation;
}
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
const rootView = getRootView();
if (rootView) {