vinzscam / react-native-file-viewer

Native file viewer for React Native. Preview any type of file supported by the mobile device.
MIT License
434 stars 102 forks source link

Fileview.close() #133

Open my-name-is-nheo opened 2 years ago

my-name-is-nheo commented 2 years ago

Is there a way we can trigger the close button on iOS when doing a swipe? Seems like android is behaving as expected, but not so on IOS

jliuhtonen commented 2 years ago

It would be nice to have an option to programmatically dismiss the Quicklook overlay. If the API needs to be backwards compatible, then one way to do it would be to enable using AbortController API and to provide a signal option to the .open() function in a similar fashion that Fetch API works in JS.

Muzamil544 commented 3 months ago

Hello every one i have done this functionality on iOS, you can close the fileViewer any time you want by using following steps.

  1. Add this method in file node_modules->react-native-file-viewer->ios->RNFileViewerManager.m RCT_EXPORT_METHOD(close) { dispatch_async(dispatch_get_main_queue(), ^{ [[RNFileViewer topViewController] dismissViewControllerAnimated:true completion:nil]; }); }

  2. now add this method in node_modules->react-native-file-viewer->index.js function close() { if (Platform.OS == "ios") { return RNFileViewer.close(); } }

  3. after adding method now navigate to the bottom of index.js, change the export lines from export default { open }; export { open }; to-> this export default { open, close }; export { open, close };

  4. now navigate to node_modules->react-native-file-viewer->index.d.ts and add the following: declare function close() and in this file change this line declare namespace _default { export { open }; } like this declare namespace _default { export { open, close }; }

  5. now you can use this function like this FileViewer.close()

MuhammadBilal164 commented 3 months ago

Thanks... My issue is resolved now @Muzamil544