Introduce CKMountable protocol
Summary: - Introduce new base protocol `CKMountable` - Contains Layout & Mount methods that have been extracted from `CKComponent` - This will allows us to introduce a new lighter version of `CKComponent`, which doesn't rely on Scope/State/Controllers/etc - Refactor `CKComponentLayout` to work with `CKMountable` instead of `CKComponent`, which will allows us to interop between `CKComponent` and a new type of components. - Refactor the codebase to support this change Reviewed By: kevin0571 Differential Revision: D17668253 fbshipit-source-id: 13db5ff4acb37b338e291ca2dd7d67cd25dbc6d2
This commit is contained in:
committed by
Facebook Github Bot
parent
9bad9ba976
commit
52976f1ee3
@@ -51,17 +51,19 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
return cachedWrapper;
|
||||
}
|
||||
}
|
||||
CKComponentReuseWrapper *reuseWrapper = CKAnalyticsListenerHelpers::GetReusedNodes(layout.component);
|
||||
// TODO: Add support for `CKMountable` components.
|
||||
CKComponent *component = (CKComponent *)layout.component;
|
||||
CKComponentReuseWrapper *reuseWrapper = CKAnalyticsListenerHelpers::GetReusedNodes(component);
|
||||
// Create a new layout wrapper.
|
||||
SKComponentLayoutWrapper *const wrapper =
|
||||
[[SKComponentLayoutWrapper alloc] initWithLayout:layout
|
||||
position:CGPointMake(0, 0)
|
||||
parentKey:[NSString stringWithFormat: @"%d.", layout.component.treeNode.nodeIdentifier]
|
||||
parentKey:[NSString stringWithFormat: @"%d.", component.treeNode.nodeIdentifier]
|
||||
reuseWrapper:reuseWrapper
|
||||
rootNode: root];
|
||||
// Cache the result.
|
||||
if (layout.component) {
|
||||
objc_setAssociatedObject(layout.component, &kLayoutWrapperKey, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
if (component) {
|
||||
objc_setAssociatedObject(component, &kLayoutWrapperKey, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
@@ -74,7 +76,7 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_rootNode = node;
|
||||
_component = layout.component;
|
||||
_component = (CKComponent *)layout.component;
|
||||
_size = layout.size;
|
||||
_position = position;
|
||||
_identifier = [parentKey stringByAppendingString:layout.component ? NSStringFromClass([layout.component class]) : @"(null)"];
|
||||
@@ -99,7 +101,7 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
rootNode:node
|
||||
];
|
||||
childWrapper->_isFlexboxChild = [_component isKindOfClass:[CKFlexboxComponent class]];
|
||||
childWrapper->_flexboxChild = findFlexboxLayoutParams(_component, child.layout.component);
|
||||
childWrapper->_flexboxChild = findFlexboxLayoutParams(_component, (CKComponent *)child.layout.component);
|
||||
_children.push_back(childWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user