@@ -145,6 +145,26 @@ render(){
145
145
146
146
[see full custom library picker example](https://github.com/thegamenicorus/react-native-phone-input/blob/master/examples/CustomLibraryPicker/app.js)
147
147
148
+ ## Custom Flag component
149
+
150
+ If you need to change how the flag is rendered, you can use the ` renderFlag` property. This function is passed the flag image source as a named ` imageSource` argument.
151
+
152
+ > Note: if you just need custom styles for the flag image, you can pass the ` flagStyle` prop, only use ` renderFlag` if you need to change what components are actually rendered within the touchable area of the flag.
153
+
154
+ ` ` ` jsx
155
+ < PhoneInput
156
+ renderFlag= {({ imageSource }) => {
157
+ return (
158
+ < View>
159
+ < Icon name= " chevron" / >
160
+ < Image source= {imageSource} width= {customWidth} height= {customHeight} style= {customStyles} / >
161
+ < / View>
162
+ )
163
+ }}
164
+ / >
165
+ ` ` `
166
+
167
+
148
168
## Custom Countries
149
169
150
170
` ` ` jsx
@@ -155,31 +175,32 @@ render(){
155
175
156
176
### Properties:
157
177
158
- | Property Name | Type | Default | Description |
159
- | ------------------------- | ---------------- | ------------------| ------------------------------------------------------------------------------ |
160
- | autoFormat | boolean | false | Format phone number while typing |
161
- | accessibilityLabel | string | 'Telephone input' | Label for accessibility purposes |
162
- | initialCountry | string | 'us' | initial selected country |
163
- | allowZeroAfterCountryCode | bool | true | allow user input 0 after country code |
164
- | disabled | bool | false | if true, disable all interaction of this component |
165
- | initialValue | string | null | initial phone number |
166
- | style | object | null | custom styles to be applied if supplied |
167
- | flagStyle | object | null | custom styles for flag image eg. {{width: 50, height: 30, borderWidth:0}} |
168
- | textStyle | object | null | custom styles for phone number text input eg. {{fontSize: 14}} |
169
- | textProps | object | null | properties for phone number text input eg. {{placeholder: 'Telephone number'}} |
170
- | textComponent | function | TextField | the input component to use |
171
- | offset | int | 10 | distance between flag and phone number |
172
- | pickerButtonColor | string | '#007AFF' | set button color of country picker |
173
- | pickerBackgroundColor | string | 'white' | set background color of country picker |
174
- | pickerItemStyle | object | null | custom styles for text in country picker eg. {{fontSize: 14}} |
175
- | cancelText | string | 'Cancel' | cancel word |
176
- | confirmText | string | 'Confirm' | confirm word |
177
- | cancelTextStyle | object | null | custom styles for country picker cancel button |
178
- | confirmTextStyle | object | null | custom styles for country picker confirm button |
179
- | onChangePhoneNumber | function(number) | null | function to be invoked when phone number is changed |
180
- | onSelectCountry | function(iso2) | null | function to be invoked when country picker is selected |
181
- | onPressFlag | function() | null | function to be invoked when press on flag image |
182
- | countriesList | array | null | custom countries list |
178
+ | Property Name | Type | Default | Description |
179
+ | ------------------------- | ------------------------- | ------------------| ------------------------------------------------------------------------------ |
180
+ | autoFormat | boolean | false | Format phone number while typing |
181
+ | accessibilityLabel | string | 'Telephone input' | Label for accessibility purposes |
182
+ | initialCountry | string | 'us' | initial selected country |
183
+ | allowZeroAfterCountryCode | bool | true | allow user input 0 after country code |
184
+ | disabled | bool | false | if true, disable all interaction of this component |
185
+ | initialValue | string | null | initial phone number |
186
+ | style | object | null | custom styles to be applied if supplied |
187
+ | flagStyle | object | null | custom styles for flag image eg. {{width: 50, height: 30, borderWidth:0}} |
188
+ | textStyle | object | null | custom styles for phone number text input eg. {{fontSize: 14}} |
189
+ | textProps | object | null | properties for phone number text input eg. {{placeholder: 'Telephone number'}} |
190
+ | textComponent | function | TextField | the input component to use |
191
+ | offset | int | 10 | distance between flag and phone number |
192
+ | pickerButtonColor | string | '#007AFF' | set button color of country picker |
193
+ | pickerBackgroundColor | string | 'white' | set background color of country picker |
194
+ | pickerItemStyle | object | null | custom styles for text in country picker eg. {{fontSize: 14}} |
195
+ | cancelText | string | 'Cancel' | cancel word |
196
+ | confirmText | string | 'Confirm' | confirm word |
197
+ | cancelTextStyle | object | null | custom styles for country picker cancel button |
198
+ | confirmTextStyle | object | null | custom styles for country picker confirm button |
199
+ | onChangePhoneNumber | function(number) | null | function to be invoked when phone number is changed |
200
+ | onSelectCountry | function(iso2) | null | function to be invoked when country picker is selected |
201
+ | onPressFlag | function() | null | function to be invoked when press on flag image |
202
+ | renderFlag | function({ imageSource }) | null | custom render function for the flag component, passed an image src |
203
+ | countriesList | array | null | custom countries list |
183
204
184
205
### Functions:
185
206
0 commit comments