diff --git a/.gitignore b/.gitignore index ed8c09532e8c3d..7557a48165d5f2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,15 @@ project.xcworkspace # Node node_modules + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +## File-based project format: +*.ipr +*.iws diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index 73010617732abd..1024b3427f3f53 100644 --- a/Examples/UIExplorer/UIExplorerList.js +++ b/Examples/UIExplorer/UIExplorerList.js @@ -126,6 +126,7 @@ class UIExplorerList extends React.Component { clearButtonMode="always" onChangeText={this._search.bind(this)} placeholder="Search..." + placeholderTextColor="red" style={styles.searchTextInput} /> diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index dfd3ab1a128469..9de1e15e92176f 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -445,6 +445,7 @@ var TextInput = React.createClass({ onSubmitEditing={this.props.onSubmitEditing} onSelectionChangeShouldSetResponder={() => true} placeholder={this.props.placeholder} + placeholderTextColor={this.props.placeholderTextColor} text={this.state.bufferedValue} autoCapitalize={autoCapitalize} autoCorrect={this.props.autoCorrect} diff --git a/React/Views/RCTTextField.h b/React/Views/RCTTextField.h index bd1be9c187bd39..ef0a07887faabc 100644 --- a/React/Views/RCTTextField.h +++ b/React/Views/RCTTextField.h @@ -17,6 +17,7 @@ @property (nonatomic, assign) BOOL autoCorrect; @property (nonatomic, assign) BOOL selectTextOnFocus; @property (nonatomic, assign) UIEdgeInsets contentInset; +@property (nonatomic, strong) UIColor *placeholderTextColor; - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; diff --git a/React/Views/RCTTextField.m b/React/Views/RCTTextField.m index 35eb84d9653dde..189a7ae649f57a 100644 --- a/React/Views/RCTTextField.m +++ b/React/Views/RCTTextField.m @@ -42,6 +42,25 @@ - (void)setText:(NSString *)text } } +- (void)_setupPlaceholder { + if (self.placeholder.length > 0 && self.placeholderTextColor) { + self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder + attributes:@{ + NSForegroundColorAttributeName : self.placeholderTextColor + }]; + } +} + +- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor { + _placeholderTextColor = placeholderTextColor; + [self _setupPlaceholder]; +} + +- (void)setPlaceholder:(NSString *)placeholder { + super.placeholder = placeholder; + [self _setupPlaceholder]; +} + - (NSArray *)reactSubviews { // TODO: do we support subviews of textfield in React? diff --git a/React/Views/RCTTextFieldManager.m b/React/Views/RCTTextFieldManager.m index 6e78d86a3b1c39..ff401a719c7c7a 100644 --- a/React/Views/RCTTextFieldManager.m +++ b/React/Views/RCTTextFieldManager.m @@ -10,7 +10,6 @@ #import "RCTTextFieldManager.h" #import "RCTBridge.h" -#import "RCTConvert.h" #import "RCTShadowView.h" #import "RCTSparseArray.h" #import "RCTTextField.h" @@ -28,6 +27,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL) RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString) +RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(text, NSString) RCT_EXPORT_VIEW_PROPERTY(clearButtonMode, UITextFieldViewMode) RCT_REMAP_VIEW_PROPERTY(clearTextOnFocus, clearsOnBeginEditing, BOOL)