Skip to content

Commit 54cda40

Browse files
[ActionSheetIOS] Add tintColor for buttons.
Closes #3374
1 parent 31125b2 commit 54cda40

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Libraries/ActionSheetIOS/ActionSheetIOS.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
var RCTActionSheetManager = require('NativeModules').ActionSheetManager;
1515

1616
var invariant = require('invariant');
17+
var processColor = require('processColor');
1718

1819
var ActionSheetIOS = {
1920
showActionSheetWithOptions(options: Object, callback: Function) {
@@ -25,6 +26,9 @@ var ActionSheetIOS = {
2526
typeof callback === 'function',
2627
'Must provide a valid callback'
2728
);
29+
30+
options.tintColor = processColor(options.tintColor);
31+
2832
RCTActionSheetManager.showActionSheetWithOptions(
2933
options,
3034
callback
@@ -48,6 +52,9 @@ var ActionSheetIOS = {
4852
typeof successCallback === 'function',
4953
'Must provide a valid successCallback'
5054
);
55+
56+
options.tintColor = processColor(options.tintColor);
57+
5158
RCTActionSheetManager.showShareActionSheetWithOptions(
5259
options,
5360
failureCallback,

Libraries/ActionSheetIOS/RCTActionSheetManager.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
6565
NSArray<NSString *> *buttons = [RCTConvert NSStringArray:options[@"options"]];
6666
NSInteger destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSInteger:options[@"destructiveButtonIndex"]] : -1;
6767
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
68-
68+
UIColor *tintColor = [RCTConvert UIColor:options[@"tintColor"]];
69+
6970
UIViewController *controller = RCTKeyWindow().rootViewController;
7071
if (controller == nil) {
7172
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
@@ -139,6 +140,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
139140
alertController.popoverPresentationController.permittedArrowDirections = 0;
140141
}
141142
[controller presentViewController:alertController animated:YES completion:nil];
143+
144+
alertController.view.tintColor = tintColor;
142145
}
143146
}
144147

@@ -176,6 +179,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
176179
if (excludedActivityTypes) {
177180
shareController.excludedActivityTypes = excludedActivityTypes;
178181
}
182+
183+
UIColor *tintColor = [RCTConvert UIColor:options[@"tintColor"]];
179184

180185
UIViewController *controller = RCTKeyWindow().rootViewController;
181186

@@ -210,6 +215,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
210215
}
211216

212217
[controller presentViewController:shareController animated:YES completion:nil];
218+
219+
shareController.view.tintColor = tintColor;
213220
}
214221

215222
#pragma mark UIActionSheetDelegate Methods

0 commit comments

Comments
 (0)