2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTBridge.h>
|
|
|
|
#import <React/RCTBridgeModule.h>
|
|
|
|
#import <React/RCTInvalidating.h>
|
|
|
|
#import <React/RCTRootView.h>
|
|
|
|
#import <React/RCTViewManager.h>
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-07-31 14:37:12 +00:00
|
|
|
/**
|
|
|
|
* Posted right before re-render happens. This is a chance for views to invalidate their state so
|
|
|
|
* next render cycle will pick up updated views and layout appropriately.
|
|
|
|
*/
|
2015-08-06 22:44:15 +00:00
|
|
|
RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification;
|
2015-07-31 14:37:12 +00:00
|
|
|
|
2017-07-03 23:13:34 +00:00
|
|
|
@class RCTLayoutAnimationGroup;
|
2017-05-08 19:40:07 +00:00
|
|
|
@class RCTUIManagerObserverCoordinator;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
/**
|
|
|
|
* The RCTUIManager is the module responsible for updating the view hierarchy.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
@interface RCTUIManager : NSObject <RCTBridgeModule, RCTInvalidating>
|
|
|
|
|
2017-11-08 00:10:55 +00:00
|
|
|
/**
|
|
|
|
* Register a root view tag and creates corresponding `rootView` and
|
|
|
|
* `rootShadowView`.
|
|
|
|
*/
|
|
|
|
- (void)registerRootViewTag:(NSNumber *)rootTag;
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
/**
|
2015-04-02 14:33:21 +00:00
|
|
|
* Register a root view with the RCTUIManager.
|
2015-03-25 00:37:03 +00:00
|
|
|
*/
|
2017-02-20 07:05:42 +00:00
|
|
|
- (void)registerRootView:(UIView *)rootView;
|
2015-03-25 00:37:03 +00:00
|
|
|
|
2017-01-27 02:14:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the view name associated with a reactTag.
|
|
|
|
*/
|
|
|
|
- (NSString *)viewNameForReactTag:(NSNumber *)reactTag;
|
|
|
|
|
2015-06-24 17:14:37 +00:00
|
|
|
/**
|
|
|
|
* Gets the view associated with a reactTag.
|
|
|
|
*/
|
|
|
|
- (UIView *)viewForReactTag:(NSNumber *)reactTag;
|
|
|
|
|
2017-05-16 16:39:44 +00:00
|
|
|
/**
|
|
|
|
* Gets the shadow view associated with a reactTag.
|
|
|
|
*/
|
|
|
|
- (RCTShadowView *)shadowViewForReactTag:(NSNumber *)reactTag;
|
|
|
|
|
2017-02-20 07:05:42 +00:00
|
|
|
/**
|
|
|
|
* Set the available size (`availableSize` property) for a root view.
|
|
|
|
* This might be used in response to changes in external layout constraints.
|
|
|
|
* This value will be directly trasmitted to layout engine and defines how big viewport is;
|
|
|
|
* this value does not affect root node size style properties.
|
|
|
|
* Can be considered as something similar to `setSize:forView:` but applicable only for root view.
|
|
|
|
*/
|
|
|
|
- (void)setAvailableSize:(CGSize)availableSize forRootView:(UIView *)rootView;
|
|
|
|
|
2017-09-25 05:57:28 +00:00
|
|
|
/**
|
|
|
|
* Sets local data for a shadow view corresponded with given view.
|
|
|
|
* In some cases we need a way to specify some environmental data to shadow view
|
|
|
|
* to improve layout (or do something similar), so `localData` serves these needs.
|
|
|
|
* For example, any stateful embedded native views may benefit from this.
|
|
|
|
* Have in mind that this data is not supposed to interfere with the state of
|
|
|
|
* the shadow view.
|
|
|
|
* Please respect one-directional data flow of React.
|
|
|
|
*/
|
|
|
|
- (void)setLocalData:(NSObject *)localData forView:(UIView *)view;
|
|
|
|
|
2015-03-25 00:37:03 +00:00
|
|
|
/**
|
Deprecating/removing `setFrame`, `setLeftTop`, and co.
Summary:
Motivation:
* `RCTShadowView`'s `frame` property actually represents computed layout of the view. We must not use it as a setter for yoga node styles;
* Using `frame` and `setLeftTop` in existing way actually works only for view with absolute positioning, so it is super rare and special case;
* Internally, setting `frame` only make sense to `RootView`, and in that case there we always must not change `origin` we are introducing `setSize` method.
Changes:
* `[-RCTShadowView setFrame:]` was removed, `frame` property is readonly now;
* `[-RCTShadowView setLeftTop:]` was removed; no replacement provided;
* `[-RCTShadowView size]` read-write property was added;
* `[-RCTUIManager setFrame:forView:]` was deprecated, use (just introduced) `setSize:forView:` instead;
* `[-RCTUIManager setSize:forView:]` was added.
If you are still need some of removed methods, you are probably doing something wrong. Consider using `setIntrinsicContentSize`-family methods,
`setSize`-family methods, or (in the worst case) accessing `yogaNode` directly.
Reviewed By: javache
Differential Revision: D4491384
fbshipit-source-id: 56dd84567324c5a86e4c870a41c38322dc1224d2
2017-02-01 20:59:26 +00:00
|
|
|
* Set the size of a view. This might be in response to a screen rotation
|
2015-05-26 11:14:31 +00:00
|
|
|
* or some other layout event outside of the React-managed view hierarchy.
|
2015-03-01 23:33:55 +00:00
|
|
|
*/
|
Deprecating/removing `setFrame`, `setLeftTop`, and co.
Summary:
Motivation:
* `RCTShadowView`'s `frame` property actually represents computed layout of the view. We must not use it as a setter for yoga node styles;
* Using `frame` and `setLeftTop` in existing way actually works only for view with absolute positioning, so it is super rare and special case;
* Internally, setting `frame` only make sense to `RootView`, and in that case there we always must not change `origin` we are introducing `setSize` method.
Changes:
* `[-RCTShadowView setFrame:]` was removed, `frame` property is readonly now;
* `[-RCTShadowView setLeftTop:]` was removed; no replacement provided;
* `[-RCTShadowView size]` read-write property was added;
* `[-RCTUIManager setFrame:forView:]` was deprecated, use (just introduced) `setSize:forView:` instead;
* `[-RCTUIManager setSize:forView:]` was added.
If you are still need some of removed methods, you are probably doing something wrong. Consider using `setIntrinsicContentSize`-family methods,
`setSize`-family methods, or (in the worst case) accessing `yogaNode` directly.
Reviewed By: javache
Differential Revision: D4491384
fbshipit-source-id: 56dd84567324c5a86e4c870a41c38322dc1224d2
2017-02-01 20:59:26 +00:00
|
|
|
- (void)setSize:(CGSize)size forView:(UIView *)view;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-03-01 18:13:22 +00:00
|
|
|
/**
|
|
|
|
* Set the natural size of a view, which is used when no explicit size is set.
|
2017-03-20 07:00:18 +00:00
|
|
|
* Use `UIViewNoIntrinsicMetric` to ignore a dimension.
|
|
|
|
* The `size` must NOT include padding and border.
|
2016-03-01 18:13:22 +00:00
|
|
|
*/
|
2017-11-30 06:49:57 +00:00
|
|
|
- (void)setIntrinsicContentSize:(CGSize)intrinsicContentSize forView:(UIView *)view;
|
2016-03-01 18:13:22 +00:00
|
|
|
|
2017-07-03 23:13:34 +00:00
|
|
|
/**
|
|
|
|
* Sets up layout animation which will perform on next layout pass.
|
|
|
|
* The animation will affect only one next layout pass.
|
|
|
|
* Must be called on the main queue.
|
|
|
|
*/
|
|
|
|
- (void)setNextLayoutAnimationGroup:(RCTLayoutAnimationGroup *)layoutAnimationGroup;
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
/**
|
|
|
|
* Schedule a block to be executed on the UI thread. Useful if you need to execute
|
|
|
|
* view logic after all currently queued view updates have completed.
|
|
|
|
*/
|
|
|
|
- (void)addUIBlock:(RCTViewManagerUIBlock)block;
|
|
|
|
|
2017-03-28 12:30:00 +00:00
|
|
|
/**
|
|
|
|
* Schedule a block to be executed on the UI thread. Useful if you need to execute
|
|
|
|
* view logic before all currently queued view updates have completed.
|
|
|
|
*/
|
|
|
|
- (void)prependUIBlock:(RCTViewManagerUIBlock)block;
|
|
|
|
|
2017-01-27 02:14:40 +00:00
|
|
|
/**
|
|
|
|
* Used by native animated module to bypass the process of updating the values through the shadow
|
|
|
|
* view hierarchy. This method will directly update native views, which means that updates for
|
|
|
|
* layout-related propertied won't be handled properly.
|
|
|
|
* Make sure you know what you're doing before calling this method :)
|
|
|
|
*/
|
|
|
|
- (void)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag
|
|
|
|
viewName:(NSString *)viewName
|
|
|
|
props:(NSDictionary *)props;
|
|
|
|
|
2016-08-29 05:46:42 +00:00
|
|
|
/**
|
|
|
|
* Given a reactTag from a component, find its root view, if possible.
|
|
|
|
* Otherwise, this will give back nil.
|
|
|
|
*
|
|
|
|
* @param reactTag the component tag
|
|
|
|
* @param completion the completion block that will hand over the rootView, if any.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
- (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView *view))completion;
|
|
|
|
|
2017-06-21 01:56:26 +00:00
|
|
|
/**
|
2017-06-21 22:04:28 +00:00
|
|
|
* Finds a view that is tagged with nativeID as its nativeID prop
|
|
|
|
* with the associated rootTag root tag view hierarchy. Returns the
|
2017-06-21 01:56:26 +00:00
|
|
|
* view if found, nil otherwise.
|
|
|
|
*
|
|
|
|
* @param nativeID the id reference to native component relative to root view.
|
|
|
|
* @param rootTag the react tag of root view hierarchy from which to find the view.
|
|
|
|
*/
|
|
|
|
- (UIView *)viewForNativeID:(NSString *)nativeID withRootTag:(NSNumber *)rootTag;
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
/**
|
|
|
|
* The view that is currently first responder, according to the JS context.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
+ (UIView *)JSResponder;
|
|
|
|
|
2015-12-11 14:54:56 +00:00
|
|
|
/**
|
|
|
|
* In some cases we might want to trigger layout from native side.
|
|
|
|
* React won't be aware of this, so we need to make sure it happens.
|
|
|
|
*/
|
|
|
|
- (void)setNeedsLayout;
|
|
|
|
|
2017-05-08 19:40:07 +00:00
|
|
|
/**
|
|
|
|
* Dedicated object for subscribing for UIManager events.
|
|
|
|
* See `RCTUIManagerObserver` protocol for more details.
|
|
|
|
*/
|
|
|
|
@property (atomic, retain, readonly) RCTUIManagerObserverCoordinator *observerCoordinator;
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@end
|
2015-03-01 23:33:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This category makes the current RCTUIManager instance available via the
|
|
|
|
* RCTBridge, which is useful for RCTBridgeModules or RCTViewManagers that
|
|
|
|
* need to access the RCTUIManager.
|
|
|
|
*/
|
|
|
|
@interface RCTBridge (RCTUIManager)
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) RCTUIManager *uiManager;
|
|
|
|
|
|
|
|
@end
|