Skip to content

Commit 35150ed

Browse files
authored
Merge pull request xgfe#124 from brunocascio/patch-1
feat(datepicker): Ability to pass icon component with `iconComponent` property
2 parents 65ec3fd + 6c02759 commit 35150ed

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

index.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,29 @@ class DatePicker extends Component {
257257
this.props.onOpenModal();
258258
}
259259
}
260+
261+
_renderIcon() {
262+
const {
263+
showIcon,
264+
iconSource,
265+
iconComponent,
266+
customStyles
267+
} = this.props;
268+
269+
if (showIcon) {
270+
if (!!iconComponent) {
271+
return iconComponent;
272+
}
273+
return (
274+
<Image
275+
style={[Style.dateIcon, customStyles.dateIcon]}
276+
source={iconSource}
277+
/>
278+
);
279+
}
280+
281+
return null;
282+
}
260283

261284
render() {
262285
const {
@@ -290,10 +313,7 @@ class DatePicker extends Component {
290313
<View style={dateInputStyle}>
291314
{this.getTitleElement()}
292315
</View>
293-
{showIcon && <Image
294-
style={[Style.dateIcon, customStyles.dateIcon]}
295-
source={iconSource}
296-
/>}
316+
{this._renderIcon()}
297317
{Platform.OS === 'ios' && <Modal
298318
transparent={true}
299319
animationType="none"
@@ -389,6 +409,7 @@ DatePicker.propTypes = {
389409
confirmBtnText: React.PropTypes.string,
390410
cancelBtnText: React.PropTypes.string,
391411
iconSource: React.PropTypes.oneOfType([React.PropTypes.number, React.PropTypes.object]),
412+
iconComponent: React.PropTypes.element,
392413
customStyles: React.PropTypes.object,
393414
showIcon: React.PropTypes.bool,
394415
disabled: React.PropTypes.bool,

0 commit comments

Comments
 (0)