iOS: set the default measure size correctly for RCTSurfaceHostingView

Summary: The RCTRootView default needs to be translated during init of RCTSurfaceHostingView correctly.

Reviewed By: shergin

Differential Revision: D7327918

fbshipit-source-id: 67a2a42b554782b37a032cc0470d794554cc1e5a
This commit is contained in:
Kevin Gozali 2018-03-19 17:33:04 -07:00 committed by Facebook Github Bot
parent b808bfdce2
commit e2462e9016
4 changed files with 14 additions and 11 deletions

View File

@ -61,7 +61,10 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz
[bridge.performanceLogger markStartForTag:RCTPLTTI];
}
if (self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]) {
// `RCTRootViewSizeFlexibilityNone` is the RCTRootView's default.
RCTSurfaceSizeMeasureMode sizeMeasureMode = convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityNone);
if (self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties sizeMeasureMode:sizeMeasureMode]) {
self.backgroundColor = [UIColor whiteColor];
}

View File

@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
* Instanciates a view with given Surface object.
* Note: The view retains the surface object.
*/
- (instancetype)initWithSurface:(RCTSurface *)surface NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithSurface:(RCTSurface *)surface
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_DESIGNATED_INITIALIZER;
/**
* Convenience initializer.
@ -40,7 +41,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (instancetype)initWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties;
initialProperties:(NSDictionary *)initialProperties
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode;
/**
* Create an instance of RCTSurface to be hosted.

View File

@ -33,20 +33,17 @@ RCT_NOT_IMPLEMENTED(- (nullable instancetype)initWithCoder:(NSCoder *)coder)
- (instancetype)initWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
{
RCTSurface *surface = [self createSurfaceWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
return [self initWithSurface:surface];
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
}
- (instancetype)initWithSurface:(RCTSurface *)surface
- (instancetype)initWithSurface:(RCTSurface *)surface sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
{
if (self = [super initWithFrame:CGRectZero]) {
_surface = surface;
_sizeMeasureMode =
RCTSurfaceSizeMeasureModeWidthAtMost |
RCTSurfaceSizeMeasureModeHeightAtMost;
_sizeMeasureMode = sizeMeasureMode;
_surface.delegate = self;
_stage = surface.stage;

View File

@ -14,11 +14,12 @@
- (instancetype)initWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
{
RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
return [self initWithSurface:surface];
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
}
@end