feat: expose application orientation (#7602)

This commit is contained in:
Vasil Chimev
2019-08-14 13:47:15 +03:00
committed by GitHub
parent a14bc9f86d
commit e2c3c8c084
15 changed files with 161 additions and 155 deletions

View File

@@ -215,6 +215,8 @@ export module ios {
}
/**
* @deprecated use application.orientation instead
*
* Gets an information about if current mode is Landscape.
*/
export function isLandscape(): boolean;

View File

@@ -8,7 +8,8 @@ export * from "./utils-common";
let mainScreenScale;
function isOrientationLandscape(orientation: number) {
return orientation === UIDeviceOrientation.LandscapeLeft || orientation === UIDeviceOrientation.LandscapeRight;
return orientation === UIDeviceOrientation.LandscapeLeft /* 3 */ ||
orientation === UIDeviceOrientation.LandscapeRight /* 4 */;
}
export module layout {
@@ -79,11 +80,15 @@ export module ios {
}
export function isLandscape(): boolean {
const device = UIDevice.currentDevice;
console.log("utils.ios.isLandscape() is deprecated; use application.orientation instead");
const deviceOrientation = UIDevice.currentDevice.orientation;
const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
const isDeviceOrientationLandscape = isOrientationLandscape(deviceOrientation);
const isStatusBarOrientationLandscape = isOrientationLandscape(statusBarOrientation);
return isOrientationLandscape(device.orientation) || isStatusBarOrientationLandscape;
return isDeviceOrientationLandscape || isStatusBarOrientationLandscape;
}
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
@@ -153,7 +158,7 @@ export function openFile(filePath: string): boolean {
}
// Need this so that we can use this function inside the ios module (avoid name clashing).
const openFileAtRootModule = openFile;
const openFileAtRootModule = openFile;
export function GC() {
__collect();