123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- /*
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- #import <UIKit/UIKit.h>
- #import <React/RCTPrimitives.h>
- #import <react/core/EventEmitter.h>
- #import <react/core/LayoutMetrics.h>
- #import <react/core/Props.h>
- #import <react/core/State.h>
- #import <react/uimanager/ComponentDescriptorProvider.h>
- NS_ASSUME_NONNULL_BEGIN
- /*
- * Bitmask for all types of possible updates performing during mounting.
- */
- typedef NS_OPTIONS(NSInteger, RNComponentViewUpdateMask) {
- RNComponentViewUpdateMaskNone = 0,
- RNComponentViewUpdateMaskProps = 1 << 0,
- RNComponentViewUpdateMaskEventEmitter = 1 << 1,
- RNComponentViewUpdateMaskState = 1 << 3,
- RNComponentViewUpdateMaskLayoutMetrics = 1 << 4,
- RNComponentViewUpdateMaskAll = RNComponentViewUpdateMaskProps | RNComponentViewUpdateMaskEventEmitter |
- RNComponentViewUpdateMaskState | RNComponentViewUpdateMaskLayoutMetrics
- };
- /*
- * Represents a `UIView` instance managed by React.
- * All methods are non-@optional.
- * `UIView+ComponentViewProtocol` category provides default implementation
- * for all of them.
- */
- @protocol RCTComponentViewProtocol <NSObject>
- /*
- * Returns a `ComponentDescriptorProvider` of a particular `ComponentDescriptor` which this component view
- * represents.
- */
- + (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider;
- /*
- * Returns a list of supplemental `ComponentDescriptorProvider`s (with do not have `ComponentView` counterparts) that
- * require for this component view.
- */
- + (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders;
- /*
- * Called for mounting (attaching) a child component view inside `self`
- * component view.
- * Receiver must add `childComponentView` as a subview.
- */
- - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)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<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- /*
- * Called for updating component's props.
- * Receiver must update native view props accordingly changed props.
- */
- - (void)updateProps:(facebook::react::Props::Shared const &)props
- oldProps:(facebook::react::Props::Shared const &)oldProps;
- /*
- * Called for updating component's state.
- * Receiver must update native view according to changed state.
- */
- - (void)updateState:(facebook::react::State::Shared const &)state
- oldState:(facebook::react::State::Shared const &)oldState;
- /*
- * Called for updating component's event handlers set.
- * Receiver must cache `eventEmitter` object inside and use it for emitting
- * events when needed.
- */
- - (void)updateEventEmitter:(facebook::react::EventEmitter::Shared const &)eventEmitter;
- /*
- * 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 const &)layoutMetrics
- oldLayoutMetrics:(facebook::react::LayoutMetrics const &)oldLayoutMetrics;
- /*
- * Called when receiving a command
- */
- - (void)handleCommand:(NSString const *)commandName args:(NSArray const *)args;
- /*
- * Called right after all update methods were called for a particular component view.
- * Useful for performing updates that require knowledge of several independent aspects of the compound mounting change
- * (e.g. props *and* layout constraints).
- */
- - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask;
- /*
- * 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;
- /**
- * Read the last props used to update the view.
- */
- - (facebook::react::SharedProps)props;
- @end
- NS_ASSUME_NONNULL_END
|