From 645d6f6c7d769c42916ab47831404a89d9ba5d1e Mon Sep 17 00:00:00 2001 From: Jim Cummins Date: Fri, 19 Feb 2016 04:10:29 -0600 Subject: [PATCH] add pickerWidth prop --- index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 4c614db..27f922f 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,7 @@ export default class PickerAny extends React.Component { pickerTitleStyle: PropTypes.any, pickerToolBarStyle: PropTypes.any, pickerItemStyle: PropTypes.any, + pickerWidth: PropTypes.number, pickerHeight: PropTypes.number, showDuration: PropTypes.number, pickerData: PropTypes.any.isRequired, @@ -44,7 +45,8 @@ export default class PickerAny extends React.Component { showDuration: 300, onPickerDone: ()=>{}, onPickerCancel: ()=>{}, - onValueChange: ()=>{} + onValueChange: ()=>{}, + pickerWidth: width > height ? height:width }; constructor(props, context){ @@ -61,6 +63,9 @@ export default class PickerAny extends React.Component { } shouldComponentUpdate(nextProps, nextState, context){ + if(nextState.pickerWidth !== this.state.pickerWidth) { + return true; + } if(JSON.stringify(nextState.selectedValue) === JSON.stringify(this.state.selectedValue)){ return false; } @@ -78,6 +83,7 @@ export default class PickerAny extends React.Component { let pickerTitleStyle = props.pickerTitleStyle; let pickerToolBarStyle = props.pickerToolBarStyle; let pickerItemStyle = props.pickerItemStyle; + let pickerWidth = props.pickerWidth; let pickerHeight = props.pickerHeight; let showDuration = props.showDuration; let pickerData = props.pickerData; @@ -125,6 +131,7 @@ export default class PickerAny extends React.Component { pickerTitleStyle, pickerToolBarStyle, pickerItemStyle, + pickerWidth, pickerHeight, showDuration, pickerData, @@ -341,7 +348,7 @@ export default class PickerAny extends React.Component { ); return ( - + - + {this.state.pickerCancelBtnText} @@ -487,7 +495,6 @@ export default class PickerAny extends React.Component { let styles = StyleSheet.create({ picker: { - width: width, position: 'absolute', bottom: 0, left: 0, @@ -495,7 +502,6 @@ let styles = StyleSheet.create({ overflow: 'hidden' }, pickerWrap: { - width: width, flexDirection: 'row' }, pickerWheel: { @@ -503,7 +509,6 @@ let styles = StyleSheet.create({ }, pickerToolbar: { height: 30, - width: width, backgroundColor: '#e6e6e6', flexDirection: 'row', borderTopWidth: 1, -- 2.26.2