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:
Kfir Schindelhaim
2019-04-26 10:11:43 -07:00
committed by Facebook Github Bot
parent f00ff72211
commit c764322c1a
4 changed files with 57 additions and 12 deletions

View File

@@ -61,6 +61,10 @@ FB_LINKABLE(CKComponent_Sonar)
if ([self respondsToSelector:@selector(sonar_componentNameOverride)]) {
return [(id)self sonar_componentNameOverride];
}
auto const canBeReusedCounter = self.flipper_canBeReusedCounter;
if (canBeReusedCounter > 0) {
return [NSString stringWithFormat:@"%@ (Can be reused x%lu)", NSStringFromClass([self class]), (unsigned long)canBeReusedCounter];
}
return NSStringFromClass([self class]);
}
@@ -98,10 +102,19 @@ FB_LINKABLE(CKComponent_Sonar)
NSMutableArray<SKNamed<NSDictionary<NSString *, NSObject *> *> *> *data = [NSMutableArray new];
[data addObject: [SKNamed newWithName: @"CKComponent"
withValue: @{
@"frame": SKObject(self.viewContext.frame),
@"controller": SKObject(NSStringFromClass([self.controller class])),
}]];
withValue: @{
@"frame": SKObject(self.viewContext.frame),
@"controller": SKObject(NSStringFromClass([self.controller class])),
}]];
auto const canBeReusedCounter = self.flipper_canBeReusedCounter;
if (canBeReusedCounter > 0) {
[data addObject: [SKNamed newWithName: @"Convert to CKRenderComponent"
withValue: @{
@"This component can be reused" :
SKObject([NSString stringWithFormat:@"%lu times", (unsigned long)canBeReusedCounter])
}]];
}
if (self.viewContext.view) {
auto _actions = _CKComponentDebugControlActionsForComponent(self);
@@ -172,6 +185,18 @@ FB_LINKABLE(CKComponent_Sonar)
};
}
static char const kCanBeReusedKey = ' ';
- (void)setFlipper_canBeReusedCounter:(NSUInteger)canBeReusedCounter
{
objc_setAssociatedObject(self, &kCanBeReusedKey, @(canBeReusedCounter), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (NSUInteger)flipper_canBeReusedCounter
{
return [objc_getAssociatedObject(self, &kCanBeReusedKey) unsignedIntegerValue];
}
@end
#endif