Skip to content

Commit

Permalink
Refactor (#212)
Browse files Browse the repository at this point in the history
* fix merge issue

* remove generated files from git

* saving

* refactor

* improve search ux

* refactor

* saving

* refactor

* rm

* upgrade flag cache

* cache

* saving

* refa

* refactor

* comment

* validation

* moving tests

* saving

* language

* fixing tests

* fix tests

* saving

* saving

* saving

* fix all tests
  • Loading branch information
cedvdb authored Feb 4, 2024
1 parent 823bd7d commit 97b2388
Show file tree
Hide file tree
Showing 88 changed files with 3,591 additions and 2,672 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
.dart_tool/
.packages
build/
example/build
example/build
**/generated_plugin_registrant.dart
**/generated_plugin_registrant.cc
**/generated_plugin_registrant.h
**/generated_plugin_registrant.cmake
36 changes: 0 additions & 36 deletions .pubignore

This file was deleted.

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## [9.0.0]

- Big Internal refactor in the hope of making contribution easier
- Various fixes for country selection UX
- Various fixes for input cursor issues
- Improve accessibility touches surfaces
- Improve accessibility labels
- Some visual tweaks
- Added some missing countries
- [Breaking] : no validation done by default
- [Breaking] : provided validators now require a context parameter
- [Breaking] : `LocalizedCountryRegistry` removed. If you were using it to localize a country name, you should use `PhoneFieldLocalization.of(context).countryName(isoCode)`.
- [Deprecated] : `isCountryChipPersistent` in favor of `isCountryButtonPersistent`.
- [Deprecated] : `shouldFormat`, it is now always ON by default
- [Deprecated] : `defaultCountry`, you should now use either `initialValue` or provide a controller with an initial value.
- [Deprecated] : `CountrySelectorNavigator.searchDelegate()` changed into `CountrySelectorNavigator.PageNavigator()`.


## [8.1.1]
- Upgraded phone_numbers_parser lib to 8.1.0
- Added norwegian language (PR #203) thanks @sidlatau
Expand Down
82 changes: 36 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,42 @@ Flutter phone input integrated with flutter internationalization
## Features

- Totally cross platform, this is a dart only package / dependencies
- Internationalization
- Internationalization: many languages supported
- Semantics
- Phone formatting localized by region
- Phone number validation (built-in validators included for main use cases)
- Support autofill and copy paste
- Extends Flutter's FormField
- Support auto fill and copy paste
- Form field
- Uses dart phone_numbers_parser for parsing


## Demo

Demo available at https://cedvdb.github.io/phone_form_field/


## Usage

```dart
// works without any param
PhoneFormField();
// all params
/// params
PhoneFormField(
key: Key('phone-field')
controller: null, // controller & initialValue value
initialValue: null, // can't be supplied simultaneously
shouldFormat: true // default
defaultCountry: IsoCode.US, // default
decoration: InputDecoration(
labelText: 'Phone', // default to null
border: OutlineInputBorder() // default to UnderlineInputBorder(),
// ...
),
validator: PhoneValidator.validMobile(), // default PhoneValidator.valid()
isCountryChipPersistent: false, // default
isCountrySelectionEnabled: true, // default
countrySelectorNavigator: CountrySelectorNavigator.bottomSheet(),
showFlagInInput: true, // default
flagSize: 16, // default
autofillHints: [AutofillHints.telephoneNumber], // default to null
enabled: true, // default
autofocus: false, // default
onSaved: (PhoneNumber p) => print('saved $p'), // default null
onChanged: (PhoneNumber p) => print('saved $p'), // default null
// ... + other textfield params
)
initialValue: PhoneNumber.parse('+33'), // or use the controller
validator: PhoneValidator.compose(
[PhoneValidator.required(), PhoneValidator.validMobile()]),
countrySelectorNavigator: const CountrySelectorNavigator.page(),
onChanged: (phoneNumber) => print('changed into $phoneNumber'),
enabled: true,
countryButtonPadding: null,
isCountrySelectionEnabled: true,
isCountryButtonPersistent: true,
showDialCode: true,
showIsoCodeInInput: true,
showFlagInInput: true,
flagSize: 16
// + all parameters of TextField
// + all parameters of FormField
// ...
);
```

## Validation
Expand All @@ -68,7 +58,6 @@ PhoneFormField(
### Validators details

* Each validator has an optional `errorText` property to override built-in translated text
* Most of them have an optional `allowEmpty` (default is true) preventing to flag an empty field as valid. Consider using a composed validator with a first `PhoneValidator.required` when a different text is needed for empty field.

### Composing validators

Expand Down Expand Up @@ -103,8 +92,8 @@ Here are the list of the parameters available for all built-in country selector

### Built-in country selector

* **CountrySelectorNavigator.searchDelegate**
Open a dialog to select the country.
* **CountrySelectorNavigator.page**
Open a page to select the country.
No extra parameters

* **CountrySelectorNavigator.dialog**
Expand Down Expand Up @@ -134,11 +123,11 @@ Here are the list of the parameters available for all built-in country selector
### Custom Country Selector Navigator

You can use your own country selector by creating a class that implements `CountrySelectorNavigator`
It has one required method `navigate` expected to return the selected country:
It has one required method `show` expected to return the selected country:

```dart
class CustomCountrySelectorNavigator implements CountrySelectorNavigator {
Future<Country?> navigate(BuildContext context) {
Future<Country?> show(BuildContext context) {
// ask user for a country and return related `Country` class
}
}
Expand Down Expand Up @@ -179,22 +168,23 @@ PhoneFormField(

- 'ar',
- 'de',
- 'el',
- 'en',
- 'el'
- 'es',
- 'fa',
- 'fr',
- 'hin',
- 'hi',
- 'it',
- 'ku',
- 'nb',
- 'nl',
- 'pt',
- 'ru',
- 'uz',
- 'uk',
- 'tr',
- 'zh',
- 'sv',
- 'tr',
- 'uk',
- 'uz',
- 'zh',


If one of the language you target is not supported you can submit a
pull request with the translated file in src/l10n
If one of the language you target is not supported you can submit a
pull request
76 changes: 0 additions & 76 deletions example/.pubignore

This file was deleted.

Loading

0 comments on commit 97b2388

Please sign in to comment.