Skip to content

Commit

Permalink
[Murat] Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat Gun committed Nov 19, 2023
1 parent cd9674e commit 519b98a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ EPhoneField()

### EphineField Country Picker Widgets

| Dialog | Bottom Sheet |
|------------------------------------------------------- | -------------------------------------------------------|
| <img src="./ephone-field-dialog.png" width="280"> | <img src="./ephone-field-bottomsheet.png" width="280"> |
| Dialog | Bottom Sheet | Page
|---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------|---|
| <img src="https://raw.githubusercontent.com/desxz/ephone_field/main/ephone-field-dialog.png" width="280"> | <img src="https://raw.githubusercontent.com/desxz/ephone_field/main/ephone-field-bottomsheet.png" width="280"> | <img src="https://raw.githubusercontent.com/desxz/ephone_field/main/ephone-field-page.png" width="280"> |


## Additional information
Expand Down Expand Up @@ -86,4 +86,4 @@ EPhoneField()
| validator | The validator for the input field. | `FormValidator` | `null` |
| onFieldSubmitted | The callback when the input is submitted. | `ValueChanged<String>` | `null` |
| onCountryChanged | The callback when the country is changed. | `ValueChanged<Country>` | `null` |
| inputFormatters | The input formatters for the input field. | `List<TextInputFormatter>` | `EphoneFieldType.inputFormatters()` |
| inputFormatters | The input formatters for the input field. | `List<TextInputFormatter>` | `EphoneFieldType.inputFormatters()` |
Binary file added ephone_field_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions lib/src/components/country_picker_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Function()? _openCountryPickerMenu(
context, searchInputDecoration, title, titlePadding, isSearchable, pickerHeight, countries, onValuePicked);
case PickerMenuType.page:
return _openCountryPickerPage(
context, searchInputDecoration, title, titlePadding, isSearchable, pickerHeight, countries, onValuePicked);
context, searchInputDecoration, title, titlePadding, isSearchable, countries, onValuePicked);
default:
return null;
}
Expand Down Expand Up @@ -178,7 +178,6 @@ void Function()? _openCountryPickerPage(
String? title,
EdgeInsetsGeometry titlePadding,
bool isSearchable,
CountryPickerHeigth pickerHeight,
List<Country> countries,
void Function(Country) onValuePicked,
) {
Expand Down
22 changes: 7 additions & 15 deletions lib/src/email_phone_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,42 +184,35 @@ class _EphoneFieldState extends State<EPhoneField> {
autovalidateMode: widget.autovalidateMode,
onChanged: (String value) {
if (_type == EphoneFieldType.phone) {
value =
'+${_selectedCountry.dialCode}${value.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
value = '+${_selectedCountry.dialCode}${value.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
}
widget.onChanged?.call(value);
},
onSaved: (String? value) {
if (_type == EphoneFieldType.phone) {
value =
'+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
value = '+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
}
widget.onSaved?.call(value);
},
onFieldSubmitted: (String? value) {
if (_type == EphoneFieldType.phone) {
value =
'+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
value = '+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
}
widget.onFieldSubmitted?.call(value);
},
initialValue: widget.initialValue,
decoration: widget.decoration.copyWith(
prefixIcon: _buildCountryPicker(_type == EphoneFieldType.phone),
labelText: _type.labelText(widget.emptyLabelText,
widget.emailLabelText, widget.phoneLabelText)),
labelText: _type.labelText(widget.emptyLabelText, widget.emailLabelText, widget.phoneLabelText)),
keyboardType: _type.keyboardType,
validator: (String? value) {
if (_type == EphoneFieldType.phone) {
value =
'+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
value = '+${_selectedCountry.dialCode}${value?.replaceAll(widget.phoneNumberMaskSplitter.value, '')}';
}
return widget.validator?.call(value);
},
inputFormatters: widget.inputFormatters ??
_type.inputFormatters(
_selectedCountry,
widget.phoneNumberMaskSplitter != MaskSplitCharacter.none,
_type.inputFormatters(_selectedCountry, widget.phoneNumberMaskSplitter != MaskSplitCharacter.none,
widget.phoneNumberMaskSplitter.value),
);
}
Expand Down Expand Up @@ -251,8 +244,7 @@ class _EphoneFieldState extends State<EPhoneField> {

/// Updates the [_type] of the input field based on the [_controller] text.
void _updateTextFieldType() {
final text =
_controller.text.replaceAll(widget.phoneNumberMaskSplitter.value, '');
final text = _controller.text.replaceAll(widget.phoneNumberMaskSplitter.value, '');
if (text.isEmpty) {
setState(() {
_type = widget.initialType;
Expand Down

0 comments on commit 519b98a

Please sign in to comment.