cedvdb / phone_form_field

Flutter phone number input
https://pub.dev/packages/phone_form_field
MIT License
71 stars 99 forks source link

Expose autofillHints #8

Closed xvrh closed 3 years ago

xvrh commented 3 years ago

Currently, the library exposes a flag withHint and inject AutofillHints.telephoneNumberNational if true. On iOS, I doesn't seem to work. I need to specify AutofillHints.telephoneNumber instead.

Can we simply expose the whole Iterable<String>? autofillHints instead of the bool flag?

cedvdb commented 3 years ago

I don't have an apple phone nor a mac. The problem is that there is two "inputs". One for the dial code and one for the national number (the telephone number without the dial code).

My worries with this are two fold:

However this is an easy feature to add.

xvrh commented 3 years ago

Would it be possible that the field detect that it is filled (or pasted) with an international prefix and automatically change the national code? ie. In if I paste "+32477123456" into the PhoneField, I expect it will change the national field to '+32'.

cedvdb commented 3 years ago

Well the phone_numbers_parser library allows to parse a phone number in its entirety. So parsing a full phone number and extracting the two parts is possible. What I'm not sure about is if it's possible to hi-jack the process of autofill hint in a non-hacky way,

xvrh commented 3 years ago

I imagine that the AutoFill feature can't be 100% correct all the time. I imagine it works by looking at data entered in other apps with annotated textfield.

I think the best thing to do are:

cedvdb commented 3 years ago

Here is what will be done:

cedvdb commented 3 years ago

Can you try the latest and see if that solve all your issues ? :

dependencies:
  phone_form_field:
    git:
      url: https://github.com/cedvdb/phone_form_field
xvrh commented 3 years ago

Hi @cedvdb, I tried the latest version, thanks a lot!

AutofillHints is not exposed directly so it is good for me.

There is still one thing I would like: when I fill with an international phone number, it should update the country code. I think internally we should try a parsing with PhoneNumber().parseRaw() first and check if the isoCode is the same or not.

cedvdb commented 3 years ago

when I fill with an international phone number, it should update the country code

Hum if you copy paste an international phone number or auto fill it should update the country code. Doesn't that work for you ?

AutofillHints is not exposed directly so it is good for me.

it is now AutofillHints.telephoneNumber. It is also exposed in BasePhoneFormField but that requires some manual setups

xvrh commented 3 years ago

it is now AutofillHints.telephoneNumber. It is also exposed in BasePhoneFormField but that requires some manual setups

Sorry the "not" in my sentence was a typo :-(

Hum if you copy paste an international phone number or auto fill it should update the country code. Doesn't that work for you ?

Yes I don't see this behaviour. When I create a PhoneFormField with default values. When I focus, it chooses "+1" (us) by default. Now I paste "+32477124578". The country code stays "+1" and it displays "invalid phone number"

cedvdb commented 3 years ago

Now I paste "+32477124578". The country code stays "+1" and it displays "invalid phone number"

What device are you on ? it works for me here https://cedvdb.github.io/phone_form_field/#/

xvrh commented 3 years ago

This is with an iPhone (real and simulator). I seems the prefix "+" is lost somewhere before it is pasted.

Indeed it work well in the web page.

cedvdb commented 3 years ago

Should be fixed in next release

https://github.com/cedvdb/phone_form_field/pull/32