Skip to content

Commit 2651c78

Browse files
authored
Merge pull request xgfe#180 from matuszeg/master
Add support for allowFontScaling
2 parents ec9fd7a + 3381063 commit 2651c78

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ You can check [index.js](https://github.com/xgfe/react-native-datepicker/blob/ma
8686
| iconComponent | - | `element` | Set the custom icon |
8787
| disabled | false | `boolean` | Controller whether or not disable the picker |
8888
| is24Hour | - | `boolean` | Set the TimePicker is24Hour flag. The default value depend on `format`. Only work in Android |
89+
| allowFontScaling | true | `boolean` | Set to false to disable font scaling for every text component |
8990
| placeholder | '' | `string` | The placeholder show when this.props.date is falsy |
9091
| 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. |
9192
| onOpenModal | - | `function` | This is called when the DatePicker Modal open. |

datepicker.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ class DatePicker extends Component {
176176
}
177177

178178
getTitleElement() {
179-
const {date, placeholder, customStyles} = this.props;
179+
const {date, placeholder, customStyles, allowFontScaling} = this.props;
180180

181181
if (!date && placeholder) {
182-
return (<Text style={[Style.placeholderText, customStyles.placeholderText]}>{placeholder}</Text>);
182+
return (<Text allowFontScaling={allowFontScaling} style={[Style.placeholderText, customStyles.placeholderText]}>{placeholder}</Text>);
183183
}
184-
return (<Text style={[Style.dateText, customStyles.dateText]}>{this.getDateStr()}</Text>);
184+
return (<Text allowFontScaling={allowFontScaling} style={[Style.dateText, customStyles.dateText]}>{this.getDateStr()}</Text>);
185185
}
186186

187187
onDateChange(date) {
@@ -340,6 +340,7 @@ class DatePicker extends Component {
340340
testID,
341341
cancelBtnTestID,
342342
confirmBtnTestID,
343+
allowFontScaling,
343344
locale
344345
} = this.props;
345346

@@ -409,6 +410,7 @@ class DatePicker extends Component {
409410
testID={cancelBtnTestID}
410411
>
411412
<Text
413+
allowFontScaling={allowFontScaling}
412414
style={[Style.btnTextText, Style.btnTextCancel, customStyles.btnTextCancel]}
413415
>
414416
{cancelBtnText}
@@ -420,7 +422,7 @@ class DatePicker extends Component {
420422
style={[Style.btnText, Style.btnConfirm, customStyles.btnConfirm]}
421423
testID={confirmBtnTestID}
422424
>
423-
<Text style={[Style.btnTextText, customStyles.btnTextConfirm]}>{confirmBtnText}</Text>
425+
<Text allowFontScaling={allowFontScaling} style={[Style.btnTextText, customStyles.btnTextConfirm]}>{confirmBtnText}</Text>
424426
</TouchableComponent>
425427
</Animated.View>
426428
</TouchableComponent>
@@ -450,6 +452,7 @@ DatePicker.defaultProps = {
450452
// whether or not show the icon
451453
showIcon: true,
452454
disabled: false,
455+
allowFontScaling: true,
453456
hideText: false,
454457
placeholder: '',
455458
TouchableComponent: TouchableHighlight,
@@ -472,6 +475,7 @@ DatePicker.propTypes = {
472475
customStyles: PropTypes.object,
473476
showIcon: PropTypes.bool,
474477
disabled: PropTypes.bool,
478+
allowFontScaling: PropTypes.bool,
475479
onDateChange: PropTypes.func,
476480
onOpenModal: PropTypes.func,
477481
onCloseModal: PropTypes.func,

0 commit comments

Comments
 (0)