Permalink
Browse files

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
  • Loading branch information...
shergin authored and facebook-github-bot committed Dec 20, 2017
1 parent 5c8481e commit 19a9c5e41da0aa6ee28a54772edcb92daa498561
Showing with 385 additions and 251 deletions.
  1. +2 −2 Libraries/Components/ScrollResponder.js
  2. +6 −6 Libraries/Components/TextInput/TextInput.js
  3. +1 −1 Libraries/Text/{RCTShadowRawText.h → RCTRawTextShadowView.h}
  4. +2 −2 Libraries/Text/{RCTShadowRawText.m → RCTRawTextShadowView.m}
  5. +1 −1 Libraries/Text/{RCTRawTextManager.h → RCTRawTextViewManager.h}
  6. +5 −5 Libraries/Text/{RCTRawTextManager.m → RCTRawTextViewManager.m}
  7. +248 −138 Libraries/Text/RCTText.xcodeproj/project.pbxproj
  8. +1 −1 Libraries/Text/{RCTShadowText.h → Text/RCTTextShadowView.h}
  9. +21 −21 Libraries/Text/{RCTShadowText.m → Text/RCTTextShadowView.m}
  10. +1 −1 Libraries/Text/{RCTText.h → Text/RCTTextView.h}
  11. +6 −6 Libraries/Text/{RCTText.m → Text/RCTTextView.m}
  12. 0 Libraries/Text/{ → Text}/RCTTextViewManager.h
  13. +22 −22 Libraries/Text/{RCTTextManager.m → Text/RCTTextViewManager.m}
  14. +1 −1 Libraries/Text/{RCTShadowTextView.h → TextInput/Multiline/RCTMultilineTextInputShadowView.h}
  15. +2 −2 Libraries/Text/{RCTShadowTextView.m → TextInput/Multiline/RCTMultilineTextInputShadowView.m}
  16. +2 −2 Libraries/Text/{RCTTextView.h → TextInput/Multiline/RCTMultilineTextInputView.h}
  17. +8 −8 Libraries/Text/{RCTTextView.m → TextInput/Multiline/RCTMultilineTextInputView.m}
  18. +1 −1 Libraries/Text/{RCTTextFieldManager.h → TextInput/Multiline/RCTMultilineTextInputViewManager.h}
  19. +8 −8 Libraries/Text/{RCTTextViewManager.m → TextInput/Multiline/RCTMultilineTextInputViewManager.m}
  20. 0 Libraries/Text/{ → TextInput/Multiline}/RCTUITextView.h
  21. 0 Libraries/Text/{ → TextInput/Multiline}/RCTUITextView.m
  22. 0 Libraries/Text/{ → TextInput}/RCTBackedTextInputDelegate.h
  23. 0 Libraries/Text/{ → TextInput}/RCTBackedTextInputDelegateAdapter.h
  24. 0 Libraries/Text/{ → TextInput}/RCTBackedTextInputDelegateAdapter.m
  25. 0 Libraries/Text/{ → TextInput}/RCTBackedTextInputViewProtocol.h
  26. +1 −1 Libraries/Text/{RCTTextInput.h → TextInput/RCTBaseTextInputView.h}
  27. +3 −3 Libraries/Text/{RCTTextInput.m → TextInput/RCTBaseTextInputView.m}
  28. 0 Libraries/Text/{ → TextInput}/RCTTextSelection.h
  29. 0 Libraries/Text/{ → TextInput}/RCTTextSelection.m
  30. +1 −1 Libraries/Text/{RCTShadowTextField.h → TextInput/Singleline/RCTSinglelineTextInputShadowView.h}
  31. +2 −2 Libraries/Text/{RCTShadowTextField.m → TextInput/Singleline/RCTSinglelineTextInputShadowView.m}
  32. +2 −2 Libraries/Text/{RCTTextField.h → TextInput/Singleline/RCTSinglelineTextInputView.h}
  33. +3 −3 Libraries/Text/{RCTTextField.m → TextInput/Singleline/RCTSinglelineTextInputView.m}
  34. +1 −1 Libraries/Text/{RCTTextManager.h → TextInput/Singleline/RCTSinglelineTextInputViewManager.h}
  35. +8 −8 Libraries/Text/{RCTTextFieldManager.m → TextInput/Singleline/RCTSinglelineTextInputViewManager.m}
  36. 0 Libraries/Text/{ → TextInput/Singleline}/RCTUITextField.h
  37. 0 Libraries/Text/{ → TextInput/Singleline}/RCTUITextField.m
  38. +24 −0 React/React.xcodeproj/project.pbxproj
  39. +1 −1 React/Views/RCTShadowView.h
  40. +1 −1 React/Views/RCTShadowView.m
