Files
Martin Yankov 0ffc790d82 chore: remove critical circular dependencies (#8114)
* chore: remove critical circular dependencies

* chore: fix tslint errors

* chore: remove platform specific types from interfaces

* chore: update unit tests polyfills

* fix: incorrect null check

* chore: update api.md file

* test: improve test case

* chore: apply comments

* test: avoid page style leaks in tests
2019-11-28 13:36:34 +02:00

52 lines
1.4 KiB
TypeScript

import { ios } from "./native-helper";
import {
write as traceWrite, categories as traceCategories, messageType as traceMessageType
} from "../trace";
export { ios };
export * from "./utils-common";
let mainScreenScale;
export function openFile(filePath: string): boolean {
try {
const appPath = ios.getCurrentAppPath();
const path = filePath.replace("~", appPath);
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = <UIDocumentInteractionControllerDelegate> new ios.UIDocumentInteractionControllerDelegateImpl();
return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}
return false;
}
export function GC() {
__collect();
}
export function releaseNativeObject(object: NSObject) {
__releaseNativeCounterpart(object);
}
export function openUrl(location: string): boolean {
try {
const url = NSURL.URLWithString(location.trim());
if (UIApplication.sharedApplication.canOpenURL(url)) {
return UIApplication.sharedApplication.openURL(url);
}
}
catch (e) {
// We Don't do anything with an error. We just output it
traceWrite("Error in OpenURL", traceCategories.Error, traceMessageType.error);
}
return false;
}
mainScreenScale = UIScreen.mainScreen.scale;