Skip to content

Commit

Permalink
Merge pull request #124 from brunocascio/patch-1
Browse files Browse the repository at this point in the history
feat(datepicker): Ability to pass icon component with `iconComponent` property
  • Loading branch information
feyy authored May 15, 2017
2 parents 65ec3fd + 6c02759 commit 35150ed
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@ class DatePicker extends Component {
this.props.onOpenModal();
}
}

_renderIcon() {
const {
showIcon,
iconSource,
iconComponent,
customStyles
} = this.props;

if (showIcon) {
if (!!iconComponent) {
return iconComponent;
}
return (
<Image
style={[Style.dateIcon, customStyles.dateIcon]}
source={iconSource}
/>
);
}

return null;
}

render() {
const {
Expand Down Expand Up @@ -290,10 +313,7 @@ class DatePicker extends Component {
<View style={dateInputStyle}>
{this.getTitleElement()}
</View>
{showIcon && <Image
style={[Style.dateIcon, customStyles.dateIcon]}
source={iconSource}
/>}
{this._renderIcon()}
{Platform.OS === 'ios' && <Modal
transparent={true}
animationType="none"
Expand Down Expand Up @@ -389,6 +409,7 @@ DatePicker.propTypes = {
confirmBtnText: React.PropTypes.string,
cancelBtnText: React.PropTypes.string,
iconSource: React.PropTypes.oneOfType([React.PropTypes.number, React.PropTypes.object]),
iconComponent: React.PropTypes.element,
customStyles: React.PropTypes.object,
showIcon: React.PropTypes.bool,
disabled: React.PropTypes.bool,
Expand Down

0 comments on commit 35150ed

Please sign in to comment.