From 2bf41672f8d25caceb915e404c90e9de28d8af0f Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 27 Jun 2017 16:05:02 -0700 Subject: [PATCH] `placeholderText` was renamed to just `placeholder` in RCTTextView Summary: We have to have RCTTextView and RCTTextInput as much unified as possible, and this is a small step in this direction. Reviewed By: javache Differential Revision: D5143877 fbshipit-source-id: ee8fcab6093fe5d994c85110b07ea16e64fed262 --- Libraries/Text/RCTTextView.m | 12 ++++++------ Libraries/Text/RCTTextViewManager.m | 2 +- Libraries/Text/RCTUITextView.h | 4 ++-- Libraries/Text/RCTUITextView.m | 26 +++++++++++++------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index cea4f87267f467..d53125e87d7fef 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -273,23 +273,23 @@ - (void)setText:(NSString *)text - (NSString *)placeholder { - return _textView.placeholderText; + return _textView.placeholder; } - (void)setPlaceholder:(NSString *)placeholder { - _textView.placeholderText = placeholder; + _textView.placeholder = placeholder; [self setNeedsLayout]; } -- (UIColor *)placeholderTextColor +- (UIColor *)placeholderColor { - return _textView.placeholderTextColor; + return _textView.placeholderColor; } -- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor +- (void)setPlaceholderColor:(UIColor *)placeholderColor { - _textView.placeholderTextColor = placeholderTextColor; + _textView.placeholderColor = placeholderColor; } - (void)setAutocorrectionType:(UITextAutocorrectionType)autocorrectionType diff --git a/Libraries/Text/RCTTextViewManager.m b/Libraries/Text/RCTTextViewManager.m index 5dcfc15391bd07..0dec7c5a4ba814 100644 --- a/Libraries/Text/RCTTextViewManager.m +++ b/Libraries/Text/RCTTextViewManager.m @@ -51,7 +51,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onTextInput, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString) -RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor) +RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, placeholderColor, UIColor) RCT_REMAP_VIEW_PROPERTY(returnKeyType, textView.returnKeyType, UIReturnKeyType) RCT_REMAP_VIEW_PROPERTY(secureTextEntry, textView.secureTextEntry, BOOL) RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor) diff --git a/Libraries/Text/RCTUITextView.h b/Libraries/Text/RCTUITextView.h index 762c1c2ad70cdb..b8388df2676cb3 100644 --- a/Libraries/Text/RCTUITextView.h +++ b/Libraries/Text/RCTUITextView.h @@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE; @property (nonatomic, assign, readonly) BOOL textWasPasted; -@property (nonatomic, copy, nullable) NSString *placeholderText; -@property (nonatomic, assign, nullable) UIColor *placeholderTextColor; +@property (nonatomic, copy, nullable) NSString *placeholder; +@property (nonatomic, strong, nullable) UIColor *placeholderColor; @end diff --git a/Libraries/Text/RCTUITextView.m b/Libraries/Text/RCTUITextView.m index b260a73f8692b2..f82c85e97cd6ad 100644 --- a/Libraries/Text/RCTUITextView.m +++ b/Libraries/Text/RCTUITextView.m @@ -23,7 +23,7 @@ @implementation RCTUITextView return [UIFont systemFontOfSize:17]; } -static UIColor *defaultPlaceholderTextColor() +static UIColor *defaultPlaceholderColor() { // Default placeholder color from UITextField. return [UIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22]; @@ -40,7 +40,7 @@ - (instancetype)initWithFrame:(CGRect)frame _placeholderView = [[UILabel alloc] initWithFrame:self.bounds]; _placeholderView.isAccessibilityElement = NO; _placeholderView.numberOfLines = 0; - _placeholderView.textColor = defaultPlaceholderTextColor(); + _placeholderView.textColor = defaultPlaceholderColor(); [self addSubview:_placeholderView]; } @@ -61,11 +61,11 @@ - (NSString *)accessibilityLabel [accessibilityLabel appendString:superAccessibilityLabel]; } - if (self.placeholderText.length > 0 && self.text.length == 0) { + if (self.placeholder.length > 0 && self.text.length == 0) { if (accessibilityLabel.length > 0) { [accessibilityLabel appendString:@" "]; } - [accessibilityLabel appendString:self.placeholderText]; + [accessibilityLabel appendString:self.placeholder]; } return accessibilityLabel; @@ -73,16 +73,16 @@ - (NSString *)accessibilityLabel #pragma mark - Properties -- (void)setPlaceholderText:(NSString *)placeholderText +- (void)setPlaceholder:(NSString *)placeholder { - _placeholderText = placeholderText; - _placeholderView.text = _placeholderText; + _placeholder = placeholder; + _placeholderView.text = _placeholder; } -- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor +- (void)setPlaceholderColor:(UIColor *)placeholderColor { - _placeholderTextColor = placeholderTextColor; - _placeholderView.textColor = _placeholderTextColor ?: defaultPlaceholderTextColor(); + _placeholderColor = placeholderColor; + _placeholderView.textColor = _placeholderColor ?: defaultPlaceholderColor(); } - (void)textDidChange @@ -148,8 +148,8 @@ - (CGSize)sizeThatFits:(CGSize)size CGSize textSize = [self fixedSizeThatFits:size]; UIEdgeInsets padddingInsets = self.textContainerInset; - NSString *placeholderText = self.placeholderText ?: @""; - CGSize placeholderSize = [placeholderText sizeWithAttributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()}]; + NSString *placeholder = self.placeholder ?: @""; + CGSize placeholderSize = [placeholder sizeWithAttributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()}]; placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height)); placeholderSize.width += padddingInsets.left + padddingInsets.right; placeholderSize.height += padddingInsets.top + padddingInsets.bottom; @@ -186,7 +186,7 @@ - (CGSize)fixedSizeThatFits:(CGSize)size - (void)invalidatePlaceholderVisibility { - BOOL isVisible = _placeholderText.length != 0 && self.text.length == 0; + BOOL isVisible = _placeholder.length != 0 && self.text.length == 0; _placeholderView.hidden = !isVisible; }