Removed hard-coded DatePicker width
Summary: The DatePicker had a hard-coded width of 320 for no reason I can think of. Removing it allows the DatePicker to naturally scale to fit the width of the container, which is how the regular Picker works already. Reviewed By: lexs Differential Revision: D3371355 fbshipit-source-id: e06d31f7275de41bb00226232cf47ad022d25b4d
This commit is contained in:
parent
bdcdfb03d4
commit
002024cc45
|
@ -13,13 +13,13 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||||
var PropTypes = require('ReactPropTypes');
|
const PropTypes = require('ReactPropTypes');
|
||||||
var React = require('React');
|
const React = require('React');
|
||||||
var StyleSheet = require('StyleSheet');
|
const StyleSheet = require('StyleSheet');
|
||||||
var View = require('View');
|
const View = require('View');
|
||||||
|
|
||||||
var requireNativeComponent = require('requireNativeComponent');
|
const requireNativeComponent = require('requireNativeComponent');
|
||||||
|
|
||||||
type DefaultProps = {
|
type DefaultProps = {
|
||||||
mode: 'date' | 'time' | 'datetime';
|
mode: 'date' | 'time' | 'datetime';
|
||||||
|
@ -34,7 +34,7 @@ type Event = Object;
|
||||||
* the user's change will be reverted immediately to reflect `props.date` as the
|
* the user's change will be reverted immediately to reflect `props.date` as the
|
||||||
* source of truth.
|
* source of truth.
|
||||||
*/
|
*/
|
||||||
var DatePickerIOS = React.createClass({
|
const DatePickerIOS = React.createClass({
|
||||||
// TOOD: Put a better type for _picker
|
// TOOD: Put a better type for _picker
|
||||||
_picker: (undefined: ?$FlowFixMe),
|
_picker: (undefined: ?$FlowFixMe),
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ var DatePickerIOS = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onChange: function(event: Event) {
|
_onChange: function(event: Event) {
|
||||||
var nativeTimeStamp = event.nativeEvent.timestamp;
|
const nativeTimeStamp = event.nativeEvent.timestamp;
|
||||||
this.props.onDateChange && this.props.onDateChange(
|
this.props.onDateChange && this.props.onDateChange(
|
||||||
new Date(nativeTimeStamp)
|
new Date(nativeTimeStamp)
|
||||||
);
|
);
|
||||||
|
@ -107,7 +107,7 @@ var DatePickerIOS = React.createClass({
|
||||||
// prop. That way they can also disallow/undo/mutate the selection of
|
// prop. That way they can also disallow/undo/mutate the selection of
|
||||||
// certain values. In other words, the embedder of this component should
|
// certain values. In other words, the embedder of this component should
|
||||||
// be the source of truth, not the native component.
|
// be the source of truth, not the native component.
|
||||||
var propsTimeStamp = this.props.date.getTime();
|
const propsTimeStamp = this.props.date.getTime();
|
||||||
if (this._picker && nativeTimeStamp !== propsTimeStamp) {
|
if (this._picker && nativeTimeStamp !== propsTimeStamp) {
|
||||||
this._picker.setNativeProps({
|
this._picker.setNativeProps({
|
||||||
date: propsTimeStamp,
|
date: propsTimeStamp,
|
||||||
|
@ -116,11 +116,11 @@ var DatePickerIOS = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var props = this.props;
|
const props = this.props;
|
||||||
return (
|
return (
|
||||||
<View style={props.style}>
|
<View style={props.style}>
|
||||||
<RCTDatePickerIOS
|
<RCTDatePickerIOS
|
||||||
ref={ picker => this._picker = picker }
|
ref={ picker => { this._picker = picker; } }
|
||||||
style={styles.datePickerIOS}
|
style={styles.datePickerIOS}
|
||||||
date={props.date.getTime()}
|
date={props.date.getTime()}
|
||||||
maximumDate={
|
maximumDate={
|
||||||
|
@ -139,10 +139,9 @@ var DatePickerIOS = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
datePickerIOS: {
|
datePickerIOS: {
|
||||||
height: 216,
|
height: 216,
|
||||||
width: 320,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue