From a204eb2742df08d1830168763c29a8d6cfcd8652 Mon Sep 17 00:00:00 2001 From: Maksim Bunkow Date: Fri, 24 Apr 2015 17:52:17 +0500 Subject: [PATCH 1/4] Added to gitignore IDEA AppCode --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 From a62201246c25931c9ec640684cf48b7c80c6c9a4 Mon Sep 17 00:00:00 2001 From: Maksim Bunkow Date: Fri, 24 Apr 2015 18:00:38 +0500 Subject: [PATCH 2/4] Created placeholderTextColor feature for issue #294 --- Examples/UIExplorer/UIExplorerList.js | 1 + Libraries/Components/TextInput/TextInput.js | 1 + React/Views/RCTTextField.h | 1 + React/Views/RCTTextField.m | 23 +++++++++++++++++++++ React/Views/RCTTextFieldManager.m | 2 +- 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index 308249572da166..9806e95200003a 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 fb5f99949fbdcd..5d0da86df67ff9 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -442,6 +442,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..d3fd4f5b7e81da 100644 --- a/React/Views/RCTTextField.m +++ b/React/Views/RCTTextField.m @@ -42,6 +42,29 @@ - (void)setText:(NSString *)text } } +- (void)_setupPlaceholder { + NSAttributedString *placeholderAttributedString = nil; + if (self.placeholder && self.placeholder.length > 0) { + if (self.placeholderTextColor) { + placeholderAttributedString = [[NSAttributedString alloc] initWithString:self.placeholder attributes:@{NSForegroundColorAttributeName : self.placeholderTextColor}]; + } + } + + if (placeholderAttributedString) + self.attributedPlaceholder = placeholderAttributedString; + +} + +- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor { + _placeholderTextColor = placeholderTextColor; + [self _setupPlaceholder]; +} + +- (void)setPlaceholder:(NSString *)placeholder { + [super setPlaceholder:[placeholder mutableCopy]]; + [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) From be93e918bf15445764a0f32889c9a065220384c5 Mon Sep 17 00:00:00 2001 From: Maksim Bunkow Date: Fri, 24 Apr 2015 22:43:36 +0500 Subject: [PATCH 3/4] Edited by Code-review #997 --- React/Views/RCTTextField.m | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/React/Views/RCTTextField.m b/React/Views/RCTTextField.m index d3fd4f5b7e81da..1b2bc9cec00f1a 100644 --- a/React/Views/RCTTextField.m +++ b/React/Views/RCTTextField.m @@ -43,16 +43,12 @@ - (void)setText:(NSString *)text } - (void)_setupPlaceholder { - NSAttributedString *placeholderAttributedString = nil; - if (self.placeholder && self.placeholder.length > 0) { - if (self.placeholderTextColor) { - placeholderAttributedString = [[NSAttributedString alloc] initWithString:self.placeholder attributes:@{NSForegroundColorAttributeName : self.placeholderTextColor}]; - } + if (self.placeholder.length > 0 && self.placeholderTextColor) { + self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder + attributes:@{ + NSForegroundColorAttributeName: self.placeholderTextColor + }]; } - - if (placeholderAttributedString) - self.attributedPlaceholder = placeholderAttributedString; - } - (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor { @@ -61,7 +57,7 @@ - (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor { } - (void)setPlaceholder:(NSString *)placeholder { - [super setPlaceholder:[placeholder mutableCopy]]; + super.placeholder = placeholder; [self _setupPlaceholder]; } From 5f6b4608c5052f2497936ae60d31f8f87a590629 Mon Sep 17 00:00:00 2001 From: Maksim Bunkow Date: Sat, 25 Apr 2015 02:06:08 +0500 Subject: [PATCH 4/4] Correct indent to 2 --- React/Views/RCTTextField.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/React/Views/RCTTextField.m b/React/Views/RCTTextField.m index 1b2bc9cec00f1a..189a7ae649f57a 100644 --- a/React/Views/RCTTextField.m +++ b/React/Views/RCTTextField.m @@ -43,12 +43,12 @@ - (void)setText:(NSString *)text } - (void)_setupPlaceholder { - if (self.placeholder.length > 0 && self.placeholderTextColor) { - self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder - attributes:@{ - NSForegroundColorAttributeName: self.placeholderTextColor - }]; - } + if (self.placeholder.length > 0 && self.placeholderTextColor) { + self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder + attributes:@{ + NSForegroundColorAttributeName : self.placeholderTextColor + }]; + } } - (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor {