Skip to content

Commit e19be0d

Browse files
committed
Merging P/R thegamenicorus#119 117
1 parent 0fab629 commit e19be0d

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

examples/CustomPicker/ModalPickerImage/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

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

66
import PropTypes from 'prop-types';
77

@@ -14,16 +14,16 @@ const propTypes = {
1414
data: PropTypes.array,
1515
onChange: PropTypes.func,
1616
initValue: PropTypes.string,
17-
style: View.propTypes.style,
18-
selectStyle: View.propTypes.style,
19-
optionStyle: View.propTypes.style,
17+
style: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
18+
selectStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
19+
optionStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
2020
optionTextStyle: Text.propTypes.style,
21-
sectionStyle: View.propTypes.style,
21+
sectionStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
2222
sectionTextStyle: Text.propTypes.style,
23-
cancelStyle: View.propTypes.style,
23+
cancelStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
2424
cancelTextStyle: Text.propTypes.style,
25-
overlayStyle: View.propTypes.style,
26-
cancelText: PropTypes.string,
25+
overlayStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
26+
cancelText: PropTypes.string
2727
};
2828

2929
const defaultProps = {

lib/index.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default class PhoneInput extends Component {
5757
onChangePhoneNumber(number) {
5858
const actionAfterSetState = this.props.onChangePhoneNumber
5959
? () => {
60-
this.props.onChangePhoneNumber(number);
61-
}
60+
this.props.onChangePhoneNumber(number);
61+
}
6262
: null;
6363
this.updateFlagAndFormatNumber(number, actionAfterSetState);
6464
}
@@ -100,7 +100,7 @@ export default class PhoneInput extends Component {
100100
}
101101

102102
getValue() {
103-
return this.state.formattedNumber.replace(/\s/g,'');
103+
return this.state.formattedNumber.replace(/\s/g, '');
104104
}
105105

106106
getNumberType() {
@@ -181,17 +181,25 @@ export default class PhoneInput extends Component {
181181
render() {
182182
const { iso2, inputValue, disabled } = this.state;
183183
const TextComponent = this.props.textComponent || TextInput;
184+
const FlagSource = Flags.get(iso2);
184185
return (
185186
<View style={[styles.container, this.props.style]}>
186187
<TouchableWithoutFeedback
187188
onPress={this.onPressFlag}
188189
disabled={disabled}
189190
>
190-
<Image
191-
source={Flags.get(iso2)}
192-
style={[styles.flag, this.props.flagStyle]}
193-
onPress={this.onPressFlag}
194-
/>
191+
{
192+
!!FlagSource ? (
193+
<Image
194+
source={FlagSource}
195+
style={[styles.flag, this.props.flagStyle]}
196+
onPress={this.onPressFlag}
197+
/>
198+
) :
199+
<View
200+
style={[styles.flag, this.props.flagStyle]}
201+
/>
202+
}
195203
</TouchableWithoutFeedback>
196204
<View style={{ flex: 1, marginLeft: this.props.offset || 10 }}>
197205
<TextComponent
@@ -206,7 +214,7 @@ export default class PhoneInput extends Component {
206214
}}
207215
keyboardType="phone-pad"
208216
underlineColorAndroid="rgba(0,0,0,0)"
209-
value={inputValue}
217+
value={this.state.formattedNumber}
210218
{...this.props.textProps}
211219
/>
212220
</View>

0 commit comments

Comments
 (0)