Fabric: Introducing `-[RCTComponentViewProtocol componentHandle]`
Summary: The new method in the protocol enforces view component classes to expose a component handle of the component that the view component represents. That will allow us to wire up those classes with shadow views in runtime explicitly and in a much more performant way than it is now. Reviewed By: mdvacca Differential Revision: D13114663 fbshipit-source-id: 853187d978aab200f85719d9c1d9fea2e3ad4e55
This commit is contained in:
Родитель
89f647d521
Коммит
eef3df86fb
|
@ -7,6 +7,7 @@
|
|||
|
||||
#import "RCTActivityIndicatorViewComponentView.h"
|
||||
|
||||
#import <react/components/activityindicator/ActivityIndicatorViewShadowNode.h>
|
||||
#import <react/components/activityindicator/ActivityIndicatorViewProps.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
@ -24,6 +25,13 @@ static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const Acti
|
|||
UIActivityIndicatorView *_activityIndicatorView;
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return ActivityIndicatorViewShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import <react/components/image/ImageEventEmitter.h>
|
||||
#import <react/components/image/ImageLocalData.h>
|
||||
#import <react/components/image/ImageProps.h>
|
||||
#import <react/components/image/ImageShadowNode.h>
|
||||
#import <react/imagemanager/ImageRequest.h>
|
||||
#import <react/imagemanager/ImageResponse.h>
|
||||
#import <react/imagemanager/RCTImagePrimitivesConversions.h>
|
||||
|
@ -43,6 +44,11 @@ using namespace facebook::react;
|
|||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return ImageShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
|
||||
{
|
||||
const auto &oldImageProps = *std::static_pointer_cast<const ImageProps>(oldProps ?: _props);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#import "RCTRootComponentView.h"
|
||||
|
||||
#import <react/components/root/RootShadowNode.h>
|
||||
#import <react/components/root/RootProps.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
@ -23,4 +24,9 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return RootShadowNode::Handle();
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#import "RCTScrollViewComponentView.h"
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <react/components/scrollview/ScrollViewShadowNode.h>
|
||||
#import <react/components/scrollview/ScrollViewLocalData.h>
|
||||
#import <react/components/scrollview/ScrollViewProps.h>
|
||||
#import <react/components/scrollview/ScrollViewEventEmitter.h>
|
||||
|
@ -48,7 +49,12 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - ComponentViewProtocol
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return ScrollViewShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#import <react/components/switch/SwitchEventEmitter.h>
|
||||
#import <react/components/switch/SwitchProps.h>
|
||||
#import <react/components/switch/SwitchShadowNode.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
|
@ -37,6 +38,13 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return SwitchShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
|
||||
{
|
||||
const auto &oldSwitchProps = *std::static_pointer_cast<const SwitchProps>(oldProps ?: _props);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#import <react/components/text/ParagraphLocalData.h>
|
||||
#import <react/components/text/ParagraphProps.h>
|
||||
#import <react/components/text/ParagraphShadowNode.h>
|
||||
#import <react/core/LocalData.h>
|
||||
#import <react/graphics/Geometry.h>
|
||||
#import <react/textlayoutmanager/TextLayoutManager.h>
|
||||
|
@ -37,6 +38,13 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
return ParagraphShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
|
||||
{
|
||||
const auto ¶graphProps = std::static_pointer_cast<const ParagraphProps>(props);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#import "RCTViewComponentView.h"
|
||||
|
||||
#import <react/components/view/ViewShadowNode.h>
|
||||
#import <react/components/view/ViewProps.h>
|
||||
#import <react/components/view/ViewEventEmitter.h>
|
||||
#import <objc/runtime.h>
|
||||
|
@ -78,6 +79,16 @@ using namespace facebook::react;
|
|||
_backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentHandle)componentHandle
|
||||
{
|
||||
RCTAssert(
|
||||
self == [RCTViewComponentView class],
|
||||
@"`+[RCTComponentViewProtocol componentHandle]` must be implemented for all subclasses (and `%@` particularly).", NSStringFromClass([self class]));
|
||||
return ViewShadowNode::Handle();
|
||||
}
|
||||
|
||||
- (void)updateProps:(SharedProps)props
|
||||
oldProps:(SharedProps)oldProps
|
||||
{
|
||||
|
|
|
@ -23,6 +23,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
@protocol RCTComponentViewProtocol <NSObject>
|
||||
|
||||
/*
|
||||
* Returns ComponentHandle of ComponentDescriptor which this ComponentView
|
||||
* represents.
|
||||
*/
|
||||
+ (facebook::react::ComponentHandle)componentHandle;
|
||||
|
||||
/*
|
||||
* Called for mounting (attaching) a child component view inside `self`
|
||||
* component view.
|
||||
|
|
Загрузка…
Ссылка в новой задаче