Skip to content

Commit

Permalink
Revert "9.0.0 (#214)"
Browse files Browse the repository at this point in the history
This reverts commit 29de145.
  • Loading branch information
cedvdb authored Feb 5, 2024
1 parent 29de145 commit e87edbe
Show file tree
Hide file tree
Showing 206 changed files with 22,858 additions and 4,588 deletions.
File renamed without changes.
49 changes: 0 additions & 49 deletions .github/workflows/deploy_demo.yml

This file was deleted.

6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@
.dart_tool/
.packages
build/
example/build
**/generated_plugin_registrant.dart
**/generated_plugin_registrant.cc
**/generated_plugin_registrant.h
**/generated_plugin_registrant.cmake
example/build
36 changes: 36 additions & 0 deletions .pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
docs/
example/build
example/windows
example/web
example/android
example/ios
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
demo_image.png

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
18 changes: 0 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
## [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
113 changes: 59 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,52 @@ Flutter phone input integrated with flutter internationalization
## Features

- Totally cross platform, this is a dart only package / dependencies
- Internationalization: many languages supported
- Semantics
- Internationalization
- Phone formatting localized by region
- Phone number validation (built-in validators included for main use cases)
- Support auto fill and copy paste
- Form field
- Support autofill and copy paste
- Extends Flutter's FormField
- 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();
/// params
// all params
PhoneFormField(
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
// ...
);
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
)
```

## Validation
Expand All @@ -58,6 +68,7 @@ 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 @@ -92,8 +103,8 @@ Here are the list of the parameters available for all built-in country selector

### Built-in country selector

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

* **CountrySelectorNavigator.dialog**
Expand Down Expand Up @@ -123,11 +134,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 `show` expected to return the selected country:
It has one required method `navigate` expected to return the selected country:

```dart
class CustomCountrySelectorNavigator implements CountrySelectorNavigator {
Future<Country?> show(BuildContext context) {
Future<Country?> navigate(BuildContext context) {
// ask user for a country and return related `Country` class
}
}
Expand All @@ -142,12 +153,6 @@ PhoneFormField(

## Internationalization

### Dynamic localization

This package uses the `flutter_country_selector` package under the hood, which exports a method for dynamic localization `CountrySelectorLocalization.of(context).countryName(isoCode)`.

### Setup

Include the delegate

```dart
Expand All @@ -170,26 +175,26 @@ This package uses the `flutter_country_selector` package under the hood, which e
That's it.


### Supported languages

- ar
- de
- el
- en
- es
- fa
- fr
- hi
- it
- ku
- nb
- nl
- pt
- ru
- sv
- tr
- uk
- uz
- zh
A bunch of languages are built-in:

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


If one of the language you target is not supported you can submit a pull request in flutter_country_selector and phone_form_field repositories.
If one of the language you target is not supported you can submit a
pull request with the translated file in src/l10n
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm docs -rf && cd example && flutter build web --release && cd .. && mkdir docs && mv example/build/web/* docs
Binary file added demo_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions example/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: default

on:
pull_request:
branches:
- 'dev'
- 'main'

jobs:
flutter_test:
name: runs analyze and tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter pub get
- run: flutter analyze
- run: flutter test
4 changes: 3 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
Expand All @@ -27,10 +26,13 @@ migrate_working_dir/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related

# Symbolication related
app.*.symbols

Expand Down
39 changes: 2 additions & 37 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
channel: "stable"
revision: db747aa1331bd95bc9b3874c842261ca2d302cd5
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: android
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: ios
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: linux
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: macos
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: web
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: windows
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
Loading

0 comments on commit e87edbe

Please sign in to comment.