Permalink
Browse files

`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
  • Loading branch information...
shergin authored and facebook-github-bot committed Jun 27, 2017
1 parent 719f000 commit 2bf41672f8d25caceb915e404c90e9de28d8af0f
@@ -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
@@ -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)
@@ -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
@@ -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,28 +61,28 @@ - (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;
}
#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;
}

0 comments on commit 2bf4167

Please sign in to comment.