2
2
// Use of this source code is governed by a MIT-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- import {
6
- NativeModules ,
7
- DeviceEventEmitter ,
8
- Platform ,
9
- NativeAppEventEmitter ,
10
- } from 'react-native'
5
+ import { NativeModules , Platform } from "react-native" ;
11
6
12
- const RNFetchBlob :RNFetchBlobNative = NativeModules . RNFetchBlob
7
+ const RNFetchBlob : RNFetchBlobNative = NativeModules . RNFetchBlob ;
13
8
14
9
/**
15
- * Open a file using UIDocumentInteractionController
10
+ * Displays an options menu using UIDocumentInteractionController.presentOptionsMenu
16
11
* @param {string } path Path of the file to be open.
17
12
* @param {string } scheme URI scheme that needs to support, optional
18
13
* @return {Promise }
19
14
*/
20
- function previewDocument ( path :string , scheme :string ) {
21
- if ( Platform . OS === 'ios' )
22
- return RNFetchBlob . previewDocument ( 'file://' + path , scheme )
23
- else
24
- return Promise . reject ( 'RNFetchBlob.openDocument only supports IOS.' )
15
+ function presentOptionsMenu ( path : string , scheme : string ) {
16
+ if ( Platform . OS === "ios" )
17
+ return RNFetchBlob . presentOptionsMenu ( "file://" + path , scheme ) ;
18
+ else return Promise . reject ( "RNFetchBlob.openDocument only supports IOS." ) ;
25
19
}
26
20
27
21
/**
28
- * Preview a file using UIDocumentInteractionController
22
+ * Displays a menu for opening the document using UIDocumentInteractionController.presentOpenInMenu
29
23
* @param {string } path Path of the file to be open.
30
24
* @param {string } scheme URI scheme that needs to support, optional
31
25
* @return {Promise }
32
26
*/
33
- function openDocument ( path :string , scheme :string ) {
34
- if ( Platform . OS === 'ios' )
35
- return RNFetchBlob . openDocument ( 'file://' + path , scheme )
36
- else
37
- return Promise . reject ( 'RNFetchBlob.previewDocument only supports IOS.' )
27
+ function presentOpenInMenu ( path : string , scheme : string ) {
28
+ if ( Platform . OS === "ios" )
29
+ return RNFetchBlob . presentOpenInMenu ( "file://" + path , scheme ) ;
30
+ else return Promise . reject ( "RNFetchBlob.openDocument only supports IOS." ) ;
31
+ }
32
+
33
+ /**
34
+ * Displays a full-screen preview of the target document using UIDocumentInteractionController.presentPreview
35
+ * @param {string } path Path of the file to be open.
36
+ * @param {string } scheme URI scheme that needs to support, optional
37
+ * @return {Promise }
38
+ */
39
+ function presentPreview ( path : string , scheme : string ) {
40
+ if ( Platform . OS === "ios" )
41
+ return RNFetchBlob . presentPreview ( "file://" + path , scheme ) ;
42
+ else return Promise . reject ( "RNFetchBlob.previewDocument only supports IOS." ) ;
38
43
}
39
44
40
45
/**
@@ -43,12 +48,15 @@ function openDocument(path:string, scheme:string) {
43
48
* @param {string } url URL of the resource, only file URL is supported
44
49
* @return {Promise }
45
50
*/
46
- function excludeFromBackupKey ( path :string ) {
47
- return RNFetchBlob . excludeFromBackupKey ( ' file://' + path ) ;
51
+ function excludeFromBackupKey ( path : string ) {
52
+ return RNFetchBlob . excludeFromBackupKey ( " file://" + path ) ;
48
53
}
49
54
50
55
export default {
51
- openDocument,
52
- previewDocument,
56
+ presentPreview,
57
+ openDocument : presentPreview , // legacy alias
58
+ presentOptionsMenu,
59
+ previewDocument : presentOptionsMenu , // legacy alias
60
+ presentOpenInMenu,
53
61
excludeFromBackupKey
54
- }
62
+ } ;
0 commit comments