@@ -46,7 +46,9 @@ export default class PhoneInput extends Component {
46
46
47
47
componentDidUpdate ( ) {
48
48
const { value, disabled } = this . props ;
49
- this . setState ( { disabled } ) ;
49
+ if ( disabled != null && disabled !== this . state . disabled ) {
50
+ this . setState ( { disabled} ) ;
51
+ }
50
52
51
53
if ( value && value !== this . state . value ) {
52
54
this . setState ( { value } ) ;
@@ -183,16 +185,18 @@ export default class PhoneInput extends Component {
183
185
const TextComponent = this . props . textComponent || TextInput ;
184
186
return (
185
187
< View style = { [ styles . container , this . props . style ] } >
186
- < TouchableWithoutFeedback
187
- onPress = { this . onPressFlag }
188
- disabled = { disabled }
189
- >
190
- < Image
191
- source = { Flags . get ( iso2 ) }
192
- style = { [ styles . flag , this . props . flagStyle ] }
188
+ { this . props . shouldShowCountryPicker && (
189
+ < TouchableWithoutFeedback
193
190
onPress = { this . onPressFlag }
194
- />
195
- </ TouchableWithoutFeedback >
191
+ disabled = { disabled }
192
+ >
193
+ < Image
194
+ source = { Flags . get ( iso2 ) }
195
+ style = { [ styles . flag , this . props . flagStyle ] }
196
+ onPress = { this . onPressFlag }
197
+ />
198
+ </ TouchableWithoutFeedback >
199
+ ) }
196
200
< View style = { { flex : 1 , marginLeft : this . props . offset || 10 } } >
197
201
< TextComponent
198
202
ref = { ref => {
@@ -211,23 +215,25 @@ export default class PhoneInput extends Component {
211
215
/>
212
216
</ View >
213
217
214
- < CountryPicker
215
- ref = { ref => {
216
- this . picker = ref ;
217
- } }
218
- selectedCountry = { iso2 }
219
- onSubmit = { this . selectCountry }
220
- buttonColor = { this . props . pickerButtonColor }
221
- buttonTextStyle = { this . props . pickerButtonTextStyle }
222
- cancelText = { this . props . cancelText }
223
- cancelTextStyle = { this . props . cancelTextStyle }
224
- confirmText = { this . props . confirmText }
225
- confirmTextStyle = { this . props . confirmTextStyle }
226
- pickerBackgroundColor = { this . props . pickerBackgroundColor }
227
- itemStyle = { this . props . pickerItemStyle }
228
- onPressCancel = { this . props . onPressCancel }
229
- onPressConfirm = { this . props . onPressConfirm }
230
- />
218
+ { this . props . shouldShowCountryPicker && (
219
+ < CountryPicker
220
+ ref = { ref => {
221
+ this . picker = ref ;
222
+ } }
223
+ selectedCountry = { iso2 }
224
+ onSubmit = { this . selectCountry }
225
+ buttonColor = { this . props . pickerButtonColor }
226
+ buttonTextStyle = { this . props . pickerButtonTextStyle }
227
+ cancelText = { this . props . cancelText }
228
+ cancelTextStyle = { this . props . cancelTextStyle }
229
+ confirmText = { this . props . confirmText }
230
+ confirmTextStyle = { this . props . confirmTextStyle }
231
+ pickerBackgroundColor = { this . props . pickerBackgroundColor }
232
+ itemStyle = { this . props . pickerItemStyle }
233
+ onPressCancel = { this . props . onPressCancel }
234
+ onPressConfirm = { this . props . onPressConfirm }
235
+ />
236
+ ) }
231
237
</ View >
232
238
) ;
233
239
}
@@ -265,11 +271,13 @@ PhoneInput.propTypes = {
265
271
confirmText : PropTypes . string ,
266
272
confirmTextTextStyle : styleType ,
267
273
disabled : PropTypes . bool ,
268
- allowZeroAfterCountryCode : PropTypes . bool
274
+ allowZeroAfterCountryCode : PropTypes . bool ,
275
+ shouldShowCountryPicker : PropTypes . bool
269
276
} ;
270
277
271
278
PhoneInput . defaultProps = {
272
279
initialCountry : "us" ,
273
280
disabled : false ,
274
- allowZeroAfterCountryCode : true
281
+ allowZeroAfterCountryCode : true ,
282
+ shouldShowCountryPicker : true
275
283
} ;
0 commit comments