Skip to content

Commit

Permalink
feat(datepicker): add support for custom icon
Browse files Browse the repository at this point in the history
  • Loading branch information
feyy committed May 6, 2016
1 parent 1bbd66e commit 7ffbe43
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ You can check [index.js](https://github.com/xgfe/react-native-datepicker/blob/ma
| format | 'YYYY-MM-DD' | `string` | Specify the display format of the date, which using [moment.js](http://momentjs.com/). The default value change according to the mode. |
| confirmBtnText | - | `string` | Specify the text of confirm btn in ios. |
| cancelBtnText | - | `string` | Specify the text of cancel btn in ios. |
| iconSource | - | `{uri: string} | number` | Specify the icon. Same as the `source` of Image, always using `require()` |
| minDate | - | `string | date` | Restricts the range of possible date values. |
| maxDate | - | `string | date` | Restricts the range of possible date values. |
| duration | 300 | `number` | Specify the animation duration of datepicker.
Expand Down
Binary file added example/google_calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions example/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class example extends Component {
maxDate="2016-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
iconSource={require('./google_calendar.png')}
onDateChange={(date) => {this.setState({date: date})}}
/>
<Text style={styles.instructions}>date: {this.state.date}</Text>
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class DatePicker extends Component {
confirmBtnText = this.props.confirmBtnText || '确定';
cancelBtnText = this.props.cancelBtnText || '取消';

iconSource = this.props.iconSource || require('./date_icon.png');

state = {
date: this.getDate(),
modalVisible: false,
Expand Down Expand Up @@ -205,7 +207,7 @@ class DatePicker extends Component {
</View>
<Image
style={Style.dateIcon}
source={require('./date_icon.png')}
source={this.iconSource}
/>
{Platform.OS === 'ios' && <Modal
transparent={true}
Expand Down

0 comments on commit 7ffbe43

Please sign in to comment.