Provide initial size to Modal

Reviewed By: majak

Differential Revision: D3202211

fb-gh-sync-id: 83a1d3d52df0dc68483639393ab64fd6f1281cb3
fbshipit-source-id: 83a1d3d52df0dc68483639393ab64fd6f1281cb3
This commit is contained in:
Pieter De Baets 2016-04-21 08:56:46 -07:00 committed by Facebook Github Bot 1
parent 0de8962e16
commit 2b69ec2589
2 changed files with 35 additions and 11 deletions

View File

@ -11,14 +11,14 @@
*/
'use strict';
var Platform = require('Platform');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
const Platform = require('Platform');
const PropTypes = require('ReactPropTypes');
const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');
var requireNativeComponent = require('requireNativeComponent');
var RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
/**
* A Modal component covers the native view (e.g. UIViewController, Activity)
@ -39,9 +39,9 @@ class Modal extends React.Component {
return null;
}
if (this.props.transparent) {
var containerBackgroundColor = {backgroundColor: 'transparent'};
}
const containerBackgroundColor = {
backgroundColor: this.props.transparent ? 'transparent' : 'white',
};
return (
<RCTModalHostView
@ -77,7 +77,7 @@ Modal.defaultProps = {
visible: true,
};
var styles = StyleSheet.create({
const styles = StyleSheet.create({
modal: {
position: 'absolute',
},

View File

@ -12,6 +12,25 @@
#import "RCTBridge.h"
#import "RCTModalHostView.h"
#import "RCTTouchHandler.h"
#import "RCTShadowView.h"
#import "RCTUtils.h"
@interface RCTModalHostShadowView : RCTShadowView
@end
@implementation RCTModalHostShadowView
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex
{
[super insertReactSubview:subview atIndex:atIndex];
if ([subview isKindOfClass:[RCTShadowView class]]) {
CGRect frame = {.origin = CGPointZero, .size = RCTScreenSize()};
[(RCTShadowView *)subview setFrame:frame];
}
}
@end
@implementation RCTModalHostViewManager
{
@ -30,6 +49,11 @@ RCT_EXPORT_MODULE()
return view;
}
- (RCTShadowView *)shadowView
{
return [RCTModalHostShadowView new];
}
- (void)invalidate
{
for (RCTModalHostView *hostView in _hostViews) {