8
8
*
9
9
* @providesModule ActionSheetIOS
10
10
* @flow
11
+ * @format
11
12
*/
12
13
'use strict' ;
13
14
14
- var RCTActionSheetManager = require ( 'NativeModules' ) . ActionSheetManager ;
15
+ const RCTActionSheetManager = require ( 'NativeModules' ) . ActionSheetManager ;
15
16
16
- var invariant = require ( 'fbjs/lib/invariant' ) ;
17
- var processColor = require ( 'processColor' ) ;
17
+ const invariant = require ( 'fbjs/lib/invariant' ) ;
18
+ const processColor = require ( 'processColor' ) ;
18
19
19
20
/**
20
21
* Display action sheets and share sheets on iOS.
21
- *
22
+ *
22
23
* See http://facebook.github.io/react-native/docs/actionsheetios.html
23
24
*/
24
- var ActionSheetIOS = {
25
+ const ActionSheetIOS = {
25
26
/**
26
27
* Display an iOS action sheet.
27
- *
28
+ *
28
29
* The `options` object must contain one or more of:
29
- *
30
+ *
30
31
* - `options` (array of strings) - a list of button titles (required)
31
32
* - `cancelButtonIndex` (int) - index of cancel button in `options`
32
33
* - `destructiveButtonIndex` (int) - index of destructive button in `options`
33
34
* - `title` (string) - a title to show above the action sheet
34
35
* - `message` (string) - a message to show below the title
35
- *
36
+ *
36
37
* The 'callback' function takes one parameter, the zero-based index
37
38
* of the selected item.
38
- *
39
+ *
39
40
* See http://facebook.github.io/react-native/docs/actionsheetios.html#showactionsheetwithoptions
40
41
*/
41
- showActionSheetWithOptions ( options : Object , callback : Function ) {
42
+ showActionSheetWithOptions (
43
+ options : { |
44
+ + title ?: ?string ,
45
+ + message ?: ?string ,
46
+ + options : Array < string > ,
47
+ + destructiveButtonIndex ?: ?number ,
48
+ + cancelButtonIndex ?: ?number ,
49
+ + anchor ?: ?number ,
50
+ + tintColor ?: number | string ,
51
+ | } ,
52
+ callback : ( buttonIndex : number ) => void ,
53
+ ) {
42
54
invariant (
43
55
typeof options === 'object' && options !== null ,
44
- 'Options must be a valid object'
45
- ) ;
46
- invariant (
47
- typeof callback === 'function' ,
48
- 'Must provide a valid callback'
56
+ 'Options must be a valid object' ,
49
57
) ;
58
+ invariant ( typeof callback === 'function' , 'Must provide a valid callback' ) ;
59
+
50
60
RCTActionSheetManager . showActionSheetWithOptions (
51
61
{ ...options , tintColor : processColor ( options . tintColor ) } ,
52
- callback
62
+ callback ,
53
63
) ;
54
64
} ,
55
65
@@ -61,7 +71,7 @@ var ActionSheetIOS = {
61
71
* - `url` (string) - a URL to share
62
72
* - `message` (string) - a message to share
63
73
* - `subject` (string) - a subject for the message
64
- * - `excludedActivityTypes` (array) - the activities to exclude from
74
+ * - `excludedActivityTypes` (array) - the activities to exclude from
65
75
* the ActionSheet
66
76
* - `tintColor` (color) - tint color of the buttons
67
77
*
@@ -73,32 +83,32 @@ var ActionSheetIOS = {
73
83
*
74
84
* - a boolean value signifying success or failure
75
85
* - a string that, in the case of success, indicates the method of sharing
76
- *
86
+ *
77
87
* See http://facebook.github.io/react-native/docs/actionsheetios.html#showshareactionsheetwithoptions
78
88
*/
79
89
showShareActionSheetWithOptions (
80
90
options : Object ,
81
91
failureCallback : Function ,
82
- successCallback : Function
92
+ successCallback : Function ,
83
93
) {
84
94
invariant (
85
95
typeof options === 'object' && options !== null ,
86
- 'Options must be a valid object'
96
+ 'Options must be a valid object' ,
87
97
) ;
88
98
invariant (
89
99
typeof failureCallback === 'function' ,
90
- 'Must provide a valid failureCallback'
100
+ 'Must provide a valid failureCallback' ,
91
101
) ;
92
102
invariant (
93
103
typeof successCallback === 'function' ,
94
- 'Must provide a valid successCallback'
104
+ 'Must provide a valid successCallback' ,
95
105
) ;
96
106
RCTActionSheetManager . showShareActionSheetWithOptions (
97
107
{ ...options , tintColor : processColor ( options . tintColor ) } ,
98
108
failureCallback,
99
- successCallback
109
+ successCallback,
100
110
) ;
101
- }
111
+ } ,
102
112
} ;
103
113
104
114
module . exports = ActionSheetIOS ;
0 commit comments