mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-02 23:05:01 +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
@@ -11,22 +11,17 @@
|
||||
|
||||
#import <React/RCTView.h>
|
||||
|
||||
#import "RCTBackedTextInputDelegate.h"
|
||||
#import "RCTBackedTextInputViewProtocol.h"
|
||||
#import "RCTFontAttributes.h"
|
||||
#import "RCTFontAttributesDelegate.h"
|
||||
|
||||
@class RCTBridge;
|
||||
@class RCTEventDispatcher;
|
||||
@class RCTTextAttributes;
|
||||
@class RCTTextSelection;
|
||||
|
||||
@interface RCTBaseTextInputView : RCTView <RCTFontAttributesDelegate> {
|
||||
@protected
|
||||
__weak RCTBridge *_bridge;
|
||||
RCTEventDispatcher *_eventDispatcher;
|
||||
NSInteger _nativeEventCount;
|
||||
NSInteger _mostRecentEventCount;
|
||||
BOOL _blurOnSubmit;
|
||||
}
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTBaseTextInputView : RCTView <RCTBackedTextInputDelegate>
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@@ -36,33 +31,24 @@
|
||||
|
||||
@property (nonatomic, readonly) UIView<RCTBackedTextInputViewProtocol> *backedTextInputView;
|
||||
|
||||
@property (nonatomic, strong, nullable) RCTTextAttributes *textAttributes;
|
||||
@property (nonatomic, assign) UIEdgeInsets reactPaddingInsets;
|
||||
@property (nonatomic, assign) UIEdgeInsets reactBorderInsets;
|
||||
@property (nonatomic, assign, readonly) CGSize contentSize;
|
||||
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onContentSizeChange;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onSelectionChange;
|
||||
|
||||
@property (nonatomic, readonly, strong) RCTFontAttributes *fontAttributes;
|
||||
@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
|
||||
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
|
||||
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChange;
|
||||
@property (nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
|
||||
@property (nonatomic, copy, nullable) RCTDirectEventBlock onScroll;
|
||||
|
||||
@property (nonatomic, assign) NSInteger mostRecentEventCount;
|
||||
@property (nonatomic, assign) BOOL blurOnSubmit;
|
||||
@property (nonatomic, assign) BOOL selectTextOnFocus;
|
||||
@property (nonatomic, assign) BOOL clearTextOnFocus;
|
||||
@property (nonatomic, copy) RCTTextSelection *selection;
|
||||
|
||||
- (void)setFont:(UIFont *)font;
|
||||
|
||||
- (void)invalidateContentSize;
|
||||
|
||||
// Temporary exposure of particial `RCTBackedTextInputDelegate` support.
|
||||
// In the future all methods of the protocol should move to this class.
|
||||
- (BOOL)textInputShouldBeginEditing;
|
||||
- (void)textInputDidBeginEditing;
|
||||
- (BOOL)textInputShouldReturn;
|
||||
- (void)textInputDidReturn;
|
||||
- (void)textInputDidChangeSelection;
|
||||
- (BOOL)textInputShouldEndEditing;
|
||||
- (void)textInputDidEndEditing;
|
||||
@property (nonatomic, strong, nullable) NSNumber *maxLength;
|
||||
@property (nonatomic, copy) NSAttributedString *attributedText;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Reference in New Issue
Block a user