Skip to content
Merged
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
3 changes: 1 addition & 2 deletions Libraries/ActionSheetIOS/ActionSheetIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ var ActionSheetIOS = {
*
* - `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`
* - `destructiveButtonIndexes` (array of ints) - indexes of destructive button in `options`
* - `destructiveButtonIndex` (int or array of ints) - index or indices of destructive buttons in `options`
* - `title` (string) - a title to show above the action sheet
* - `message` (string) - a message to show below the title
*/
Expand Down
11 changes: 8 additions & 3 deletions Libraries/ActionSheetIOS/RCTActionSheetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ - (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;
NSArray<NSNumber *> *destructiveButtonIndexes = [RCTConvert NSArray:options[@"destructiveButtonIndexes"]];
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
NSArray<NSNumber *> *destructiveButtonIndices;
if ([options[@"destructiveButtonIndex"] isKindOfClass:[NSArray class]]) {
destructiveButtonIndices = [RCTConvert NSArray:options[@"destructiveButtonIndex"]];
} else {
NSNumber *destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSNumber:options[@"destructiveButtonIndex"]] : @-1;
destructiveButtonIndices = @[destructiveButtonIndex];
}

UIViewController *controller = RCTPresentedViewController();

Expand All @@ -93,7 +98,7 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
NSInteger index = 0;
for (NSString *option in buttons) {
UIAlertActionStyle style = UIAlertActionStyleDefault;
if (index == destructiveButtonIndex || [destructiveButtonIndexes containsObject:@(index)]) {
if ([destructiveButtonIndices containsObject:@(index)]) {
style = UIAlertActionStyleDestructive;
} else if (index == cancelButtonIndex) {
style = UIAlertActionStyleCancel;
Expand Down