From 002024cc456246761421f6e5c354466baa819843 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Wed, 1 Jun 2016 06:48:29 -0700 Subject: [PATCH] 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 --- .../DatePicker/DatePickerIOS.ios.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index fe7c05e70..60382cc4a 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -13,13 +13,13 @@ */ 'use strict'; -var NativeMethodsMixin = require('NativeMethodsMixin'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const PropTypes = require('ReactPropTypes'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const View = require('View'); -var requireNativeComponent = require('requireNativeComponent'); +const requireNativeComponent = require('requireNativeComponent'); type DefaultProps = { 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 * source of truth. */ -var DatePickerIOS = React.createClass({ +const DatePickerIOS = React.createClass({ // TOOD: Put a better type for _picker _picker: (undefined: ?$FlowFixMe), @@ -97,7 +97,7 @@ var DatePickerIOS = React.createClass({ }, _onChange: function(event: Event) { - var nativeTimeStamp = event.nativeEvent.timestamp; + const nativeTimeStamp = event.nativeEvent.timestamp; this.props.onDateChange && this.props.onDateChange( new Date(nativeTimeStamp) ); @@ -107,7 +107,7 @@ var DatePickerIOS = React.createClass({ // prop. That way they can also disallow/undo/mutate the selection of // certain values. In other words, the embedder of this component should // 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) { this._picker.setNativeProps({ date: propsTimeStamp, @@ -116,11 +116,11 @@ var DatePickerIOS = React.createClass({ }, render: function() { - var props = this.props; + const props = this.props; return ( this._picker = picker } + ref={ picker => { this._picker = picker; } } style={styles.datePickerIOS} date={props.date.getTime()} maximumDate={ @@ -139,10 +139,9 @@ var DatePickerIOS = React.createClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ datePickerIOS: { height: 216, - width: 320, }, });