From 1725fd6bf1a7ba5923124048e6e5f35ff6a257e5 Mon Sep 17 00:00:00 2001 From: Adam Ernst Date: Sun, 15 Mar 2020 19:39:20 -0700 Subject: [PATCH] Simplify CKComponentHostingViewProtocol Summary: All current implementations of `CKComponentHostingViewProtocol` *contain* a `CKInspectableView`, so there is no need for the hosting view itself to conform. This also simplifies the Flipper plugin. Reviewed By: d16r Differential Revision: D20457822 fbshipit-source-id: 472f80f5bb2ee507862487d076cfb0e3de6416fa --- .../FlipperKitLayoutComponentKitSupport.mm | 7 ---- .../SKComponentHostingViewDescriptor.h | 9 ---- .../SKComponentHostingViewDescriptor.mm | 42 ------------------- 3 files changed, 58 deletions(-) diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm index c50f3aa67..c3048b19f 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm @@ -14,7 +14,6 @@ #import -#import "SKComponentHostingViewDescriptor.h" #import "SKComponentLayoutDescriptor.h" #import "SKComponentLayoutWrapper.h" #import "SKComponentRootViewDescriptor.h" @@ -24,9 +23,6 @@ + (void)setUpWithDescriptorMapper:(SKDescriptorMapper*)mapper subDescriptors:(NSArray*)subDescriptors { - [mapper registerDescriptor:[[SKComponentHostingViewDescriptor alloc] - initWithDescriptorMapper:mapper] - forClass:[CKComponentHostingView class]]; [mapper registerDescriptor:[[SKComponentRootViewDescriptor alloc] initWithDescriptorMapper:mapper] forClass:[CKComponentRootView class]]; @@ -40,9 +36,6 @@ + (void)setUpWithDescriptorMapper:(SKDescriptorMapper*)mapper { // What we really want here is "forProtocol:@protocol(CKInspectableView)" but // no such luck. - [mapper registerDescriptor:[[SKComponentHostingViewDescriptor alloc] - initWithDescriptorMapper:mapper] - forClass:[CKComponentHostingView class]]; [mapper registerDescriptor:[[SKComponentRootViewDescriptor alloc] initWithDescriptorMapper:mapper] forClass:[CKComponentRootView class]]; diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.h index cf9138475..8ecfd7c25 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.h +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.h @@ -4,12 +4,3 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ - -#import - -@class CKComponentHostingView; - -@interface SKComponentHostingViewDescriptor - : SKNodeDescriptor - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.mm index 2c351fde3..8ecfd7c25 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentHostingViewDescriptor.mm @@ -4,45 +4,3 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ - -#if FB_SONARKIT_ENABLED - -#import "SKComponentHostingViewDescriptor.h" -#import -#import -#import -#import -#import - -#import - -#import "SKComponentLayoutWrapper.h" - -@implementation SKComponentHostingViewDescriptor - -- (NSString*)identifierForNode:(CKComponentHostingView*)node { - return [NSString stringWithFormat:@"%p", node]; -} - -- (NSUInteger)childCountForNode:(CKComponentHostingView*)node { - return node.mountedLayout.component ? 1 : 0; -} - -- (id)childForNode:(CKComponentHostingView*)node atIndex:(NSUInteger)index { - return [SKComponentLayoutWrapper - newFromRoot:node - parentKey:[NSString stringWithFormat:@"%@.", node.uniqueIdentifier]]; -} - -- (void)setHighlighted:(BOOL)highlighted forNode:(CKComponentHostingView*)node { - SKNodeDescriptor* viewDescriptor = [self descriptorForClass:[UIView class]]; - [viewDescriptor setHighlighted:highlighted forNode:node]; -} - -- (void)hitTest:(SKTouch*)touch forNode:(CKComponentHostingView*)node { - [touch continueWithChildIndex:0 withOffset:(CGPoint){0, 0}]; -} - -@end - -#endif