Skip to content

Commit 19a9c5e

Browse files
sherginfacebook-github-bot
authored andcommitted
The Great File Renaming in RCTText
Summary: The previous file/class name convention seemed cool... but now it drives me BANANAS! It makes all this code really hard to maintain. So, evething were renamed following common modern RN convention. Reviewed By: mmmulani Differential Revision: D6605090 fbshipit-source-id: 88ca13d793a5d2adaac2b7922ec6bd4654aacec5
1 parent 5c8481e commit 19a9c5e

40 files changed

+385
-251
lines changed

Libraries/Components/ScrollResponder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ function isTagInstanceOfTextInput(tag) {
126126
var instance = getInstanceFromNode(tag);
127127
return instance && instance.viewConfig && (
128128
instance.viewConfig.uiViewClassName === 'AndroidTextInput' ||
129-
instance.viewConfig.uiViewClassName === 'RCTTextView' ||
130-
instance.viewConfig.uiViewClassName === 'RCTTextField'
129+
instance.viewConfig.uiViewClassName === 'RCTMultilineTextInputView' ||
130+
instance.viewConfig.uiViewClassName === 'RCTSinglelineTextInputView'
131131
);
132132
}
133133

Libraries/Components/TextInput/TextInput.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const onlyMultiline = {
5050
if (Platform.OS === 'android') {
5151
var AndroidTextInput = requireNativeComponent('AndroidTextInput', null);
5252
} else if (Platform.OS === 'ios') {
53-
var RCTTextView = requireNativeComponent('RCTTextView', null);
54-
var RCTTextField = requireNativeComponent('RCTTextField', null);
53+
var RCTMultilineTextInputView = requireNativeComponent('RCTMultilineTextInputView', null);
54+
var RCTSinglelineTextInputView = requireNativeComponent('RCTSinglelineTextInputView', null);
5555
}
5656

5757
type Event = Object;
@@ -707,7 +707,7 @@ const TextInput = createReactClass({
707707
}
708708
}
709709
textContainer =
710-
<RCTTextField
710+
<RCTSinglelineTextInputView
711711
ref={this._setNativeRef}
712712
{...props}
713713
onFocus={this._onFocus}
@@ -733,7 +733,7 @@ const TextInput = createReactClass({
733733
}
734734
props.style.unshift(styles.multilineInput);
735735
textContainer =
736-
<RCTTextView
736+
<RCTMultilineTextInputView
737737
ref={this._setNativeRef}
738738
{...props}
739739
children={children}
@@ -926,8 +926,8 @@ const TextInput = createReactClass({
926926

927927
var styles = StyleSheet.create({
928928
multilineInput: {
929-
// This default top inset makes RCTTextView seem as close as possible
930-
// to single-line RCTTextField defaults, using the system defaults
929+
// This default top inset makes RCTMultilineTextInputView seem as close as possible
930+
// to single-line RCTSinglelineTextInputView defaults, using the system defaults
931931
// of font size 17 and a height of 31 points.
932932
paddingTop: 5,
933933
},

Libraries/Text/RCTShadowRawText.h Libraries/Text/RCTRawTextShadowView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#import <React/RCTShadowView.h>
1111

12-
@interface RCTShadowRawText : RCTShadowView
12+
@interface RCTRawTextShadowView : RCTShadowView
1313

1414
@property (nonatomic, copy) NSString *text;
1515

Libraries/Text/RCTShadowRawText.m Libraries/Text/RCTRawTextShadowView.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTShadowRawText.h"
10+
#import "RCTRawTextShadowView.h"
1111

1212
#import <React/RCTUIManager.h>
1313

14-
@implementation RCTShadowRawText
14+
@implementation RCTRawTextShadowView
1515

1616
- (instancetype)init
1717
{

Libraries/Text/RCTRawTextManager.h Libraries/Text/RCTRawTextViewManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#import <React/RCTViewManager.h>
1111

12-
@interface RCTRawTextManager : RCTViewManager
12+
@interface RCTRawTextViewManager : RCTViewManager
1313

1414
@end

Libraries/Text/RCTRawTextManager.m Libraries/Text/RCTRawTextViewManager.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTRawTextManager.h"
10+
#import "RCTRawTextViewManager.h"
1111

12-
#import "RCTShadowRawText.h"
12+
#import "RCTRawTextShadowView.h"
1313

14-
@implementation RCTRawTextManager
14+
@implementation RCTRawTextViewManager
1515

16-
RCT_EXPORT_MODULE()
16+
RCT_EXPORT_MODULE(RCTRawText)
1717

1818
- (RCTShadowView *)shadowView
1919
{
20-
return [RCTShadowRawText new];
20+
return [RCTRawTextShadowView new];
2121
}
2222

2323
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)

Libraries/Text/RCTText.xcodeproj/project.pbxproj

+248-138
Large diffs are not rendered by default.

Libraries/Text/RCTShadowText.h Libraries/Text/Text/RCTTextShadowView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, RCTSizeComparison)
2121
extern NSString *const RCTIsHighlightedAttributeName;
2222
extern NSString *const RCTReactTagAttributeName;
2323

24-
@interface RCTShadowText : RCTShadowView
24+
@interface RCTTextShadowView : RCTShadowView
2525

2626
@property (nonatomic, strong) UIColor *color;
2727
@property (nonatomic, strong) UIColor *backgroundColor;

Libraries/Text/RCTShadowText.m Libraries/Text/Text/RCTTextShadowView.m

+21-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTShadowText.h"
10+
#import "RCTTextShadowView.h"
1111

1212
#import <React/RCTAccessibilityManager.h>
1313
#import <React/RCTBridge.h>
@@ -18,9 +18,9 @@
1818
#import <React/RCTUIManager.h>
1919
#import <React/RCTUtils.h>
2020

21-
#import "RCTShadowRawText.h"
22-
#import "RCTText.h"
21+
#import "RCTRawTextShadowView.h"
2322
#import "RCTTextView.h"
23+
#import "RCTMultilineTextInputView.h"
2424

2525
NSString *const RCTIsHighlightedAttributeName = @"IsHighlightedAttributeName";
2626
NSString *const RCTReactTagAttributeName = @"ReactTagAttributeName";
@@ -31,7 +31,7 @@
3131
static CGFloat const kAutoSizeHeightErrorMargin = 0.025f;
3232
static CGFloat const kAutoSizeGranularity = 0.001f;
3333

34-
@implementation RCTShadowText
34+
@implementation RCTTextShadowView
3535
{
3636
NSTextStorage *_cachedTextStorage;
3737
CGFloat _cachedTextStorageWidth;
@@ -43,7 +43,7 @@ @implementation RCTShadowText
4343

4444
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
4545
{
46-
RCTShadowText *shadowText = (__bridge RCTShadowText *)YGNodeGetContext(node);
46+
RCTTextShadowView *shadowText = (__bridge RCTTextShadowView *)YGNodeGetContext(node);
4747
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width widthMode:widthMode];
4848
[shadowText calculateTextFrame:textStorage];
4949
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
@@ -109,7 +109,7 @@ - (void)contentSizeMultiplierDidChange:(NSNotification *)note
109109
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
110110
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
111111
{
112-
if ([[self reactSuperview] isKindOfClass:[RCTShadowText class]]) {
112+
if ([[self reactSuperview] isKindOfClass:[RCTTextShadowView class]]) {
113113
return parentProperties;
114114
}
115115

@@ -122,22 +122,22 @@ - (void)contentSizeMultiplierDidChange:(NSNotification *)note
122122
CGRect textFrame = [self calculateTextFrame:textStorage];
123123
BOOL selectable = _selectable;
124124
[applierBlocks addObject:^(NSDictionary<NSNumber *, UIView *> *viewRegistry) {
125-
RCTText *view = (RCTText *)viewRegistry[self.reactTag];
125+
RCTTextView *view = (RCTTextView *)viewRegistry[self.reactTag];
126126
view.textFrame = textFrame;
127127
view.textStorage = textStorage;
128128
view.selectable = selectable;
129129

130130
/**
131131
* NOTE: this logic is included to support rich text editing inside multiline
132132
* `<TextInput>` controls. It is required in order to ensure that the
133-
* textStorage (aka attributed string) is copied over from the RCTShadowText
134-
* to the RCTText view in time to be used to update the editable text content.
135-
* TODO: we should establish a delegate relationship betweeen RCTTextView
136-
* and its contaned RCTText element when they get inserted and get rid of this
133+
* textStorage (aka attributed string) is copied over from the RCTTextShadowView
134+
* to the RCTTextView view in time to be used to update the editable text content.
135+
* TODO: we should establish a delegate relationship betweeen RCTMultilineTextInputView
136+
* and its contaned RCTTextView element when they get inserted and get rid of this
137137
*/
138138
UIView *parentView = viewRegistry[parentTag];
139139
if ([parentView respondsToSelector:@selector(performTextUpdate)]) {
140-
[(RCTTextView *)parentView performTextUpdate];
140+
[(RCTMultilineTextInputView *)parentView performTextUpdate];
141141
}
142142
}];
143143

@@ -308,8 +308,8 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
308308
CGFloat heightOfTallestSubview = 0.0;
309309
NSMutableAttributedString *attributedString = [NSMutableAttributedString new];
310310
for (RCTShadowView *child in [self reactSubviews]) {
311-
if ([child isKindOfClass:[RCTShadowText class]]) {
312-
RCTShadowText *shadowText = (RCTShadowText *)child;
311+
if ([child isKindOfClass:[RCTTextShadowView class]]) {
312+
RCTTextShadowView *shadowText = (RCTTextShadowView *)child;
313313
[attributedString appendAttributedString:
314314
[shadowText _attributedStringWithFontFamily:fontFamily
315315
fontSize:fontSize
@@ -321,8 +321,8 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
321321
backgroundColor:shadowText.backgroundColor ?: backgroundColor
322322
opacity:opacity * shadowText.opacity]];
323323
[child setTextComputed];
324-
} else if ([child isKindOfClass:[RCTShadowRawText class]]) {
325-
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
324+
} else if ([child isKindOfClass:[RCTRawTextShadowView class]]) {
325+
RCTRawTextShadowView *shadowRawText = (RCTRawTextShadowView *)child;
326326
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
327327
[child setTextComputed];
328328
} else {
@@ -340,7 +340,7 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
340340
if (height > heightOfTallestSubview) {
341341
heightOfTallestSubview = height;
342342
}
343-
// Don't call setTextComputed on this child. RCTTextManager takes care of
343+
// Don't call setTextComputed on this child. RCTTextViewManager takes care of
344344
// processing inline UIViews.
345345
}
346346
}
@@ -653,8 +653,8 @@ - (void)setAllowFontScaling:(BOOL)allowFontScaling
653653
{
654654
_allowFontScaling = allowFontScaling;
655655
for (RCTShadowView *child in [self reactSubviews]) {
656-
if ([child isKindOfClass:[RCTShadowText class]]) {
657-
((RCTShadowText *)child).allowFontScaling = allowFontScaling;
656+
if ([child isKindOfClass:[RCTTextShadowView class]]) {
657+
((RCTTextShadowView *)child).allowFontScaling = allowFontScaling;
658658
}
659659
}
660660
[self dirtyText];
@@ -668,8 +668,8 @@ - (void)setFontSizeMultiplier:(CGFloat)fontSizeMultiplier
668668
_fontSizeMultiplier = 1.0;
669669
}
670670
for (RCTShadowView *child in [self reactSubviews]) {
671-
if ([child isKindOfClass:[RCTShadowText class]]) {
672-
((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier;
671+
if ([child isKindOfClass:[RCTTextShadowView class]]) {
672+
((RCTTextShadowView *)child).fontSizeMultiplier = fontSizeMultiplier;
673673
}
674674
}
675675
[self dirtyText];

Libraries/Text/RCTText.h Libraries/Text/Text/RCTTextView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#import <UIKit/UIKit.h>
1111

12-
@interface RCTText : UIView
12+
@interface RCTTextView : UIView
1313

1414
@property (nonatomic, assign) UIEdgeInsets contentInset;
1515
@property (nonatomic, strong) NSTextStorage *textStorage;

Libraries/Text/RCTText.m Libraries/Text/Text/RCTTextView.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTText.h"
10+
#import "RCTTextView.h"
1111

1212
#import <MobileCoreServices/UTCoreTypes.h>
1313

1414
#import <React/RCTUtils.h>
1515
#import <React/UIView+React.h>
1616

17-
#import "RCTShadowText.h"
17+
#import "RCTTextShadowView.h"
1818

19-
static void collectNonTextDescendants(RCTText *view, NSMutableArray *nonTextDescendants)
19+
static void collectNonTextDescendants(RCTTextView *view, NSMutableArray *nonTextDescendants)
2020
{
2121
for (UIView *child in view.reactSubviews) {
22-
if ([child isKindOfClass:[RCTText class]]) {
23-
collectNonTextDescendants((RCTText *)child, nonTextDescendants);
22+
if ([child isKindOfClass:[RCTTextView class]]) {
23+
collectNonTextDescendants((RCTTextView *)child, nonTextDescendants);
2424
} else if (!CGRectEqualToRect(child.frame, CGRectZero)) {
2525
[nonTextDescendants addObject:child];
2626
}
2727
}
2828
}
2929

30-
@implementation RCTText
30+
@implementation RCTTextView
3131
{
3232
NSTextStorage *_textStorage;
3333
CAShapeLayer *_highlightLayer;
File renamed without changes.

Libraries/Text/RCTTextManager.m Libraries/Text/Text/RCTTextViewManager.m

+22-22
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTTextManager.h"
10+
#import "RCTTextViewManager.h"
1111

1212
#import <React/RCTAccessibilityManager.h>
1313
#import <React/RCTAssert.h>
@@ -17,42 +17,42 @@
1717
#import <React/UIView+React.h>
1818
#import <yoga/Yoga.h>
1919

20-
#import "RCTShadowRawText.h"
21-
#import "RCTShadowText.h"
22-
#import "RCTText.h"
20+
#import "RCTRawTextShadowView.h"
21+
#import "RCTTextShadowView.h"
2322
#import "RCTTextView.h"
23+
#import "RCTMultilineTextInputView.h"
2424

25-
static void collectDirtyNonTextDescendants(RCTShadowText *shadowView, NSMutableArray *nonTextDescendants) {
25+
static void collectDirtyNonTextDescendants(RCTTextShadowView *shadowView, NSMutableArray *nonTextDescendants) {
2626
for (RCTShadowView *child in shadowView.reactSubviews) {
27-
if ([child isKindOfClass:[RCTShadowText class]]) {
28-
collectDirtyNonTextDescendants((RCTShadowText *)child, nonTextDescendants);
29-
} else if ([child isKindOfClass:[RCTShadowRawText class]]) {
27+
if ([child isKindOfClass:[RCTTextShadowView class]]) {
28+
collectDirtyNonTextDescendants((RCTTextShadowView *)child, nonTextDescendants);
29+
} else if ([child isKindOfClass:[RCTRawTextShadowView class]]) {
3030
// no-op
3131
} else if ([child isTextDirty]) {
3232
[nonTextDescendants addObject:child];
3333
}
3434
}
3535
}
3636

37-
@interface RCTShadowText (Private)
37+
@interface RCTTextShadowView (Private)
3838

3939
- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width widthMode:(YGMeasureMode)widthMode;
4040

4141
@end
4242

4343

44-
@implementation RCTTextManager
44+
@implementation RCTTextViewManager
4545

46-
RCT_EXPORT_MODULE()
46+
RCT_EXPORT_MODULE(RCTText)
4747

4848
- (UIView *)view
4949
{
50-
return [RCTText new];
50+
return [RCTTextView new];
5151
}
5252

5353
- (RCTShadowView *)shadowView
5454
{
55-
return [RCTShadowText new];
55+
return [RCTTextShadowView new];
5656
}
5757

5858
#pragma mark - Shadow properties
@@ -101,13 +101,13 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNu
101101
RCTShadowView *shadowView = queue[i];
102102
RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text");
103103

104-
if ([shadowView isKindOfClass:[RCTShadowText class]]) {
105-
((RCTShadowText *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier;
106-
[(RCTShadowText *)shadowView recomputeText];
107-
collectDirtyNonTextDescendants((RCTShadowText *)shadowView, queue);
108-
} else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) {
104+
if ([shadowView isKindOfClass:[RCTTextShadowView class]]) {
105+
((RCTTextShadowView *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier;
106+
[(RCTTextShadowView *)shadowView recomputeText];
107+
collectDirtyNonTextDescendants((RCTTextShadowView *)shadowView, queue);
108+
} else if ([shadowView isKindOfClass:[RCTRawTextShadowView class]]) {
109109
RCTLogError(@"Raw text cannot be used outside of a <Text> tag. Not rendering string: '%@'",
110-
[(RCTShadowRawText *)shadowView text]);
110+
[(RCTRawTextShadowView *)shadowView text]);
111111
} else {
112112
for (RCTShadowView *child in [shadowView reactSubviews]) {
113113
if ([child isTextDirty]) {
@@ -123,13 +123,13 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNu
123123
return nil;
124124
}
125125

126-
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowView
126+
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTTextShadowView *)shadowView
127127
{
128128
NSNumber *reactTag = shadowView.reactTag;
129129
UIEdgeInsets padding = shadowView.paddingAsInsets;
130130

131-
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
132-
RCTText *text = viewRegistry[reactTag];
131+
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
132+
RCTTextView *text = viewRegistry[reactTag];
133133
text.contentInset = padding;
134134
};
135135
}

Libraries/Text/RCTShadowTextView.h Libraries/Text/TextInput/Multiline/RCTMultilineTextInputShadowView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#import <React/RCTShadowView.h>
1111

12-
@interface RCTShadowTextView : RCTShadowView
12+
@interface RCTMultilineTextInputShadowView : RCTShadowView
1313

1414
@end

0 commit comments

Comments
 (0)