mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 06:38:13 +00:00
Summary: `RCTSurfaceHostingProxyRootView` surfaces are still automatically started right after the initialization to match `RCTRootView` interface, but `RCTSurfaceHostingView` must be started explicitly now. Also fixed some internal stuff so start and register are clear and distinct. Background / initial motivation: One tricky bit - we render the template as part of init`ing the rootView, so we don't know what the surfaceId will be before hand to register the UITemplate. Two possible solutions: 1) Require start be called explicitly after initializing the rootView, and setup the context in between. 2) Do something like "setUITemplateConfigForNextSurface" before creating the rootView, and have some hook when the surfaceId is assigned that associates the surfaceId with that "next" UITemplate stuff before. (1) seems a lot cleaner, but it requires ever user of rootView to explicitly call start on it - how do you feel about that? Seems like we could also use that start call to decide if the initial render should be synchronous or not? start vs. startSync? Reviewed By: mdvacca Differential Revision: D13372914 fbshipit-source-id: 6db297870610e6c231f8a78c0dd74d584cb64910
87 lines
2.3 KiB
Objective-C
87 lines
2.3 KiB
Objective-C
/**
|
|
* 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 <memory>
|
|
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTComponentViewFactory.h>
|
|
#import <react/uimanager/ContextContainer.h>
|
|
#import <React/RCTPrimitives.h>
|
|
#import <react/config/ReactNativeConfig.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@class RCTFabricSurface;
|
|
@class RCTMountingManager;
|
|
|
|
/**
|
|
* Coordinates presenting of React Native Surfaces and represents application
|
|
* facing interface of running React Native core.
|
|
* SurfacePresenter incapsulates a bridge object inside and discourage direct
|
|
* access to it.
|
|
*/
|
|
@interface RCTSurfacePresenter : NSObject
|
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
config:(std::shared_ptr<const facebook::react::ReactNativeConfig>)config;
|
|
|
|
@property (nonatomic, readonly) RCTComponentViewFactory *componentViewFactory;
|
|
@property (nonatomic, readonly) facebook::react::SharedContextContainer contextContainer;
|
|
|
|
@end
|
|
|
|
@interface RCTSurfacePresenter (Surface)
|
|
|
|
/**
|
|
* Surface uses these methods to register itself in the Presenter.
|
|
*/
|
|
- (void)registerSurface:(RCTFabricSurface *)surface;
|
|
/**
|
|
* Starting initiates running, rendering and mounting processes.
|
|
* Should be called after registerSurface and any other surface-specific setup is done
|
|
*/
|
|
- (void)startSurface:(RCTFabricSurface *)surface;
|
|
- (void)unregisterSurface:(RCTFabricSurface *)surface;
|
|
- (void)setProps:(NSDictionary *)props
|
|
surface:(RCTFabricSurface *)surface;
|
|
|
|
- (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
|
|
|
|
/**
|
|
* Measures the Surface with given constraints.
|
|
*/
|
|
- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize
|
|
maximumSize:(CGSize)maximumSize
|
|
surface:(RCTFabricSurface *)surface;
|
|
|
|
/**
|
|
* Sets `minimumSize` and `maximumSize` layout constraints for the Surface.
|
|
*/
|
|
- (void)setMinimumSize:(CGSize)minimumSize
|
|
maximumSize:(CGSize)maximumSize
|
|
surface:(RCTFabricSurface *)surface;
|
|
|
|
@end
|
|
|
|
@interface RCTSurfacePresenter (Deprecated)
|
|
|
|
/**
|
|
* Returns a underlying bridge.
|
|
*/
|
|
- (RCTBridge *)bridge_DO_NOT_USE;
|
|
|
|
@end
|
|
|
|
@interface RCTBridge (Deprecated)
|
|
|
|
@property (nonatomic) RCTSurfacePresenter *surfacePresenter;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|