Skip to content

Commit

Permalink
Ability to pass icon component
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocascio authored May 9, 2017
1 parent 95c7d64 commit 6c02759
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 6c02759

Please sign in to comment.