From 4e412381f24c310eb6e4c4c3e6081ba77f11ae15 Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 14 May 2015 09:37:39 -0700 Subject: [PATCH] [TextView] Define missing properties and add getters Summary: Some of the RCTTextView properties weren't set up correctly which would cause bugs when you'd set a property and then unset it, trying to revert to the default. This requires reading the default value from the dummy view instance, but some of these properties didn't have getters which was causing issues. Fixes #1174 Closes https://github.com/facebook/react-native/pull/1175 Github Author: James Ide Test Plan: Create a `` component. Give it a style with `color: 'blue'`, and then on the next render pass remove the style. No more red box. --- Libraries/Text/RCTTextView.h | 4 +++- Libraries/Text/RCTTextView.m | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Libraries/Text/RCTTextView.h b/Libraries/Text/RCTTextView.h index 19f2fea39..014e35315 100644 --- a/Libraries/Text/RCTTextView.h +++ b/Libraries/Text/RCTTextView.h @@ -21,8 +21,10 @@ @property (nonatomic, assign) BOOL selectTextOnFocus; @property (nonatomic, assign) UIEdgeInsets contentInset; @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets; +@property (nonatomic, copy) NSString *text; +@property (nonatomic, strong) UIColor *textColor; @property (nonatomic, strong) UIColor *placeholderTextColor; -@property (nonatomic, assign) UIFont *font; +@property (nonatomic, strong) UIFont *font; - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index c5947f317..fa5b2bf8a 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -72,13 +72,22 @@ } } +- (UIFont *)font +{ + return _textView.font; +} + - (void)setFont:(UIFont *)font { - _font = font; - _textView.font = _font; + _textView.font = font; [self updatePlaceholder]; } +- (UIColor *)textColor +{ + return _textView.textColor; +} + - (void)setTextColor:(UIColor *)textColor { _textView.textColor = textColor; @@ -106,6 +115,11 @@ [self updateFrames]; } +- (NSString *)text +{ + return _textView.text; +} + - (void)setText:(NSString *)text { if (![text isEqualToString:_textView.text]) { @@ -146,7 +160,6 @@ - (void)textViewDidBeginEditing:(UITextView *)textView { if (_clearTextOnFocus) { - [_textView setText:@""]; _textView.text = @""; [self _setPlaceholderVisibility]; }