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:
parent
4498bc8197
commit
928fd0d605
|
@ -17,10 +17,20 @@ var invariant = require('fbjs/lib/invariant');
|
||||||
var processColor = require('processColor');
|
var processColor = require('processColor');
|
||||||
|
|
||||||
var ActionSheetIOS = {
|
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) {
|
showActionSheetWithOptions(options: Object, callback: Function) {
|
||||||
invariant(
|
invariant(
|
||||||
typeof options === 'object' && options !== null,
|
typeof options === 'object' && options !== null,
|
||||||
'Options must a valid object'
|
'Options must be a valid object'
|
||||||
);
|
);
|
||||||
invariant(
|
invariant(
|
||||||
typeof callback === 'function',
|
typeof callback === 'function',
|
||||||
|
@ -50,7 +60,7 @@ var ActionSheetIOS = {
|
||||||
) {
|
) {
|
||||||
invariant(
|
invariant(
|
||||||
typeof options === 'object' && options !== null,
|
typeof options === 'object' && options !== null,
|
||||||
'Options must a valid object'
|
'Options must be a valid object'
|
||||||
);
|
);
|
||||||
invariant(
|
invariant(
|
||||||
typeof failureCallback === 'function',
|
typeof failureCallback === 'function',
|
||||||
|
|
|
@ -61,6 +61,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *title = [RCTConvert NSString:options[@"title"]];
|
NSString *title = [RCTConvert NSString:options[@"title"]];
|
||||||
|
NSString *message = [RCTConvert NSString:options[@"message"]];
|
||||||
NSArray<NSString *> *buttons = [RCTConvert NSStringArray:options[@"options"]];
|
NSArray<NSString *> *buttons = [RCTConvert NSStringArray:options[@"options"]];
|
||||||
NSInteger destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSInteger:options[@"destructiveButtonIndex"]] : -1;
|
NSInteger destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSInteger:options[@"destructiveButtonIndex"]] : -1;
|
||||||
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
|
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
|
||||||
|
@ -113,7 +114,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
|
||||||
{
|
{
|
||||||
UIAlertController *alertController =
|
UIAlertController *alertController =
|
||||||
[UIAlertController alertControllerWithTitle:title
|
[UIAlertController alertControllerWithTitle:title
|
||||||
message:nil
|
message:message
|
||||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||||
|
|
||||||
NSInteger index = 0;
|
NSInteger index = 0;
|
||||||
|
|
Loading…
Reference in New Issue