FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: added missing openFile method in ios utils by vakrilov · Pull Request #7431 · NativeScript/NativeScript · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
35 changes: 22 additions & 13 deletions tns-core-modules/utils/utils.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,9 @@ export module ios {
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;

export function openFile(filePath: string): boolean {
try {
const appPath = getCurrentAppPath();
const path = filePath.replace("~", appPath);
console.log("utils.ios.openFile() is deprecated; use utils.openFile() instead");

const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();

return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}

return false;
return openFileAtRootModule(filePath);
}

export function getCurrentAppPath(): string {
Expand Down Expand Up @@ -146,6 +135,26 @@ export module ios {

}

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 = new UIDocumentInteractionControllerDelegateImpl();

return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}

return false;
}

// Need this so that we can use this function inside the ios module (avoid name clashing).
const openFileAtRootModule = openFile;

export function GC() {
__collect();
}
Expand Down

Back | FazBrowse Home | New Git URL