UNPKG

2.22 kBJavaScriptView Raw
1import { Trace } from '../trace';
2import { ios as iOSUtils } from './native-helper';
3export { clearInterval, clearTimeout, setInterval, setTimeout } from '../timer';
4export * from './common';
5export * from './constants';
6export * from './debug';
7export * from './layout-helper';
8export * from './macrotask-scheduler';
9export * from './mainthread-helper';
10export * from './native-helper';
11export * from './types';
12export function openFile(filePath) {
13 try {
14 const appPath = iOSUtils.getCurrentAppPath();
15 const path = iOSUtils.isRealDevice() ? filePath.replace('~', appPath) : filePath;
16 const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
17 controller.delegate = iOSUtils.createUIDocumentInteractionControllerDelegate();
18 return controller.presentPreviewAnimated(true);
19 }
20 catch (e) {
21 Trace.write('Error in openFile', Trace.categories.Error, Trace.messageType.error);
22 }
23 return false;
24}
25export function GC() {
26 __collect();
27}
28export function releaseNativeObject(object) {
29 __releaseNativeCounterpart(object);
30}
31export function openUrl(location) {
32 try {
33 const url = NSURL.URLWithString(location.trim());
34 if (UIApplication.sharedApplication.canOpenURL(url)) {
35 return UIApplication.sharedApplication.openURL(url);
36 }
37 }
38 catch (e) {
39 // We Don't do anything with an error. We just output it
40 Trace.write('Error in OpenURL', Trace.categories.Error, Trace.messageType.error);
41 }
42 return false;
43}
44export function isRealDevice() {
45 return iOSUtils.isRealDevice();
46}
47export const ad = 0;
48export function dismissSoftInput(nativeView) {
49 if (nativeView instanceof UIView && !nativeView.isFirstResponder) {
50 return;
51 }
52 UIApplication.sharedApplication.sendActionToFromForEvent('resignFirstResponder', null, null, null);
53}
54export function dismissKeyboard() {
55 dismissSoftInput();
56}
57export function copyToClipboard(value) {
58 try {
59 UIPasteboard.generalPasteboard.setValueForPasteboardType(value, kUTTypePlainText);
60 }
61 catch (err) {
62 console.log(err);
63 }
64}
65//# sourceMappingURL=index.ios.js.map
\No newline at end of file