Removed exported constants for fixed-size views

Summary: Creating a view instance just to get the default view size is quite expensive, and affects startup time for the bridge as it must be done on the main thread. I've removed these cases and simply hard-coded the sizes in the JS file. This will need to be updated if the view sizes ever change, but in practice that's very unlikely.

Reviewed By: javache

Differential Revision: D3218917

fb-gh-sync-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
fbshipit-source-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
This commit is contained in:
Nick Lockwood 2016-04-26 04:20:56 -07:00 committed by Facebook Github Bot 9
parent 036199d3f7
commit c1aff6b116
9 changed files with 5 additions and 43 deletions

View File

@ -16,7 +16,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var RCTDatePickerIOSConsts = require('UIManager').RCTDatePicker.Constants;
var StyleSheet = require('StyleSheet');
var View = require('View');
@ -142,8 +141,8 @@ var DatePickerIOS = React.createClass({
var styles = StyleSheet.create({
datePickerIOS: {
height: RCTDatePickerIOSConsts.ComponentHeight,
width: RCTDatePickerIOSConsts.ComponentWidth,
height: 216,
width: 320,
},
});

View File

@ -15,7 +15,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ReactChildren = require('ReactChildren');
var RCTPickerIOSConsts = require('NativeModules').UIManager.RCTPicker.Constants;
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var TextStylePropTypes = require('TextStylePropTypes');
@ -108,7 +107,7 @@ var styles = StyleSheet.create({
// The picker will conform to whatever width is given, but we do
// have to set the component's height explicitly on the
// surrounding view to ensure it gets rendered.
height: RCTPickerIOSConsts.ComponentHeight,
height: 216,
},
});

View File

@ -13,7 +13,6 @@
var Image = require('Image');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
@ -72,7 +71,7 @@ var ProgressViewIOS = React.createClass({
var styles = StyleSheet.create({
progressView: {
height: NativeModules.ProgressViewManager.ComponentHeight
height: 2,
},
});

View File

@ -12,7 +12,6 @@
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
@ -120,7 +119,7 @@ var SegmentedControlIOS = React.createClass({
var styles = StyleSheet.create({
segmentedControl: {
height: NativeModules.SegmentedControlManager.ComponentHeight
height: 28,
},
});

View File

@ -42,13 +42,4 @@ RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)
- (NSDictionary<NSString *, id> *)constantsToExport
{
UIDatePicker *view = [UIDatePicker new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
@"ComponentWidth": @(view.intrinsicContentSize.width),
};
}
@end

View File

@ -43,13 +43,4 @@ RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, RCTPicker)
view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName];
}
- (NSDictionary<NSString *, id> *)constantsToExport
{
UIPickerView *view = [UIPickerView new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
@"ComponentWidth": @(view.intrinsicContentSize.width)
};
}
@end

View File

@ -36,12 +36,4 @@ RCT_EXPORT_VIEW_PROPERTY(trackTintColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(progressImage, UIImage)
RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage)
- (NSDictionary<NSString *, id> *)constantsToExport
{
UIProgressView *view = [UIProgressView new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
};
}
@end

View File

@ -29,12 +29,4 @@ RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL)
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
- (NSDictionary<NSString *, id> *)constantsToExport
{
RCTSegmentedControl *view = [RCTSegmentedControl new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
};
}
@end