Skip to content

Commit

Permalink
9.0.0 (#214)
Browse files Browse the repository at this point in the history
* fix: disable country chip when field is disabled (#202)

* fix: disable country chip when field is disabled

* fixup! fix: disable country chip when field is disabled

* fixup! fixup! fix: disable country chip when field is disabled

* add ku and ckb translations (#209)

* fix: copy/paste wasn't possible due to context menu builder being passed as null (#198)

Co-authored-by: Mattias Siø Fjellvang <mattias@doubble.dk>

* bugfix: close keyboard on scroll (#162)

* Supported safe area in bottom sheet of country selector (#153)

Co-authored-by: Serge Shkurko <shkurko@thekey.space>

* update intl to 18.0 (#156)

* 7.0.6

* Fix search cursor color and initial bottom sheet height (#157)

* downgrade intl

* fix cursor color

* fix panel height

* enlarge prefix hit area

* added cursor fix

* revert changes from incorrect pr

* feature: allow searching by ISO code

* feature: search by submitting form

* bugfix: fixed issue where it would double pop the route if submitting form and both lists had results

* feature: search by submitting form (#160)

* feature: search by submitting form

* bugfix: fixed issue where it would double pop the route if submitting form and both lists had results

* feature: allow searching by ISO code (#161)

* bugfix: hide the keyboard when scrolling list, so it doesn't overlap

* feature: use autofill hints for search input

* feature: auto-submit when autofilling/pasting country

* refactor: move change handler into seperate method

* refactor: fixed deprecated window usage

* fix: copy/paste wasn't possible due to context menu builder being passed as null

* fix: remove listener on dispose

---------

Co-authored-by: Serge Shkurko <sergeshkurko@outlook.com>
Co-authored-by: Serge Shkurko <shkurko@thekey.space>
Co-authored-by: zitob9 <elias.housni@gmail.com>
Co-authored-by: cedvdb <cedvandenbosch@gmail.com>
Co-authored-by: cizmarf <37090294+cizmarf@users.noreply.github.com>
Co-authored-by: Mattias Siø Fjellvang <mattias@doubble.dk>

* feature: autofill country (#163)

* Supported safe area in bottom sheet of country selector (#153)

Co-authored-by: Serge Shkurko <shkurko@thekey.space>

* update intl to 18.0 (#156)

* 7.0.6

* Fix search cursor color and initial bottom sheet height (#157)

* downgrade intl

* fix cursor color

* fix panel height

* enlarge prefix hit area

* added cursor fix

* revert changes from incorrect pr

* feature: allow searching by ISO code

* feature: search by submitting form

* bugfix: fixed issue where it would double pop the route if submitting form and both lists had results

* feature: search by submitting form (#160)

* feature: search by submitting form

* bugfix: fixed issue where it would double pop the route if submitting form and both lists had results

* feature: allow searching by ISO code (#161)

* bugfix: hide the keyboard when scrolling list, so it doesn't overlap

* feature: use autofill hints for search input

* feature: auto-submit when autofilling/pasting country

* refactor: move change handler into seperate method

* refactor: fixed deprecated window usage

* fix: copy/paste wasn't possible due to context menu builder being passed as null

* fix: remove listener on dispose

---------

Co-authored-by: Serge Shkurko <sergeshkurko@outlook.com>
Co-authored-by: Serge Shkurko <shkurko@thekey.space>
Co-authored-by: zitob9 <elias.housni@gmail.com>
Co-authored-by: cedvdb <cedvandenbosch@gmail.com>
Co-authored-by: cizmarf <37090294+cizmarf@users.noreply.github.com>
Co-authored-by: Mattias Siø Fjellvang <mattias@doubble.dk>

* feat: add ability to customise search delegate app bar theme (#208)

* Refactor (#212)

* 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

* External country selector (#213)

* 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

* localization

* readd example

* localization

* dart fix

* external country selector

* cc

---------

Co-authored-by: Tautvydas Šidlauskas <tautvydas.sidlauskas@gmail.com>
Co-authored-by: Ahmad Najm <86409804+ahmadnajmdev@users.noreply.github.com>
Co-authored-by: Mattias Fjellvang <simplenotezy@users.noreply.github.com>
Co-authored-by: Mattias Siø Fjellvang <mattias@doubble.dk>
Co-authored-by: Serge Shkurko <sergeshkurko@outlook.com>
Co-authored-by: Serge Shkurko <shkurko@thekey.space>
Co-authored-by: zitob9 <elias.housni@gmail.com>
Co-authored-by: cizmarf <37090294+cizmarf@users.noreply.github.com>
  • Loading branch information
9 people committed Feb 5, 2024
1 parent ddcbfb0 commit 29de145
Show file tree
Hide file tree
Showing 206 changed files with 4,588 additions and 22,858 deletions.
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

0 comments on commit 29de145

Please sign in to comment.