Skip to content

Commit

Permalink
Merging P/R thegamenicorus#119 117
Browse files Browse the repository at this point in the history
  • Loading branch information
sleroy committed Sep 28, 2019
1 parent 0fab629 commit e19be0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
16 changes: 8 additions & 8 deletions examples/CustomPicker/ModalPickerImage/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


import React from 'react';
import { View, Modal, Text, ScrollView, TouchableOpacity, Image } from 'react-native';
import { View, Modal, Text, ScrollView, TouchableOpacity, Image, ViewPropTypes } from 'react-native';

import PropTypes from 'prop-types';

Expand All @@ -14,16 +14,16 @@ const propTypes = {
data: PropTypes.array,
onChange: PropTypes.func,
initValue: PropTypes.string,
style: View.propTypes.style,
selectStyle: View.propTypes.style,
optionStyle: View.propTypes.style,
style: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
selectStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
optionStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
optionTextStyle: Text.propTypes.style,
sectionStyle: View.propTypes.style,
sectionStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
sectionTextStyle: Text.propTypes.style,
cancelStyle: View.propTypes.style,
cancelStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
cancelTextStyle: Text.propTypes.style,
overlayStyle: View.propTypes.style,
cancelText: PropTypes.string,
overlayStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
cancelText: PropTypes.string
};

const defaultProps = {
Expand Down
26 changes: 17 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default class PhoneInput extends Component {
onChangePhoneNumber(number) {
const actionAfterSetState = this.props.onChangePhoneNumber
? () => {
this.props.onChangePhoneNumber(number);
}
this.props.onChangePhoneNumber(number);
}
: null;
this.updateFlagAndFormatNumber(number, actionAfterSetState);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ export default class PhoneInput extends Component {
}

getValue() {
return this.state.formattedNumber.replace(/\s/g,'');
return this.state.formattedNumber.replace(/\s/g, '');
}

getNumberType() {
Expand Down Expand Up @@ -181,17 +181,25 @@ export default class PhoneInput extends Component {
render() {
const { iso2, inputValue, disabled } = this.state;
const TextComponent = this.props.textComponent || TextInput;
const FlagSource = Flags.get(iso2);
return (
<View style={[styles.container, this.props.style]}>
<TouchableWithoutFeedback
onPress={this.onPressFlag}
disabled={disabled}
>
<Image
source={Flags.get(iso2)}
style={[styles.flag, this.props.flagStyle]}
onPress={this.onPressFlag}
/>
{
!!FlagSource ? (
<Image
source={FlagSource}
style={[styles.flag, this.props.flagStyle]}
onPress={this.onPressFlag}
/>
) :
<View
style={[styles.flag, this.props.flagStyle]}
/>
}
</TouchableWithoutFeedback>
<View style={{ flex: 1, marginLeft: this.props.offset || 10 }}>
<TextComponent
Expand All @@ -206,7 +214,7 @@ export default class PhoneInput extends Component {
}}
keyboardType="phone-pad"
underlineColorAndroid="rgba(0,0,0,0)"
value={inputValue}
value={this.state.formattedNumber}
{...this.props.textProps}
/>
</View>
Expand Down

0 comments on commit e19be0d

Please sign in to comment.