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
This commit is contained in:
Valentin Shergin 2017-06-27 16:05:02 -07:00 committed by Facebook Github Bot
parent 719f0005f6
commit 2bf41672f8
4 changed files with 22 additions and 22 deletions

View File

@ -273,23 +273,23 @@ static NSAttributedString *removeReactTagFromString(NSAttributedString *string)
- (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

View File

@ -51,7 +51,7 @@ RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
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)

View File

@ -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

View File

@ -23,7 +23,7 @@ static UIFont *defaultPlaceholderFont()
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 @@ static UIColor *defaultPlaceholderTextColor()
_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 @@ static UIColor *defaultPlaceholderTextColor()
[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 @@ static UIColor *defaultPlaceholderTextColor()
#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 @@ static UIColor *defaultPlaceholderTextColor()
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 @@ static UIColor *defaultPlaceholderTextColor()
- (void)invalidatePlaceholderVisibility
{
BOOL isVisible = _placeholderText.length != 0 && self.text.length == 0;
BOOL isVisible = _placeholder.length != 0 && self.text.length == 0;
_placeholderView.hidden = !isVisible;
}