Show mounted ComponentKit views in Flipper

Summary:
Before this diff, Flipper showed *leaf* views created by ComponentKit, but not any intermediate views. Now we show both.

A new node type `SKComponentMountedView` is used for this purpose. Its descriptor `SKComponentMountedViewDescriptor` mostly delegates to its view's descriptor, but redirects back into ComponentKit for children.

Reviewed By: Andrey-Mishanin

Differential Revision: D21130997

fbshipit-source-id: b3c12ea7cc1200962b3ba7c269c48d68b1809948
This commit is contained in:
Adam Ernst
2020-04-21 11:51:02 -07:00
committed by Facebook GitHub Bot
parent 756987e4bf
commit d0803ecd56
8 changed files with 274 additions and 50 deletions

View File

@@ -9,8 +9,35 @@
#import <ComponentKit/CKComponentLayout.h>
#import <ComponentKit/CKFlexboxComponent.h>
#import <ComponentKit/CKOptional.h>
#import <ComponentKit/CKVariant.h>
#import <vector>
@protocol CKInspectableView;
@class SKComponentLayoutWrapper;
@class SKComponentMountedView;
// CK::Variant does not support Objective-C types unless they are boxed:
struct SKLeafViewChild {
UIView* view;
};
struct SKMountedViewChild {
SKComponentMountedView* view;
};
/**
The children of a SKComponentLayoutWrapper may be:
- A single leaf view, which may have UIView children of its own.
- A single non-leaf view, if the component created a view; its children will be
the component's child components.
- An array of SKComponentLayoutWrappers, if the component did not create a
view.
*/
using SKComponentLayoutWrapperChildren = CK::Variant<
SKLeafViewChild,
SKMountedViewChild,
std::vector<SKComponentLayoutWrapper*>>;
@interface SKComponentLayoutWrapper : NSObject
@@ -18,11 +45,11 @@
@property(nonatomic, readonly) NSString* identifier;
@property(nonatomic, readonly) CGSize size;
@property(nonatomic, readonly) CGPoint position;
@property(nonatomic, readonly) std::vector<SKComponentLayoutWrapper*> children;
@property(nonatomic, readonly) SKComponentLayoutWrapperChildren children;
@property(nonatomic, weak, readonly) id<CKInspectableView> rootNode;
// Null for layouts which are not direct children of a CKFlexboxComponent
@property(nonatomic, readonly) BOOL isFlexboxChild;
@property(nonatomic, readonly) CKFlexboxComponentChild flexboxChild;
/** CK::none for components that are not the child of a CKFlexboxComponent. */
@property(nonatomic, readonly) CK::Optional<CKFlexboxComponentChild>
flexboxChild;
+ (instancetype)newFromRoot:(id<CKInspectableView>)root
parentKey:(NSString*)parentKey;