Layout plugin integration for reused nodes information
Summary: - Expose the reused component counter into the layout plugin https://pxl.cl/wVJf Reviewed By: priteshrnandgaonkar Differential Revision: D14952906 fbshipit-source-id: 784a02dbf44d80d95fdd3a804f58ecd0f51a3e1f
This commit is contained in:
committed by
Facebook Github Bot
parent
f00ff72211
commit
c764322c1a
@@ -9,12 +9,16 @@
|
||||
|
||||
#import "SKComponentLayoutWrapper.h"
|
||||
|
||||
#import <ComponentKit/CKAnalyticsListenerHelpers.h>
|
||||
#import <ComponentKit/CKComponent.h>
|
||||
#import <ComponentKit/CKComponentInternal.h>
|
||||
#import <ComponentKit/CKComponentRootView.h>
|
||||
#import <ComponentKit/CKComponentAttachController.h>
|
||||
#import <ComponentKit/CKComponentAttachControllerInternal.h>
|
||||
#import <ComponentKit/CKInspectableView.h>
|
||||
|
||||
#import "CKComponent+Sonar.h"
|
||||
|
||||
static char const kLayoutWrapperKey = ' ';
|
||||
|
||||
static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKComponent *child) {
|
||||
@@ -41,22 +45,36 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
|
||||
+ (instancetype)newFromRoot:(id<CKInspectableView>)root {
|
||||
const CKComponentLayout layout = [root mountedLayout];
|
||||
CKComponentReuseWrapper *reuseWrapper = CKAnalyticsListenerHelpers::GetReusedNodes(layout.component);
|
||||
SKComponentLayoutWrapper *const wrapper =
|
||||
[[SKComponentLayoutWrapper alloc] initWithLayout:layout
|
||||
position:CGPointMake(0, 0)
|
||||
parentKey:[NSString stringWithFormat: @"%p.", layout.component]];
|
||||
if (layout.component)
|
||||
parentKey:[NSString stringWithFormat: @"%p.", layout.component]
|
||||
reuseWrapper:reuseWrapper];
|
||||
if (layout.component) {
|
||||
objc_setAssociatedObject(layout.component, &kLayoutWrapperKey, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
- (instancetype)initWithLayout:(const CKComponentLayout &)layout position:(CGPoint)position parentKey:(NSString *)parentKey {
|
||||
- (instancetype)initWithLayout:(const CKComponentLayout &)layout
|
||||
position:(CGPoint)position
|
||||
parentKey:(NSString *)parentKey
|
||||
reuseWrapper:(CKComponentReuseWrapper *)reuseWrapper
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_component = layout.component;
|
||||
_size = layout.size;
|
||||
_position = position;
|
||||
_identifier = [parentKey stringByAppendingString:layout.component ? NSStringFromClass([layout.component class]) : @"(null)"];
|
||||
|
||||
if (_component && reuseWrapper) {
|
||||
auto const canBeReusedCounter = [reuseWrapper canBeReusedCounter:_component.treeNode.nodeIdentifier];
|
||||
if (canBeReusedCounter > 0) {
|
||||
_component.flipper_canBeReusedCounter = canBeReusedCounter;
|
||||
}
|
||||
}
|
||||
|
||||
if (layout.children != nullptr) {
|
||||
int index = 0;
|
||||
for (const auto &child : *layout.children) {
|
||||
@@ -65,7 +83,8 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
}
|
||||
SKComponentLayoutWrapper *childWrapper = [[SKComponentLayoutWrapper alloc] initWithLayout:child.layout
|
||||
position:child.position
|
||||
parentKey:[_identifier stringByAppendingFormat:@"[%d].", index++]];
|
||||
parentKey:[_identifier stringByAppendingFormat:@"[%d].", index++]
|
||||
reuseWrapper:reuseWrapper];
|
||||
childWrapper->_isFlexboxChild = [_component isKindOfClass:[CKFlexboxComponent class]];
|
||||
childWrapper->_flexboxChild = findFlexboxLayoutParams(_component, child.layout.component);
|
||||
_children.push_back(childWrapper);
|
||||
|
||||
Reference in New Issue
Block a user