1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8 #import <UIKit/UIKit.h> 9 10 #import <ABI48_0_0React/ABI48_0_0renderer/componentregistry/ComponentDescriptorProvider.h> 11 #import <ABI48_0_0React/ABI48_0_0renderer/core/EventEmitter.h> 12 #import <ABI48_0_0React/ABI48_0_0renderer/core/LayoutMetrics.h> 13 #import <ABI48_0_0React/ABI48_0_0renderer/core/Props.h> 14 #import <ABI48_0_0React/ABI48_0_0renderer/core/State.h> 15 16 NS_ASSUME_NONNULL_BEGIN 17 18 /* 19 * Bitmask for all types of possible updates performing during mounting. 20 */ 21 typedef NS_OPTIONS(NSInteger, ABI48_0_0RNComponentViewUpdateMask) { 22 ABI48_0_0RNComponentViewUpdateMaskNone = 0, 23 ABI48_0_0RNComponentViewUpdateMaskProps = 1 << 0, 24 ABI48_0_0RNComponentViewUpdateMaskEventEmitter = 1 << 1, 25 ABI48_0_0RNComponentViewUpdateMaskState = 1 << 3, 26 ABI48_0_0RNComponentViewUpdateMaskLayoutMetrics = 1 << 4, 27 28 ABI48_0_0RNComponentViewUpdateMaskAll = ABI48_0_0RNComponentViewUpdateMaskProps | ABI48_0_0RNComponentViewUpdateMaskEventEmitter | 29 ABI48_0_0RNComponentViewUpdateMaskState | ABI48_0_0RNComponentViewUpdateMaskLayoutMetrics 30 }; 31 32 /* 33 * Represents a `UIView` instance managed by ABI48_0_0React. 34 * All methods are non-@optional. 35 * `UIView+ComponentViewProtocol` category provides default implementation 36 * for all of them. 37 */ 38 @protocol ABI48_0_0RCTComponentViewProtocol <NSObject> 39 40 /* 41 * Returns a `ComponentDescriptorProvider` of a particular `ComponentDescriptor` which this component view 42 * represents. 43 */ 44 + (ABI48_0_0facebook::ABI48_0_0React::ComponentDescriptorProvider)componentDescriptorProvider; 45 46 /* 47 * Returns a list of supplemental `ComponentDescriptorProvider`s (with do not have `ComponentView` counterparts) that 48 * require for this component view. 49 */ 50 + (std::vector<ABI48_0_0facebook::ABI48_0_0React::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders; 51 52 /* 53 * Called for mounting (attaching) a child component view inside `self` 54 * component view. 55 * Receiver must add `childComponentView` as a subview. 56 */ 57 - (void)mountChildComponentView:(UIView<ABI48_0_0RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index; 58 59 /* 60 * Called for unmounting (detaching) a child component view from `self` 61 * component view. 62 * Receiver must remove `childComponentView` as a subview. 63 */ 64 - (void)unmountChildComponentView:(UIView<ABI48_0_0RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index; 65 66 /* 67 * Called for updating component's props. 68 * Receiver must update native view props accordingly changed props. 69 */ 70 - (void)updateProps:(ABI48_0_0facebook::ABI48_0_0React::Props::Shared const &)props 71 oldProps:(ABI48_0_0facebook::ABI48_0_0React::Props::Shared const &)oldProps; 72 73 /* 74 * Called for updating component's state. 75 * Receiver must update native view according to changed state. 76 */ 77 - (void)updateState:(ABI48_0_0facebook::ABI48_0_0React::State::Shared const &)state 78 oldState:(ABI48_0_0facebook::ABI48_0_0React::State::Shared const &)oldState; 79 80 /* 81 * Called for updating component's event handlers set. 82 * Receiver must cache `eventEmitter` object inside and use it for emitting 83 * events when needed. 84 */ 85 - (void)updateEventEmitter:(ABI48_0_0facebook::ABI48_0_0React::EventEmitter::Shared const &)eventEmitter; 86 87 /* 88 * Called for updating component's layout metrics. 89 * Receiver must update `UIView` layout-related fields (such as `frame`, 90 * `bounds`, `layer.zPosition`, and so on) accordingly. 91 */ 92 - (void)updateLayoutMetrics:(ABI48_0_0facebook::ABI48_0_0React::LayoutMetrics const &)layoutMetrics 93 oldLayoutMetrics:(ABI48_0_0facebook::ABI48_0_0React::LayoutMetrics const &)oldLayoutMetrics; 94 95 /* 96 * Called when receiving a command 97 */ 98 - (void)handleCommand:(NSString const *)commandName args:(NSArray const *)args; 99 100 /* 101 * Called right after all update methods were called for a particular component view. 102 * Useful for performing updates that require knowledge of several independent aspects of the compound mounting change 103 * (e.g. props *and* layout constraints). 104 */ 105 - (void)finalizeUpdates:(ABI48_0_0RNComponentViewUpdateMask)updateMask; 106 107 /* 108 * Called right after the component view is moved to a recycle pool. 109 * Receiver must reset any local state and release associated 110 * non-reusable resources. 111 */ 112 - (void)prepareForRecycle; 113 114 /* 115 * Read the last props used to update the view. 116 */ 117 - (ABI48_0_0facebook::ABI48_0_0React::Props::Shared)props; 118 119 - (BOOL)isJSResponder; 120 - (void)setIsJSResponder:(BOOL)isJSResponder; 121 122 /* 123 * This is broken. Do not use. 124 */ 125 - (void)setPropKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN:(nullable NSSet<NSString *> *)props; 126 - (nullable NSSet<NSString *> *)propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN; 127 128 @end 129 130 NS_ASSUME_NONNULL_END 131