Skip to content

Commit 61d046b

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Flow Type ActionSheetIOS
Reviewed By: sahrens Differential Revision: D6548474 fbshipit-source-id: dac0cb2cdd85bc49d4302b4382142fd70ab4ecc4
1 parent 85503a0 commit 61d046b

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

Libraries/ActionSheetIOS/ActionSheetIOS.js

+34-24
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,58 @@
88
*
99
* @providesModule ActionSheetIOS
1010
* @flow
11+
* @format
1112
*/
1213
'use strict';
1314

14-
var RCTActionSheetManager = require('NativeModules').ActionSheetManager;
15+
const RCTActionSheetManager = require('NativeModules').ActionSheetManager;
1516

16-
var invariant = require('fbjs/lib/invariant');
17-
var processColor = require('processColor');
17+
const invariant = require('fbjs/lib/invariant');
18+
const processColor = require('processColor');
1819

1920
/**
2021
* Display action sheets and share sheets on iOS.
21-
*
22+
*
2223
* See http://facebook.github.io/react-native/docs/actionsheetios.html
2324
*/
24-
var ActionSheetIOS = {
25+
const ActionSheetIOS = {
2526
/**
2627
* Display an iOS action sheet.
27-
*
28+
*
2829
* The `options` object must contain one or more of:
29-
*
30+
*
3031
* - `options` (array of strings) - a list of button titles (required)
3132
* - `cancelButtonIndex` (int) - index of cancel button in `options`
3233
* - `destructiveButtonIndex` (int) - index of destructive button in `options`
3334
* - `title` (string) - a title to show above the action sheet
3435
* - `message` (string) - a message to show below the title
35-
*
36+
*
3637
* The 'callback' function takes one parameter, the zero-based index
3738
* of the selected item.
38-
*
39+
*
3940
* See http://facebook.github.io/react-native/docs/actionsheetios.html#showactionsheetwithoptions
4041
*/
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+
) {
4254
invariant(
4355
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',
4957
);
58+
invariant(typeof callback === 'function', 'Must provide a valid callback');
59+
5060
RCTActionSheetManager.showActionSheetWithOptions(
5161
{...options, tintColor: processColor(options.tintColor)},
52-
callback
62+
callback,
5363
);
5464
},
5565

@@ -61,7 +71,7 @@ var ActionSheetIOS = {
6171
* - `url` (string) - a URL to share
6272
* - `message` (string) - a message to share
6373
* - `subject` (string) - a subject for the message
64-
* - `excludedActivityTypes` (array) - the activities to exclude from
74+
* - `excludedActivityTypes` (array) - the activities to exclude from
6575
* the ActionSheet
6676
* - `tintColor` (color) - tint color of the buttons
6777
*
@@ -73,32 +83,32 @@ var ActionSheetIOS = {
7383
*
7484
* - a boolean value signifying success or failure
7585
* - a string that, in the case of success, indicates the method of sharing
76-
*
86+
*
7787
* See http://facebook.github.io/react-native/docs/actionsheetios.html#showshareactionsheetwithoptions
7888
*/
7989
showShareActionSheetWithOptions(
8090
options: Object,
8191
failureCallback: Function,
82-
successCallback: Function
92+
successCallback: Function,
8393
) {
8494
invariant(
8595
typeof options === 'object' && options !== null,
86-
'Options must be a valid object'
96+
'Options must be a valid object',
8797
);
8898
invariant(
8999
typeof failureCallback === 'function',
90-
'Must provide a valid failureCallback'
100+
'Must provide a valid failureCallback',
91101
);
92102
invariant(
93103
typeof successCallback === 'function',
94-
'Must provide a valid successCallback'
104+
'Must provide a valid successCallback',
95105
);
96106
RCTActionSheetManager.showShareActionSheetWithOptions(
97107
{...options, tintColor: processColor(options.tintColor)},
98108
failureCallback,
99-
successCallback
109+
successCallback,
100110
);
101-
}
111+
},
102112
};
103113

104114
module.exports = ActionSheetIOS;

0 commit comments

Comments
 (0)