Skip to content

Commit

Permalink
[ActionSheetIOS] Add tintColor for buttons.
Browse files Browse the repository at this point in the history
Closes #3374
  • Loading branch information
christopherdro committed Dec 7, 2015
1 parent 31125b2 commit b0106dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Libraries/ActionSheetIOS/ActionSheetIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
var RCTActionSheetManager = require('NativeModules').ActionSheetManager;

var invariant = require('invariant');
var processColor = require('processColor');

var ActionSheetIOS = {
showActionSheetWithOptions(options: Object, callback: Function) {
Expand All @@ -25,6 +26,9 @@ var ActionSheetIOS = {
typeof callback === 'function',
'Must provide a valid callback'
);

options.tintColor = processColor(options.tintColor);

RCTActionSheetManager.showActionSheetWithOptions(
options,
callback
Expand All @@ -48,6 +52,9 @@ var ActionSheetIOS = {
typeof successCallback === 'function',
'Must provide a valid successCallback'
);

options.tintColor = processColor(options.tintColor);

RCTActionSheetManager.showShareActionSheetWithOptions(
options,
failureCallback,
Expand Down
9 changes: 8 additions & 1 deletion Libraries/ActionSheetIOS/RCTActionSheetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
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;

UIColor *tintColor = options[@"tintColor"] ? [RCTConvert UIColor:options[@"tintColor"]] : nil;

UIViewController *controller = RCTKeyWindow().rootViewController;
if (controller == nil) {
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
Expand Down Expand Up @@ -139,6 +140,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
alertController.popoverPresentationController.permittedArrowDirections = 0;
}
[controller presentViewController:alertController animated:YES completion:nil];

alertController.view.tintColor = tintColor;
}
}

Expand Down Expand Up @@ -176,6 +179,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
if (excludedActivityTypes) {
shareController.excludedActivityTypes = excludedActivityTypes;
}

UIColor *tintColor = options[@"tintColor"] ? [RCTConvert UIColor:options[@"tintColor"]] : nil;

UIViewController *controller = RCTKeyWindow().rootViewController;

Expand Down Expand Up @@ -210,6 +215,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
}

[controller presentViewController:shareController animated:YES completion:nil];

shareController.view.tintColor = tintColor;
}

#pragma mark UIActionSheetDelegate Methods
Expand Down

0 comments on commit b0106dc

Please sign in to comment.