From 87539c34dbe1ba359d4f42caf612380a930498ff Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 10 Apr 2018 16:36:43 -0700 Subject: [PATCH] Fabric: RCTComponentViewProtocol Summary: RCTComponentViewProtocol is a protocol for all UIView instances which are managed by React/MountingManager. Reviewed By: mdvacca Differential Revision: D7507520 fbshipit-source-id: dcbed8c5d0cc97f72942508aeccb445833ade271 --- .../Mounting/RCTComponentViewProtocol.h | 64 +++++++++++++++++++ React/Fabric/RCTPrimitives.h | 10 +++ 2 files changed, 74 insertions(+) create mode 100644 React/Fabric/Mounting/RCTComponentViewProtocol.h create mode 100644 React/Fabric/RCTPrimitives.h diff --git a/React/Fabric/Mounting/RCTComponentViewProtocol.h b/React/Fabric/Mounting/RCTComponentViewProtocol.h new file mode 100644 index 00000000000..d23ac72adfe --- /dev/null +++ b/React/Fabric/Mounting/RCTComponentViewProtocol.h @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Represents a `UIView` instance managed by React. + * All methods are non-@optional. + * `UIView+ComponentViewProtocol` category provides default implementation + * for all of them. + */ +@protocol RCTComponentViewProtocol + +/* + * Called for mounting (attaching) a child component view inside `self` + * component view. + * Receiver must add `childComponentView` as a subview. + */ +- (void)mountChildComponentView:(UIView *)childComponentView + index:(NSInteger)index; + +/* + * Called for unmounting (detaching) a child component view from `self` + * component view. + * Receiver must remove `childComponentView` as a subview. + */ +- (void)unmountChildComponentView:(UIView *)childComponentView + index:(NSInteger)index; + +/* + * Called for updating component's props. + * Receiver must update native view props accordingly changed props. + */ +- (void)updateProps:(facebook::react::SharedProps)props + oldProps:(facebook::react::SharedProps)oldProps; + +/* + * Called for updating component's layout metrics. + * Receiver must update `UIView` layout-related fields (such as `frame`, + * `bounds`, `layer.zPosition`, and so on) accordingly. + */ +- (void)updateLayoutMetrics:(facebook::react::LayoutMetrics)layoutMetrics + oldLayoutMetrics:(facebook::react::LayoutMetrics)oldLayoutMetrics; + +/* + * Called right after the component view is moved to a recycle pool. + * Receiver must reset any local state and release associated + * non-reusable resources. + */ +- (void)prepareForRecycle; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/RCTPrimitives.h b/React/Fabric/RCTPrimitives.h new file mode 100644 index 00000000000..7712dabc9f1 --- /dev/null +++ b/React/Fabric/RCTPrimitives.h @@ -0,0 +1,10 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import + +typedef NSInteger ReactTag;