Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Libraries/ActionSheetIOS/ActionSheetIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ var invariant = require('fbjs/lib/invariant');
var processColor = require('processColor');

var ActionSheetIOS = {
/**
* Display an iOS action sheet. The `options` object must contain one or more
* of:
*
* - `options` (array of strings) - a list of button titles (required)
* - `cancelButtonIndex` (int) - index of cancel button in `options`
* - `destructiveButtonIndex` (int) - index of destructive button in `options`
* - `title` (string) - a title to show above the action sheet
* - `message` (string) - a message to show below the title
*/
showActionSheetWithOptions(options: Object, callback: Function) {
invariant(
typeof options === 'object' && options !== null,
'Options must a valid object'
'Options must be a valid object'
);
invariant(
typeof callback === 'function',
Expand Down Expand Up @@ -50,7 +60,7 @@ var ActionSheetIOS = {
) {
invariant(
typeof options === 'object' && options !== null,
'Options must a valid object'
'Options must be a valid object'
);
invariant(
typeof failureCallback === 'function',
Expand Down
3 changes: 2 additions & 1 deletion Libraries/ActionSheetIOS/RCTActionSheetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
}

NSString *title = [RCTConvert NSString:options[@"title"]];
NSString *message = [RCTConvert NSString:options[@"message"]];
NSArray<NSString *> *buttons = [RCTConvert NSStringArray:options[@"options"]];
NSInteger destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSInteger:options[@"destructiveButtonIndex"]] : -1;
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
Expand Down Expand Up @@ -113,7 +114,7 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
{
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:title
message:nil
message:message
preferredStyle:UIAlertControllerStyleActionSheet];

NSInteger index = 0;
Expand Down