@@ -126,8 +126,8 @@ function isTagInstanceOfTextInput(tag) {
var instance = getInstanceFromNode(tag);
return instance && instance.viewConfig && (
instance.viewConfig.uiViewClassName === 'AndroidTextInput' ||
instance.viewConfig.uiViewClassName === 'RCTTextView' ||
instance.viewConfig.uiViewClassName === 'RCTTextField'
instance.viewConfig.uiViewClassName === 'RCTMultilineTextInputView' ||
instance.viewConfig.uiViewClassName === 'RCTSinglelineTextInputView'
);
}
@@ -50,8 +50,8 @@ const onlyMultiline = {
if (Platform.OS === 'android') {
var AndroidTextInput = requireNativeComponent('AndroidTextInput', null);
} else if (Platform.OS === 'ios') {
var RCTTextView = requireNativeComponent('RCTTextView', null);
var RCTTextField = requireNativeComponent('RCTTextField', null);
var RCTMultilineTextInputView = requireNativeComponent('RCTMultilineTextInputView', null);
var RCTSinglelineTextInputView = requireNativeComponent('RCTSinglelineTextInputView', null);
}
type Event = Object;
@@ -707,7 +707,7 @@ const TextInput = createReactClass({
}
}
textContainer =
<RCTTextField
<RCTSinglelineTextInputView
ref={this._setNativeRef}
{...props}
onFocus={this._onFocus}
@@ -733,7 +733,7 @@ const TextInput = createReactClass({
}
props.style.unshift(styles.multilineInput);
textContainer =
<RCTTextView
<RCTMultilineTextInputView
ref={this._setNativeRef}
{...props}
children={children}
@@ -926,8 +926,8 @@ const TextInput = createReactClass({
var styles = StyleSheet.create({
multilineInput: {
// This default top inset makes RCTTextView seem as close as possible
// to single-line RCTTextField defaults, using the system defaults
// This default top inset makes RCTMultilineTextInputView seem as close as possible
// to single-line RCTSinglelineTextInputView defaults, using the system defaults
// of font size 17 and a height of 31 points.
paddingTop: 5,
},
@@ -9,7 +9,7 @@
#import <React/RCTShadowView.h>
@interface RCTShadowRawText : RCTShadowView
@interface RCTRawTextShadowView : RCTShadowView
@property (nonatomic, copy) NSString *text;
@@ -7,11 +7,11 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTShadowRawText.h"
#import "RCTRawTextShadowView.h"
#import <React/RCTUIManager.h>
@implementation RCTShadowRawText
@implementation RCTRawTextShadowView
- (instancetype)init
{
@@ -9,6 +9,6 @@
#import <React/RCTViewManager.h>
@interface RCTRawTextManager : RCTViewManager
@interface RCTRawTextViewManager : RCTViewManager
@end
@@ -7,17 +7,17 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTRawTextManager.h"
#import "RCTRawTextViewManager.h"
#import "RCTShadowRawText.h"
#import "RCTRawTextShadowView.h"
@implementation RCTRawTextManager
@implementation RCTRawTextViewManager
RCT_EXPORT_MODULE()
RCT_EXPORT_MODULE(RCTRawText)
- (RCTShadowView *)shadowView
{
return [RCTShadowRawText new];
return [RCTRawTextShadowView new];
}
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, RCTSizeComparison)
extern NSString *const RCTIsHighlightedAttributeName;
extern NSString *const RCTReactTagAttributeName;
@interface RCTShadowText : RCTShadowView
@interface RCTTextShadowView : RCTShadowView
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, strong) UIColor *backgroundColor;
@@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTShadowText.h"
#import "RCTTextShadowView.h"
#import <React/RCTAccessibilityManager.h>
#import <React/RCTBridge.h>
@@ -18,9 +18,9 @@
#import <React/RCTUIManager.h>
#import <React/RCTUtils.h>
#import "RCTShadowRawText.h"
#import "RCTText.h"
#import "RCTRawTextShadowView.h"
#import "RCTTextView.h"
#import "RCTMultilineTextInputView.h"
NSString *const RCTIsHighlightedAttributeName = @"IsHighlightedAttributeName";
NSString *const RCTReactTagAttributeName = @"ReactTagAttributeName";
@@ -31,7 +31,7 @@
static CGFloat const kAutoSizeHeightErrorMargin = 0.025f;
static CGFloat const kAutoSizeGranularity = 0.001f;
@implementation RCTShadowText
@implementation RCTTextShadowView
{
NSTextStorage *_cachedTextStorage;
CGFloat _cachedTextStorageWidth;
@@ -43,7 +43,7 @@ @implementation RCTShadowText
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
{
RCTShadowText *shadowText = (__bridge RCTShadowText *)YGNodeGetContext(node);
RCTTextShadowView *shadowText = (__bridge RCTTextShadowView *)YGNodeGetContext(node);
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width widthMode:widthMode];
[shadowText calculateTextFrame:textStorage];
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
@@ -109,7 +109,7 @@ - (void)contentSizeMultiplierDidChange:(NSNotification *)note
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
{
if ([[self reactSuperview] isKindOfClass:[RCTShadowText class]]) {
if ([[self reactSuperview] isKindOfClass:[RCTTextShadowView class]]) {
return parentProperties;
}
@@ -122,22 +122,22 @@ - (void)contentSizeMultiplierDidChange:(NSNotification *)note
CGRect textFrame = [self calculateTextFrame:textStorage];
BOOL selectable = _selectable;
[applierBlocks addObject:^(NSDictionary<NSNumber *, UIView *> *viewRegistry) {
RCTText *view = (RCTText *)viewRegistry[self.reactTag];
RCTTextView *view = (RCTTextView *)viewRegistry[self.reactTag];
view.textFrame = textFrame;
view.textStorage = textStorage;
view.selectable = selectable;
/**
* NOTE: this logic is included to support rich text editing inside multiline
* `<TextInput>` controls. It is required in order to ensure that the
* textStorage (aka attributed string) is copied over from the RCTShadowText
* to the RCTText view in time to be used to update the editable text content.
* TODO: we should establish a delegate relationship betweeen RCTTextView
* and its contaned RCTText element when they get inserted and get rid of this
* textStorage (aka attributed string) is copied over from the RCTTextShadowView
* to the RCTTextView view in time to be used to update the editable text content.
* TODO: we should establish a delegate relationship betweeen RCTMultilineTextInputView
* and its contaned RCTTextView element when they get inserted and get rid of this
*/
UIView *parentView = viewRegistry[parentTag];
if ([parentView respondsToSelector:@selector(performTextUpdate)]) {
[(RCTTextView *)parentView performTextUpdate];
[(RCTMultilineTextInputView *)parentView performTextUpdate];
}
}];
@@ -308,8 +308,8 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
CGFloat heightOfTallestSubview = 0.0;
NSMutableAttributedString *attributedString = [NSMutableAttributedString new];
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
RCTShadowText *shadowText = (RCTShadowText *)child;
if ([child isKindOfClass:[RCTTextShadowView class]]) {
RCTTextShadowView *shadowText = (RCTTextShadowView *)child;
[attributedString appendAttributedString:
[shadowText _attributedStringWithFontFamily:fontFamily
fontSize:fontSize
@@ -321,8 +321,8 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
backgroundColor:shadowText.backgroundColor ?: backgroundColor
opacity:opacity * shadowText.opacity]];
[child setTextComputed];
} else if ([child isKindOfClass:[RCTShadowRawText class]]) {
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
} else if ([child isKindOfClass:[RCTRawTextShadowView class]]) {
RCTRawTextShadowView *shadowRawText = (RCTRawTextShadowView *)child;
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
[child setTextComputed];
} else {
@@ -340,7 +340,7 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
if (height > heightOfTallestSubview) {
heightOfTallestSubview = height;
}
// Don't call setTextComputed on this child. RCTTextManager takes care of
// Don't call setTextComputed on this child. RCTTextViewManager takes care of
// processing inline UIViews.
}
}
@@ -653,8 +653,8 @@ - (void)setAllowFontScaling:(BOOL)allowFontScaling
{
_allowFontScaling = allowFontScaling;
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
((RCTShadowText *)child).allowFontScaling = allowFontScaling;
if ([child isKindOfClass:[RCTTextShadowView class]]) {
((RCTTextShadowView *)child).allowFontScaling = allowFontScaling;
}
}
[self dirtyText];
@@ -668,8 +668,8 @@ - (void)setFontSizeMultiplier:(CGFloat)fontSizeMultiplier
_fontSizeMultiplier = 1.0;
}
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier;
if ([child isKindOfClass:[RCTTextShadowView class]]) {
((RCTTextShadowView *)child).fontSizeMultiplier = fontSizeMultiplier;
}
}
[self dirtyText];
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
@interface RCTText : UIView
@interface RCTTextView : UIView
@property (nonatomic, assign) UIEdgeInsets contentInset;
@property (nonatomic, strong) NSTextStorage *textStorage;
@@ -7,27 +7,27 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTText.h"
#import "RCTTextView.h"
#import <MobileCoreServices/UTCoreTypes.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>
#import "RCTShadowText.h"
#import "RCTTextShadowView.h"
static void collectNonTextDescendants(RCTText *view, NSMutableArray *nonTextDescendants)
static void collectNonTextDescendants(RCTTextView *view, NSMutableArray *nonTextDescendants)
{
for (UIView *child in view.reactSubviews) {
if ([child isKindOfClass:[RCTText class]]) {
collectNonTextDescendants((RCTText *)child, nonTextDescendants);
if ([child isKindOfClass:[RCTTextView class]]) {
collectNonTextDescendants((RCTTextView *)child, nonTextDescendants);
} else if (!CGRectEqualToRect(child.frame, CGRectZero)) {
[nonTextDescendants addObject:child];
}
}
}
@implementation RCTText
@implementation RCTTextView
{
NSTextStorage *_textStorage;
CAShapeLayer *_highlightLayer;
@@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTTextManager.h"
#import "RCTTextViewManager.h"
#import <React/RCTAccessibilityManager.h>
#import <React/RCTAssert.h>
@@ -17,42 +17,42 @@
#import <React/UIView+React.h>
#import <yoga/Yoga.h>
#import "RCTShadowRawText.h"
#import "RCTShadowText.h"
#import "RCTText.h"
#import "RCTRawTextShadowView.h"
#import "RCTTextShadowView.h"
#import "RCTTextView.h"
#import "RCTMultilineTextInputView.h"
static void collectDirtyNonTextDescendants(RCTShadowText *shadowView, NSMutableArray *nonTextDescendants) {
static void collectDirtyNonTextDescendants(RCTTextShadowView *shadowView, NSMutableArray *nonTextDescendants) {
for (RCTShadowView *child in shadowView.reactSubviews) {
if ([child isKindOfClass:[RCTShadowText class]]) {
collectDirtyNonTextDescendants((RCTShadowText *)child, nonTextDescendants);
} else if ([child isKindOfClass:[RCTShadowRawText class]]) {
if ([child isKindOfClass:[RCTTextShadowView class]]) {
collectDirtyNonTextDescendants((RCTTextShadowView *)child, nonTextDescendants);
} else if ([child isKindOfClass:[RCTRawTextShadowView class]]) {
// no-op
} else if ([child isTextDirty]) {
[nonTextDescendants addObject:child];
}
}
}
@interface RCTShadowText (Private)
@interface RCTTextShadowView (Private)
- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width widthMode:(YGMeasureMode)widthMode;
@end
@implementation RCTTextManager
@implementation RCTTextViewManager
RCT_EXPORT_MODULE()
RCT_EXPORT_MODULE(RCTText)
- (UIView *)view
{
return [RCTText new];
return [RCTTextView new];
}
- (RCTShadowView *)shadowView
{
return [RCTShadowText new];
return [RCTTextShadowView new];
}
#pragma mark - Shadow properties
@@ -101,13 +101,13 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNu
RCTShadowView *shadowView = queue[i];
RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text");
if ([shadowView isKindOfClass:[RCTShadowText class]]) {
((RCTShadowText *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier;
[(RCTShadowText *)shadowView recomputeText];
collectDirtyNonTextDescendants((RCTShadowText *)shadowView, queue);
} else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) {
if ([shadowView isKindOfClass:[RCTTextShadowView class]]) {
((RCTTextShadowView *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier;
[(RCTTextShadowView *)shadowView recomputeText];
collectDirtyNonTextDescendants((RCTTextShadowView *)shadowView, queue);
} else if ([shadowView isKindOfClass:[RCTRawTextShadowView class]]) {
RCTLogError(@"Raw text cannot be used outside of a <Text> tag. Not rendering string: '%@'",
[(RCTShadowRawText *)shadowView text]);
[(RCTRawTextShadowView *)shadowView text]);
} else {
for (RCTShadowView *child in [shadowView reactSubviews]) {
if ([child isTextDirty]) {
@@ -123,13 +123,13 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNu
return nil;
}
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowView
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTTextShadowView *)shadowView
{
NSNumber *reactTag = shadowView.reactTag;
UIEdgeInsets padding = shadowView.paddingAsInsets;
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
RCTText *text = viewRegistry[reactTag];
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
RCTTextView *text = viewRegistry[reactTag];
text.contentInset = padding;
};
}
@@ -9,6 +9,6 @@
#import <React/RCTShadowView.h>
@interface RCTShadowTextView : RCTShadowView
@interface RCTMultilineTextInputShadowView : RCTShadowView
@end
Oops, something went wrong.

0 comments on commit 19a9c5e

Please sign in to comment.