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
|
|
|
|
2016-05-16 15:01:35 +00:00
|
|
|
/**
|
|
|
|
* UIManager queue
|
|
|
|
*/
|
|
|
|
RCT_EXTERN dispatch_queue_t RCTGetUIManagerQueue(void);
|
|
|
|
|
2016-05-04 13:54:12 +00:00
|
|
|
/**
|
|
|
|
* Default name for the UIManager queue
|
|
|
|
*/
|
|
|
|
RCT_EXTERN char *const RCTUIManagerQueueName;
|
|
|
|
|
2017-05-08 19:40:06 +00:00
|
|
|
/**
|
|
|
|
* Check if we are currently on UIManager queue.
|
|
|
|
*/
|
|
|
|
RCT_EXTERN BOOL RCTIsUIManagerQueue(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience macro for asserting that we're running on UIManager queue.
|
|
|
|
*/
|
|
|
|
#define RCTAssertUIManagerQueue() RCTAssert(RCTIsUIManagerQueue(), \
|
|
|
|
@"This function must be called on the UIManager queue")
|
|
|
|
|
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
|
|
|
|
2015-08-17 13:11:29 +00:00
|
|
|
/**
|
|
|
|
* Posted whenever a new root view is registered with RCTUIManager. The userInfo property
|
|
|
|
* will contain a RCTUIManagerRootViewKey with the registered root view.
|
|
|
|
*/
|
|
|
|
RCT_EXTERN NSString *const RCTUIManagerDidRegisterRootViewNotification;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Posted whenever a root view is removed from the RCTUIManager. The userInfo property
|
|
|
|
* will contain a RCTUIManagerRootViewKey with the removed root view.
|
|
|
|
*/
|
|
|
|
RCT_EXTERN NSString *const RCTUIManagerDidRemoveRootViewNotification;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Key for the root view property in the above notifications
|
|
|
|
*/
|
|
|
|
RCT_EXTERN NSString *const RCTUIManagerRootViewKey;
|
|
|
|
|
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>
|
|
|
|
|
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-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;
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
- (void)setIntrinsicContentSize:(CGSize)size forView:(UIView *)view;
|
|
|
|
|
2015-05-26 11:14:31 +00:00
|
|
|
/**
|
2016-03-21 10:20:49 +00:00
|
|
|
* Update the background color of a view. The source of truth for
|
|
|
|
* backgroundColor is the shadow view, so if to update backgroundColor from
|
|
|
|
* native code you will need to call this method.
|
2015-05-26 11:14:31 +00:00
|
|
|
*/
|
2016-03-21 10:20:49 +00:00
|
|
|
- (void)setBackgroundColor:(UIColor *)color forView:(UIView *)view;
|
2015-05-26 11:14:31 +00:00
|
|
|
|
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;
|
|
|
|
|
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-02 13:12:17 +00:00
|
|
|
/**
|
|
|
|
* Normally, UI changes are not applied until the complete batch of method
|
|
|
|
* invocations from JavaScript to native has completed.
|
|
|
|
*
|
|
|
|
* Setting this to YES will flush UI changes sooner, which could potentially
|
|
|
|
* result in inconsistent UI updates.
|
|
|
|
*
|
|
|
|
* The default is NO (recommended).
|
|
|
|
*/
|
|
|
|
@property (atomic, assign) BOOL unsafeFlushUIChangesBeforeBatchEnds;
|
|
|
|
|
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
|
|
|
|
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
|
|
|
@interface RCTUIManager (Deprecated)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is deprecated and will be removed in next releases.
|
|
|
|
* Use `setSize:forView:` or `setIntrinsicContentSize:forView:` instead.
|
|
|
|
* Only frames with `origin` equals {0, 0} are supported.
|
|
|
|
*/
|
|
|
|
- (void)setFrame:(CGRect)frame forView:(UIView *)view
|
|
|
|
__deprecated_msg("Use `setSize:forView:` or `setIntrinsicContentSize:forView:` instead.");
|
|
|
|
|
2017-02-20 07:05:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is deprecated and will be removed in next releases.
|
|
|
|
* Use `registerRootView:` instead. There is no need to specify `sizeFlexibility` anymore.
|
|
|
|
*/
|
|
|
|
- (void)registerRootView:(UIView *)rootView withSizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility
|
|
|
|
__deprecated_msg("Use `registerRootView:` instead.");
|
|
|
|
|
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
|
|
|
@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
|