mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 14:25:08 +08:00
The New <Text> on iOS
Summary: This is a complete rewrite of RCTText, the part of React Native which manages Text and TextInput components. Key points: * It's understandable now. It follows a simple architectural pattern, and it's easy to debug and iterate. Text flow layout is a first-class citizen in React Native layout system now, not just a wired special case. It also brings entirely new possibilities such as nested interleaving <Text> and <View> components. * All <Text>-specific APIs were removed from UIManager and co (it's about ~16 public methods which were used exclusively only by <Text>). * It relies on new Yoga measurement/cloning API and on-dirty handler. So, it removes built-in dirty propagation subsystem from RN completely. * It caches string fragments properly and granularly on a per-node basis which makes updating text-containing components more performant. * It does not instantiate UIView for virtual components which reduces memory utilization. * It drastically improves <TextInput> capabilities (e.g. rich text inside single line <TextInput> is now supported). Screenshots: https://cl.ly/2j3r1V0L0324 https://cl.ly/3N2V3C3d3q3R Reviewed By: mmmulani Differential Revision: D6617326 fbshipit-source-id: 35d4d81b35c9870e9557d0211c0e934e6072a41e
This commit is contained in:
committed by
Facebook Github Bot
parent
cd263a2cc7
commit
2716f53220
@@ -9,15 +9,8 @@
|
||||
|
||||
#import "RCTSinglelineTextInputViewManager.h"
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTFont.h>
|
||||
#import <React/RCTShadowView+Layout.h>
|
||||
#import <React/RCTShadowView.h>
|
||||
|
||||
#import "RCTConvert+Text.h"
|
||||
#import "RCTSinglelineTextInputShadowView.h"
|
||||
#import "RCTBaseTextInputShadowView.h"
|
||||
#import "RCTSinglelineTextInputView.h"
|
||||
#import "RCTUITextField.h"
|
||||
|
||||
@implementation RCTSinglelineTextInputViewManager
|
||||
|
||||
@@ -25,7 +18,12 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (RCTShadowView *)shadowView
|
||||
{
|
||||
return [RCTSinglelineTextInputShadowView new];
|
||||
RCTBaseTextInputShadowView *shadowView =
|
||||
(RCTBaseTextInputShadowView *)[super shadowView];
|
||||
|
||||
shadowView.maximumNumberOfLines = 1;
|
||||
|
||||
return shadowView;
|
||||
}
|
||||
|
||||
- (UIView *)view
|
||||
@@ -33,10 +31,4 @@ RCT_EXPORT_MODULE()
|
||||
return [[RCTSinglelineTextInputView alloc] initWithBridge:self.bridge];
|
||||
}
|
||||
|
||||
#pragma mark - Singleline <TextInput> (aka TextField) specific properties
|
||||
|
||||
RCT_REMAP_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL)
|
||||
RCT_REMAP_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user