Skip to content

Commit

Permalink
Merge pull request #93 from mykhailo-melnyk/master
Browse files Browse the repository at this point in the history
Add onPressCancel and onPressConfirm callbacks
  • Loading branch information
thegamenicorus authored Jul 7, 2019
2 parents e30602a + f78928b commit 9db8aee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/countryPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const propTypes = {
cancelText: PropTypes.string,
itemStyle: PropTypes.object,
onSubmit: PropTypes.func,
onPressCancel: PropTypes.func,
onPressConfirm: PropTypes.func,
};

export default class CountryPicker extends Component {
Expand Down Expand Up @@ -44,12 +46,20 @@ export default class CountryPicker extends Component {
}

onPressCancel() {
if(this.props.onPressCancel){
this.props.onPressCancel();
}

this.setState({
modalVisible: false,
});
}

onPressSubmit() {
if(this.props.onPressConfirm){
this.props.onPressConfirm();
}

if (this.props.onSubmit) {
this.props.onSubmit(this.state.selectedCountry);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ export default class PhoneInput extends Component {
confirmTextStyle={this.props.confirmTextStyle}
pickerBackgroundColor={this.props.pickerBackgroundColor}
itemStyle={this.props.pickerItemStyle}
onPressCancel={this.props.onPressCancel}
onPressConfirm={this.props.onPressConfirm}
/>
</View>
);
Expand All @@ -244,6 +246,8 @@ PhoneInput.propTypes = {
offset: PropTypes.number,
textProps: PropTypes.object,
onSelectCountry: PropTypes.func,
onPressCancel: PropTypes.func,
onPressConfirm: PropTypes.func,
pickerButtonColor: PropTypes.string,
pickerBackgroundColor: PropTypes.string,
pickerItemStyle: styleType,
Expand Down

0 comments on commit 9db8aee

Please sign in to comment.