Add support for "message" option to ActionSheetIOS and improve docs

Summary:Updated docs:

![screen shot 2016-03-27 at 12 41 02](https://cloud.githubusercontent.com/assets/3316532/14066504/35509612-f419-11e5-923f-e354ad939ee5.png)
Closes https://github.com/facebook/react-native/pull/6685

Differential Revision: D3119791

Pulled By: javache

fb-gh-sync-id: fadd5ea1a1b979f79b41c80b6a19fdb9ea3f100f
fbshipit-source-id: fadd5ea1a1b979f79b41c80b6a19fdb9ea3f100f
This commit is contained in:
Lane Rettig 2016-03-30 22:10:00 -07:00 committed by Facebook Github Bot 3
parent 4498bc8197
commit 928fd0d605
2 changed files with 14 additions and 3 deletions

View File

@ -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',
@ -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',

View File

@ -61,6 +61,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
}
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;
@ -113,7 +114,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
{
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:title
message:nil
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
NSInteger index = 0;