Skip to content

Commit 9db8aee

Browse files
Merge pull request #93 from mykhailo-melnyk/master
Add onPressCancel and onPressConfirm callbacks
2 parents e30602a + f78928b commit 9db8aee

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/countryPicker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const propTypes = {
1414
cancelText: PropTypes.string,
1515
itemStyle: PropTypes.object,
1616
onSubmit: PropTypes.func,
17+
onPressCancel: PropTypes.func,
18+
onPressConfirm: PropTypes.func,
1719
};
1820

1921
export default class CountryPicker extends Component {
@@ -44,12 +46,20 @@ export default class CountryPicker extends Component {
4446
}
4547

4648
onPressCancel() {
49+
if(this.props.onPressCancel){
50+
this.props.onPressCancel();
51+
}
52+
4753
this.setState({
4854
modalVisible: false,
4955
});
5056
}
5157

5258
onPressSubmit() {
59+
if(this.props.onPressConfirm){
60+
this.props.onPressConfirm();
61+
}
62+
5363
if (this.props.onSubmit) {
5464
this.props.onSubmit(this.state.selectedCountry);
5565
}

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ export default class PhoneInput extends Component {
225225
confirmTextStyle={this.props.confirmTextStyle}
226226
pickerBackgroundColor={this.props.pickerBackgroundColor}
227227
itemStyle={this.props.pickerItemStyle}
228+
onPressCancel={this.props.onPressCancel}
229+
onPressConfirm={this.props.onPressConfirm}
228230
/>
229231
</View>
230232
);
@@ -244,6 +246,8 @@ PhoneInput.propTypes = {
244246
offset: PropTypes.number,
245247
textProps: PropTypes.object,
246248
onSelectCountry: PropTypes.func,
249+
onPressCancel: PropTypes.func,
250+
onPressConfirm: PropTypes.func,
247251
pickerButtonColor: PropTypes.string,
248252
pickerBackgroundColor: PropTypes.string,
249253
pickerItemStyle: styleType,

0 commit comments

Comments
 (0)