Callback get country code
The flag feature is nice, but what's the point if we don't know the country code ? Please add a Callback so when user chooses a flag and adds the a phone number, we get the country code for formatting the number later,users don't want to provide the country code
The code detection is not the responsibility of the UI component, and it's not how SwiftUI works. So you need to get the code from the logic core module instead:
import PhoneNumberKit
print(PhoneNumberKit().countryCode(for: "IR"))
Also, I've put a workaround that you can directly call the core functions within the SwiftUI View. So you can get the country code of the number if the number is completely provided:
iPhoneNumberField(
"Title",
text: $text,
isEditing: $isEditing,
formatted: true
) {
print($0.phoneNumber?.countryCode)
}
Deploy Preview for kubeapps-dev ready!
| Name | Link |
|---|---|
| Latest commit | c848f595e270295f874dbad006a304e36bc34e5c |
| Latest deploy log | https://app.netlify.com/sites/kubeapps-dev/deploys/63775589d3e4d50009462191 |
| Deploy Preview | https://deploy-preview-5576--kubeapps-dev.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
I think the users request is valid here: The goal of formatting and validation is so that you can know that the number is valid, but the string returned in the binding is a formatted one, there should probably be a second binding which contains the full number with country code so that we can actually get that value and use it elsewhere in code. Otherwise, this just makes it look pretty.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.