File tree Expand file tree Collapse file tree 3 files changed +46
-4
lines changed
Expand file tree Collapse file tree 3 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ var BUTTONS = [
2727 'Option 0' ,
2828 'Option 1' ,
2929 'Option 2' ,
30- 'Destruct ' ,
30+ 'Delete ' ,
3131 'Cancel' ,
3232] ;
3333var DESTRUCTIVE_INDEX = 3 ;
@@ -65,6 +65,40 @@ var ActionSheetExample = React.createClass({
6565 }
6666} ) ;
6767
68+ var ActionSheetTintExample = React . createClass ( {
69+ getInitialState ( ) {
70+ return {
71+ clicked : 'none' ,
72+ } ;
73+ } ,
74+
75+ render ( ) {
76+ return (
77+ < View >
78+ < Text onPress = { this . showActionSheet } style = { style . button } >
79+ Click to show the ActionSheet
80+ </ Text >
81+ < Text >
82+ Clicked button: { this . state . clicked }
83+ </ Text >
84+ </ View >
85+ ) ;
86+ } ,
87+
88+ showActionSheet ( ) {
89+ ActionSheetIOS . showActionSheetWithOptions ( {
90+ options : BUTTONS ,
91+ cancelButtonIndex : CANCEL_INDEX ,
92+ destructiveButtonIndex : DESTRUCTIVE_INDEX ,
93+ tintColor : 'green' ,
94+ } ,
95+ ( buttonIndex ) => {
96+ this . setState ( { clicked : BUTTONS [ buttonIndex ] } ) ;
97+ } ) ;
98+ }
99+ } ) ;
100+
101+
68102var ShareActionSheetExample = React . createClass ( {
69103 getInitialState ( ) {
70104 return {
@@ -123,6 +157,10 @@ exports.examples = [
123157 title : 'Show Action Sheet' ,
124158 render ( ) : ReactElement { return < ActionSheetExample /> ; }
125159 } ,
160+ {
161+ title : 'Show Action Sheet with tinted buttons' ,
162+ render ( ) : ReactElement { return < ActionSheetTintExample /> ; }
163+ } ,
126164 {
127165 title : 'Show Share Action Sheet' ,
128166 render ( ) : ReactElement { return < ShareActionSheetExample /> ; }
Original file line number Diff line number Diff line change 1414var RCTActionSheetManager = require ( 'NativeModules' ) . ActionSheetManager ;
1515
1616var invariant = require ( 'invariant' ) ;
17+ var processColor = require ( 'processColor' ) ;
1718
1819var ActionSheetIOS = {
1920 showActionSheetWithOptions ( options : Object , callback : Function ) {
@@ -26,7 +27,7 @@ var ActionSheetIOS = {
2627 'Must provide a valid callback'
2728 ) ;
2829 RCTActionSheetManager . showActionSheetWithOptions (
29- options ,
30+ { ... options , tintColor : processColor ( options . tintColor ) } ,
3031 callback
3132 ) ;
3233 } ,
@@ -49,7 +50,7 @@ var ActionSheetIOS = {
4950 'Must provide a valid successCallback'
5051 ) ;
5152 RCTActionSheetManager . showShareActionSheetWithOptions (
52- options ,
53+ { ... options , tintColor : processColor ( options . tintColor ) } ,
5354 failureCallback ,
5455 successCallback
5556 ) ;
Original file line number Diff line number Diff line change 1616#import " RCTUIManager.h"
1717
1818@interface RCTActionSheetManager () <UIActionSheetDelegate>
19-
2019@end
2120
2221@implementation RCTActionSheetManager
@@ -139,6 +138,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
139138 alertController.popoverPresentationController .permittedArrowDirections = 0 ;
140139 }
141140 [controller presentViewController: alertController animated: YES completion: nil ];
141+
142+ alertController.view .tintColor = [RCTConvert UIColor: options[@" tintColor" ]];
142143 }
143144}
144145
@@ -210,6 +211,8 @@ - (CGRect)sourceRectInView:(UIView *)sourceView
210211 }
211212
212213 [controller presentViewController: shareController animated: YES completion: nil ];
214+
215+ shareController.view .tintColor = [RCTConvert UIColor: options[@" tintColor" ]];
213216}
214217
215218#pragma mark UIActionSheetDelegate Methods
You can’t perform that action at this time.
0 commit comments