Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.0.0 #214

Merged
merged 8 commits into from
Feb 5, 2024
Merged

9.0.0 #214

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/deploy_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- name: Install deps
run: flutter pub get
working-directory: ./example
- name: build
run: flutter build web --base-href "/phone_form_field/"
working-directory: ./example
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./example/build/web
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
File renamed without changes.
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
113 changes: 54 additions & 59 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 All @@ -153,6 +142,12 @@ 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 @@ -175,26 +170,26 @@ PhoneFormField(
That's it.


A bunch of languages are built-in:

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

### Supported languages

- ar
- de
- el
- en
- es
- fa
- fr
- hi
- it
- ku
- nb
- nl
- pt
- ru
- 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 in flutter_country_selector and phone_form_field repositories.
1 change: 0 additions & 1 deletion build.sh

This file was deleted.

Binary file removed demo_image.png
Binary file not shown.
23 changes: 0 additions & 23 deletions example/.github/workflows/ci.yml

This file was deleted.

4 changes: 1 addition & 3 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
migrate_working_dir/

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

# Web related

# Symbolication related
app.*.symbols

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

version:
revision: db747aa1331bd95bc9b3874c842261ca2d302cd5
channel: stable
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
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
Loading