1 | import { Trace } from '../trace';
|
2 | import { ios as iOSUtils } from './native-helper';
|
3 | export { clearInterval, clearTimeout, setInterval, setTimeout } from '../timer';
|
4 | export * from './common';
|
5 | export * from './constants';
|
6 | export * from './debug';
|
7 | export * from './layout-helper';
|
8 | export * from './macrotask-scheduler';
|
9 | export * from './mainthread-helper';
|
10 | export * from './native-helper';
|
11 | export * from './types';
|
12 | export 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 | }
|
25 | export function GC() {
|
26 | __collect();
|
27 | }
|
28 | export function releaseNativeObject(object) {
|
29 | __releaseNativeCounterpart(object);
|
30 | }
|
31 | export 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 |
|
40 | Trace.write('Error in OpenURL', Trace.categories.Error, Trace.messageType.error);
|
41 | }
|
42 | return false;
|
43 | }
|
44 | export function isRealDevice() {
|
45 | return iOSUtils.isRealDevice();
|
46 | }
|
47 | export const ad = 0;
|
48 | export function dismissSoftInput(nativeView) {
|
49 | if (nativeView instanceof UIView && !nativeView.isFirstResponder) {
|
50 | return;
|
51 | }
|
52 | UIApplication.sharedApplication.sendActionToFromForEvent('resignFirstResponder', null, null, null);
|
53 | }
|
54 | export function dismissKeyboard() {
|
55 | dismissSoftInput();
|
56 | }
|
57 | export function copyToClipboard(value) {
|
58 | try {
|
59 | UIPasteboard.generalPasteboard.setValueForPasteboardType(value, kUTTypePlainText);
|
60 | }
|
61 | catch (err) {
|
62 | console.log(err);
|
63 | }
|
64 | }
|
65 |
|
\ | No newline at end of file |