Skip to content

Commit

Permalink
Merge pull request #180 from matuszeg/master
Browse files Browse the repository at this point in the history
Add support for allowFontScaling
  • Loading branch information
feyy authored Apr 8, 2018
2 parents ec9fd7a + 3381063 commit 2651c78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ You can check [index.js](https://github.com/xgfe/react-native-datepicker/blob/ma
| iconComponent | - | `element` | Set the custom icon |
| disabled | false | `boolean` | Controller whether or not disable the picker |
| is24Hour | - | `boolean` | Set the TimePicker is24Hour flag. The default value depend on `format`. Only work in Android |
| allowFontScaling | true | `boolean` | Set to false to disable font scaling for every text component |
| placeholder | '' | `string` | The placeholder show when this.props.date is falsy |
| onDateChange | - | `function` | This is called when the user confirm the picked date or time in the UI. The first and only argument is a date or time string representing the new date and time formatted by [moment.js](http://momentjs.com/) with the given format property. |
| onOpenModal | - | `function` | This is called when the DatePicker Modal open. |
Expand Down
12 changes: 8 additions & 4 deletions datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ class DatePicker extends Component {
}

getTitleElement() {
const {date, placeholder, customStyles} = this.props;
const {date, placeholder, customStyles, allowFontScaling} = this.props;

if (!date && placeholder) {
return (<Text style={[Style.placeholderText, customStyles.placeholderText]}>{placeholder}</Text>);
return (<Text allowFontScaling={allowFontScaling} style={[Style.placeholderText, customStyles.placeholderText]}>{placeholder}</Text>);
}
return (<Text style={[Style.dateText, customStyles.dateText]}>{this.getDateStr()}</Text>);
return (<Text allowFontScaling={allowFontScaling} style={[Style.dateText, customStyles.dateText]}>{this.getDateStr()}</Text>);
}

onDateChange(date) {
Expand Down Expand Up @@ -340,6 +340,7 @@ class DatePicker extends Component {
testID,
cancelBtnTestID,
confirmBtnTestID,
allowFontScaling,
locale
} = this.props;

Expand Down Expand Up @@ -409,6 +410,7 @@ class DatePicker extends Component {
testID={cancelBtnTestID}
>
<Text
allowFontScaling={allowFontScaling}
style={[Style.btnTextText, Style.btnTextCancel, customStyles.btnTextCancel]}
>
{cancelBtnText}
Expand All @@ -420,7 +422,7 @@ class DatePicker extends Component {
style={[Style.btnText, Style.btnConfirm, customStyles.btnConfirm]}
testID={confirmBtnTestID}
>
<Text style={[Style.btnTextText, customStyles.btnTextConfirm]}>{confirmBtnText}</Text>
<Text allowFontScaling={allowFontScaling} style={[Style.btnTextText, customStyles.btnTextConfirm]}>{confirmBtnText}</Text>
</TouchableComponent>
</Animated.View>
</TouchableComponent>
Expand Down Expand Up @@ -450,6 +452,7 @@ DatePicker.defaultProps = {
// whether or not show the icon
showIcon: true,
disabled: false,
allowFontScaling: true,
hideText: false,
placeholder: '',
TouchableComponent: TouchableHighlight,
Expand All @@ -472,6 +475,7 @@ DatePicker.propTypes = {
customStyles: PropTypes.object,
showIcon: PropTypes.bool,
disabled: PropTypes.bool,
allowFontScaling: PropTypes.bool,
onDateChange: PropTypes.func,
onOpenModal: PropTypes.func,
onCloseModal: PropTypes.func,
Expand Down

0 comments on commit 2651c78

Please sign in to comment.