mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers Differential Revision: D2651920 fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
This commit is contained in:
committed by
facebook-github-bot-4
parent
5a34a097f2
commit
fa0b45c58b
@@ -16,7 +16,6 @@
|
||||
#import "RCTImageComponent.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTShadowRawText.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTText.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@@ -81,17 +80,17 @@ static css_dim_t RCTMeasure(void *context, float width)
|
||||
[self dirtyText];
|
||||
}
|
||||
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
|
||||
{
|
||||
parentProperties = [super processUpdatedProperties:applierBlocks
|
||||
parentProperties:parentProperties];
|
||||
|
||||
UIEdgeInsets padding = self.paddingAsInsets;
|
||||
CGFloat width = self.frame.size.width - (padding.left + padding.right);
|
||||
|
||||
|
||||
NSTextStorage *textStorage = [self buildTextStorageForWidth:width];
|
||||
[applierBlocks addObject:^(RCTSparseArray *viewRegistry) {
|
||||
[applierBlocks addObject:^(NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
|
||||
RCTText *view = viewRegistry[self.reactTag];
|
||||
view.textStorage = textStorage;
|
||||
}];
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTTextField.h"
|
||||
|
||||
@interface RCTTextFieldManager() <UITextFieldDelegate>
|
||||
@@ -117,8 +116,8 @@ RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
||||
{
|
||||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
return ^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
((RCTTextField *)viewRegistry[reactTag]).contentInset = padding;
|
||||
return ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextField *> *viewRegistry) {
|
||||
viewRegistry[reactTag].contentInset = padding;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#import "RCTLog.h"
|
||||
#import "RCTShadowRawText.h"
|
||||
#import "RCTShadowText.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTText.h"
|
||||
#import "RCTTextView.h"
|
||||
#import "UIView+React.h"
|
||||
@@ -61,10 +60,10 @@ RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
||||
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNumber *, RCTShadowView *> *)shadowViewRegistry
|
||||
{
|
||||
NSMutableSet *textViewTagsToUpdate = [NSMutableSet new];
|
||||
for (RCTShadowView *rootView in shadowViewRegistry.allObjects) {
|
||||
for (RCTShadowView *rootView in shadowViewRegistry.allValues) {
|
||||
if (![rootView isReactRootView]) {
|
||||
// This isn't a root view
|
||||
continue;
|
||||
@@ -135,7 +134,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
||||
CGFloat width = shadowText.frame.size.width - (padding.left + padding.right);
|
||||
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width];
|
||||
|
||||
[uiBlocks addObject:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[uiBlocks addObject:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
|
||||
RCTTextView *textView = viewRegistry[reactTag];
|
||||
RCTText *text;
|
||||
for (RCTText *subview in textView.reactSubviews) {
|
||||
@@ -150,7 +149,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
||||
}];
|
||||
}
|
||||
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
for (RCTViewManagerUIBlock uiBlock in uiBlocks) {
|
||||
uiBlock(uiManager, viewRegistry);
|
||||
}
|
||||
@@ -165,7 +164,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
||||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
|
||||
RCTText *text = viewRegistry[reactTag];
|
||||
text.contentInset = padding;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
NSInteger _nativeEventCount;
|
||||
RCTText *_richTextView;
|
||||
NSAttributedString *_pendingAttributedText;
|
||||
NSMutableArray<UIView<RCTComponent> *> *_subviews;
|
||||
NSMutableArray<UIView *> *_subviews;
|
||||
BOOL _blockTextShouldChange;
|
||||
UITextRange *_previousSelectionRange;
|
||||
}
|
||||
@@ -71,12 +71,12 @@
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
return _subviews;
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView<RCTComponent> *)subview atIndex:(NSInteger)index
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)index
|
||||
{
|
||||
if ([subview isKindOfClass:[RCTText class]]) {
|
||||
if (_richTextView) {
|
||||
@@ -90,7 +90,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView<RCTComponent> *)subview
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
if (_richTextView == subview) {
|
||||
[_subviews removeObject:_richTextView];
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTTextView.h"
|
||||
|
||||
@implementation RCTTextViewManager
|
||||
@@ -61,8 +60,8 @@ RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
||||
{
|
||||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
((RCTTextView *)viewRegistry[reactTag]).contentInset = padding;
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
|
||||
viewRegistry[reactTag].contentInset = padding;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user