diff --git a/React/Fabric/Mounting/MountItems/RCTCreateMountItem.h b/React/Fabric/Mounting/MountItems/RCTCreateMountItem.h new file mode 100644 index 00000000000..6376094894d --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTCreateMountItem.h @@ -0,0 +1,27 @@ +/** + * 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 + +NS_ASSUME_NONNULL_BEGIN + +@class RCTComponentViewRegistry; + +/** + * Creates a ready-to-mount component view. + */ +@interface RCTCreateMountItem : NSObject + +- (instancetype)initWithComponentName:(NSString *)componentName + tag:(ReactTag)tag; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTCreateMountItem.mm b/React/Fabric/Mounting/MountItems/RCTCreateMountItem.mm new file mode 100644 index 00000000000..df04396b476 --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTCreateMountItem.mm @@ -0,0 +1,33 @@ +/** + * 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 "RCTCreateMountItem.h" + +#import "RCTComponentViewRegistry.h" + +@implementation RCTCreateMountItem { + NSString *_componentName; + ReactTag _tag; +} + +- (instancetype)initWithComponentName:(NSString *)componentName + tag:(ReactTag)tag +{ + if (self = [super init]) { + _componentName = componentName; + _tag = tag; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + [registry dequeueComponentViewWithName:_componentName tag:_tag]; +} + +@end diff --git a/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.h b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.h new file mode 100644 index 00000000000..a4c6077b56f --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.h @@ -0,0 +1,25 @@ +/** + * 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 + +NS_ASSUME_NONNULL_BEGIN + +/** + * Deletes (returns to recycle pool) a component view. + */ +@interface RCTDeleteMountItem : NSObject + +- (instancetype)initWithComponentName:(NSString *)componentName + tag:(ReactTag)tag; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm new file mode 100644 index 00000000000..99909f450cc --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm @@ -0,0 +1,34 @@ +/** + * 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 "RCTDeleteMountItem.h" + +#import "RCTComponentViewRegistry.h" + +@implementation RCTDeleteMountItem { + NSString *_componentName; + ReactTag _tag; +} + +- (instancetype)initWithComponentName:(NSString *)componentName + tag:(ReactTag)tag +{ + if (self = [super init]) { + _componentName = componentName; + _tag = tag; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + UIView *componentView = [registry componentViewByTag:_tag]; + [registry enqueueComponentViewWithName:_componentName tag:_tag componentView:componentView]; +} + +@end diff --git a/React/Fabric/Mounting/MountItems/RCTInsertMountItem.h b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.h new file mode 100644 index 00000000000..e3d4ac29d7a --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.h @@ -0,0 +1,28 @@ +/** + * 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 + +NS_ASSUME_NONNULL_BEGIN + +@class RCTComponentViewRegistry; + +/** + * Inserts a component view into another component view. + */ +@interface RCTInsertMountItem : NSObject + +- (instancetype)initWithChildTag:(ReactTag)childTag + parentTag:(ReactTag)parentTag + index:(NSInteger)index; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm new file mode 100644 index 00000000000..f714cb0a70d --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm @@ -0,0 +1,40 @@ +/** + * 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 "RCTInsertMountItem.h" + +#import "RCTComponentViewRegistry.h" + +@implementation RCTInsertMountItem { + ReactTag _childTag; + ReactTag _parentTag; + NSInteger _index; +} + +- (instancetype)initWithChildTag:(ReactTag)childTag + parentTag:(ReactTag)parentTag + index:(NSInteger)index +{ + if (self = [super init]) { + _childTag = childTag; + _parentTag = parentTag; + _index = index; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + UIView *childComponentView = [registry componentViewByTag:_childTag]; + UIView *parentComponentView = [registry componentViewByTag:_parentTag]; + + [parentComponentView mountChildComponentView:childComponentView + index:_index]; +} + +@end diff --git a/React/Fabric/Mounting/MountItems/RCTMountItemProtocol.h b/React/Fabric/Mounting/MountItems/RCTMountItemProtocol.h new file mode 100644 index 00000000000..f46c397498b --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTMountItemProtocol.h @@ -0,0 +1,23 @@ +/** + * 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 + +NS_ASSUME_NONNULL_BEGIN + +@class RCTComponentViewRegistry; + +/** + * Granular representation of any change in a user interface. + */ +@protocol RCTMountItemProtocol + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.h b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.h new file mode 100644 index 00000000000..0fe9555a613 --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.h @@ -0,0 +1,26 @@ +/** + * 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 + +NS_ASSUME_NONNULL_BEGIN + +/** + * Removes a component view from another component view. + */ +@interface RCTRemoveMountItem : NSObject + +- (instancetype)initWithChildTag:(ReactTag)childTag + parentTag:(ReactTag)parentTag + index:(NSInteger)index; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm new file mode 100644 index 00000000000..d46b936dd04 --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm @@ -0,0 +1,40 @@ +/** + * 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 "RCTRemoveMountItem.h" + +#import "RCTComponentViewRegistry.h" + +@implementation RCTRemoveMountItem { + ReactTag _childTag; + ReactTag _parentTag; + NSInteger _index; +} + +- (instancetype)initWithChildTag:(ReactTag)childTag + parentTag:(ReactTag)parentTag + index:(NSInteger)index +{ + if (self = [super init]) { + _childTag = childTag; + _parentTag = parentTag; + _index = index; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + UIView *childComponentView = [registry componentViewByTag:_childTag]; + UIView *parentComponentView = [registry componentViewByTag:_parentTag]; + + [parentComponentView unmountChildComponentView:childComponentView + index:_index]; +} + +@end diff --git a/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.h b/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.h new file mode 100644 index 00000000000..378c179d3c4 --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.h @@ -0,0 +1,27 @@ +/** + * 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 + +/** + * Updates layout metrics of a component view. + */ +@interface RCTUpdateLayoutMetricsMountItem : NSObject + +- (instancetype)initWithTag:(ReactTag)tag + oldLayoutMetrics:(facebook::react::LayoutMetrics)oldLayoutMetrics + newLayoutMetrics:(facebook::react::LayoutMetrics)newLayoutMetrics; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.mm b/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.mm new file mode 100644 index 00000000000..c61a043626a --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTUpdateLayoutMetricsMountItem.mm @@ -0,0 +1,41 @@ +/** + * 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 "RCTUpdateLayoutMetricsMountItem.h" + +#import "RCTComponentViewRegistry.h" + +using namespace facebook::react; + +@implementation RCTUpdateLayoutMetricsMountItem { + ReactTag _tag; + LayoutMetrics _oldLayoutMetrics; + LayoutMetrics _newLayoutMetrics; +} + +- (instancetype)initWithTag:(ReactTag)tag + oldLayoutMetrics:(facebook::react::LayoutMetrics)oldLayoutMetrics + newLayoutMetrics:(facebook::react::LayoutMetrics)newLayoutMetrics +{ + if (self = [super init]) { + _tag = tag; + _oldLayoutMetrics = oldLayoutMetrics; + _newLayoutMetrics = newLayoutMetrics; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + UIView *componentView = [registry componentViewByTag:_tag]; + + [componentView updateLayoutMetrics:_newLayoutMetrics + oldLayoutMetrics:_oldLayoutMetrics]; +} + +@end diff --git a/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.h b/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.h new file mode 100644 index 00000000000..efdfed64ddb --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.h @@ -0,0 +1,27 @@ +/** + * 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 + +/** + * Updates props of a component view. + */ +@interface RCTUpdatePropsMountItem : NSObject + +- (instancetype)initWithTag:(ReactTag)tag + oldProps:(facebook::react::SharedProps)oldProps + newProps:(facebook::react::SharedProps)newProps; + +@end + +NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.mm b/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.mm new file mode 100644 index 00000000000..694b72e4046 --- /dev/null +++ b/React/Fabric/Mounting/MountItems/RCTUpdatePropsMountItem.mm @@ -0,0 +1,39 @@ +/** + * 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 "RCTUpdatePropsMountItem.h" + +#import "RCTComponentViewRegistry.h" + +using namespace facebook::react; + +@implementation RCTUpdatePropsMountItem { + ReactTag _tag; + SharedProps _oldProps; + SharedProps _newProps; +} + +- (instancetype)initWithTag:(ReactTag)tag + oldProps:(SharedProps)oldProps + newProps:(SharedProps)newProps +{ + if (self = [super init]) { + _tag = tag; + _oldProps = oldProps; + _newProps = newProps; + } + + return self; +} + +- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry +{ + UIView *componentView = [registry componentViewByTag:_tag]; + [componentView updateProps:_newProps oldProps:_oldProps]; +} + +@end