mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: expose orientation to application module (#7832)
This commit is contained in:
committed by
Manol Donev
parent
25046c7f94
commit
4166e2d966
@@ -21,3 +21,7 @@ export function testDisplayedEvent() {
|
|||||||
// global.isDisplayedEventFired flag is set in app.ts application.displayedEvent handler
|
// global.isDisplayedEventFired flag is set in app.ts application.displayedEvent handler
|
||||||
TKUnit.assert((<any>global).isDisplayedEventFired, "application.displayedEvent not fired");
|
TKUnit.assert((<any>global).isDisplayedEventFired, "application.displayedEvent not fired");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function testOrientation() {
|
||||||
|
TKUnit.assert(app.orientation, "Orientation not initialized.");
|
||||||
|
}
|
||||||
|
|||||||
@@ -248,6 +248,10 @@ export function getNativeApplication(): android.app.Application {
|
|||||||
return nativeApp;
|
return nativeApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function orientation(): "portrait" | "landscape" | "unknown" {
|
||||||
|
return androidApp.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
|
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
|
||||||
const rootView = getRootView();
|
const rootView = getRootView();
|
||||||
if (rootView) {
|
if (rootView) {
|
||||||
|
|||||||
@@ -285,6 +285,12 @@ export function on(event: "discardedError", callback: (args: DiscardedErrorEvent
|
|||||||
*/
|
*/
|
||||||
export function on(event: "orientationChanged", callback: (args: OrientationChangedEventData) => void, thisArg?: any);
|
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.
|
* This is the Android-specific application object instance.
|
||||||
* Encapsulates methods and properties specific to the Android platform.
|
* Encapsulates methods and properties specific to the Android platform.
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ const Responder = (<any>UIResponder).extend({
|
|||||||
// NOOP
|
// NOOP
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
protocols: [UIApplicationDelegate]
|
protocols: [UIApplicationDelegate]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
class NotificationObserver extends NSObject {
|
class NotificationObserver extends NSObject {
|
||||||
@@ -415,6 +415,10 @@ function setViewControllerView(view: View): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function orientation(): "portrait" | "landscape" | "unknown" {
|
||||||
|
return iosApp.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
|
on(orientationChangedEvent, (args: OrientationChangedEventData) => {
|
||||||
const rootView = getRootView();
|
const rootView = getRootView();
|
||||||
if (rootView) {
|
if (rootView) {
|
||||||
|
|||||||
Reference in New Issue
Block a user