mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
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 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',
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user