Skip to content

Commit 3762e71

Browse files
authored
Merge pull request #128 from avencat/customTouchableComponent
Add the ability to pass a custom TouchableComponent
2 parents 17ca170 + 0a9feaf commit 3762e71

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ You can check [index.js](https://github.com/xgfe/react-native-datepicker/blob/ma
9292
| onCloseModal | - | `function` | This is called when the DatePicker Modal close |
9393
| onPressMask | - | `function` | This is called when clicking the ios modal mask |
9494
| modalOnResponderTerminationRequest | - | `function` | Set the callback for React Native's [Gesture Responder System](https://facebook.github.io/react-native/docs/gesture-responder-system.html#responder-lifecycle)'s call to `onResponderTerminationRequest`. By default this will reject a termination request, but can be overidden in case the View under the Modal is implementing custom gesture responders, and you wish for those to be overidden in certain cases. |
95+
| TouchableComponent | `TouchableHighlight` | `Component` | Replace the `TouchableHighlight` with a custom `Component`. For example : `TouchableOpacity` |
9596

9697
### Property `customStyles` available keys
9798

index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ class DatePicker extends Component {
342342
disabled && customStyles.disabled
343343
];
344344

345+
const TouchableComponent = this.props.TouchableComponent ? this.props.TouchableComponent : TouchableHighlight;
346+
345347
return (
346-
<TouchableHighlight
348+
<TouchableComponent
347349
style={[Style.dateTouch, style]}
348350
underlayColor={'transparent'}
349351
onPress={this.onPressDate}
@@ -369,13 +371,13 @@ class DatePicker extends Component {
369371
<View
370372
style={{flex: 1}}
371373
>
372-
<TouchableHighlight
374+
<TouchableComponent
373375
style={Style.datePickerMask}
374376
activeOpacity={1}
375377
underlayColor={'#00000077'}
376378
onPress={this.onPressMask}
377379
>
378-
<TouchableHighlight
380+
<TouchableComponent
379381
underlayColor={'#fff'}
380382
style={{flex: 1}}
381383
>
@@ -394,7 +396,7 @@ class DatePicker extends Component {
394396
style={[Style.datePicker, customStyles.datePicker]}
395397
/>
396398
</View>
397-
<TouchableHighlight
399+
<TouchableComponent
398400
underlayColor={'transparent'}
399401
onPress={this.onPressCancel}
400402
style={[Style.btnText, Style.btnCancel, customStyles.btnCancel]}
@@ -405,22 +407,22 @@ class DatePicker extends Component {
405407
>
406408
{cancelBtnText}
407409
</Text>
408-
</TouchableHighlight>
409-
<TouchableHighlight
410+
</TouchableComponent>
411+
<TouchableComponent
410412
underlayColor={'transparent'}
411413
onPress={this.onPressConfirm}
412414
style={[Style.btnText, Style.btnConfirm, customStyles.btnConfirm]}
413415
testID={confirmBtnTestID}
414416
>
415417
<Text style={[Style.btnTextText, customStyles.btnTextConfirm]}>{confirmBtnText}</Text>
416-
</TouchableHighlight>
418+
</TouchableComponent>
417419
</Animated.View>
418-
</TouchableHighlight>
419-
</TouchableHighlight>
420+
</TouchableComponent>
421+
</TouchableComponent>
420422
</View>
421423
</Modal>}
422424
</View>
423-
</TouchableHighlight>
425+
</TouchableComponent>
424426
);
425427
}
426428
}

0 commit comments

Comments
 (0)