{"id":20047901,"url":"https://github.com/chronotruck/flagphonenumber","last_synced_at":"2025-12-12T06:22:47.739Z","repository":{"id":21679828,"uuid":"93746595","full_name":"chronotruck/FlagPhoneNumber","owner":"chronotruck","description":"A formatted phone number UITextField with country flag picker. ","archived":false,"fork":false,"pushed_at":"2024-06-01T15:48:41.000Z","size":15886,"stargazers_count":441,"open_issues_count":95,"forks_count":328,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-13T02:01:59.866Z","etag":null,"topics":["country","flags","phonenumber","picker","textfield"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chronotruck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-08T12:24:05.000Z","updated_at":"2025-04-18T10:22:56.000Z","dependencies_parsed_at":"2023-07-13T10:33:34.807Z","dependency_job_id":"c14e757a-aa64-4f1f-b24c-9068a9408591","html_url":"https://github.com/chronotruck/FlagPhoneNumber","commit_stats":{"total_commits":143,"total_committers":10,"mean_commits":14.3,"dds":0.1748251748251748,"last_synced_commit":"6d7b4d4f904f8c23e566067071f08a9a5012e70a"},"previous_names":["chronotruck/ctkflagphonenumber"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronotruck%2FFlagPhoneNumber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronotruck%2FFlagPhoneNumber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronotruck%2FFlagPhoneNumber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronotruck%2FFlagPhoneNumber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chronotruck","download_url":"https://codeload.github.com/chronotruck/FlagPhoneNumber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478187,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["country","flags","phonenumber","picker","textfield"],"created_at":"2024-11-13T11:39:24.809Z","updated_at":"2025-12-12T06:22:47.710Z","avatar_url":"https://github.com/chronotruck.png","language":"C","readme":"# FlagPhoneNumber\n\nFlagPhoneNumber is a phone number textfield with a fancy country code picker.   \n\n[![CI Status](http://img.shields.io/travis/grifas/FlagPhoneNumber.svg?style=flat)](https://travis-ci.org/chronotruck/FlagPhoneNumber)\n[![Version](https://img.shields.io/cocoapods/v/FlagPhoneNumber.svg?style=flat)](http://cocoapods.org/pods/FlagPhoneNumber)\n[![License](https://img.shields.io/cocoapods/l/FlagPhoneNumber.svg?style=flat)](http://cocoapods.org/pods/FlagPhoneNumber)\n[![Platform](https://img.shields.io/cocoapods/p/FlagPhoneNumber.svg?style=flat)](http://cocoapods.org/pods/FlagPhoneNumber)\n[![Language](https://img.shields.io/badge/language-swift-brightgreen.svg?style=flat)](https://developer.apple.com/swift)\n\n## 🌅 Screenshot\n\u003cimg src=\"./Screenshot/screenshot_1.PNG\" width=\"288px\"\u003e \u003cimg src=\"./Screenshot/screenshot_2.PNG\" width=\"288px\"\u003e \u003cimg src=\"./Screenshot/screenshot_3.PNG\" width=\"288px\"\u003e\n\n\n## 🌍 Localization\n\nCountry names are displayed according to the phone language\n\n## 📲 Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## ⬇️ Installation\n\nFlagPhoneNumber is available through [Swift Package Manager](https://github.com/apple/swift-package-manager), [CocoaPods](http://cocoapods.org) and [Carthage](https://github.com/Carthage/Carthage). \n\n### Swift Package Manager\n\nSimply add in your `Package Dependencies` the following line: \n\n```ruby\nhttps://github.com/chronotruck/FlagPhoneNumber\n```\n\n### Carthage\n\nSimply add in your `Cartfile` the following line: \n\n```ruby\ngithub \"chronotruck/FlagPhoneNumber\"\n```\n\n### Cocoapods\n\nSimply add in your `Podfile` the following line:\n\n```ruby\npod \"FlagPhoneNumber\"\n```\n\n### Manually\n\nSimply import the Sources repository in your project.\n\n#### 👴🏻 Objective-C is supported \n\n\n## 🗺 Usage\n\nYou can instantiate it in storyboards/xibs or programmatically:\n\n```swift\nlet phoneNumberTextField = FPNTextField(frame: CGRect(x: 0, y: 0, width: view.bounds.width - 16, height: 50))\n\n// You can change the chosen flag then set the phone number\nphoneNumberTextField.setFlag(for: .FR)\nphoneNumberTextField.set(phoneNumber: \"0600000001\")\n\n// Or directly set the phone number with country code, which will update automatically the flag image\nphoneNumberTextField.set(phoneNumber: \"+33600000001\")\n```\n\n## 🚨 FPNTextFieldDelegate\n\nFPNTextFieldDelegate inherites from UITextFieldDelegate so nothing change:\n\n```swift\nphoneNumberTextField.delegate = self\n```\n\nIt provides you three methods:\n\n```swift\nextension YourViewController: FPNTextFieldDelegate {\n\n   /// The place to present/push the listController if you choosen displayMode = .list\n   func fpnDisplayCountryList() {\n      let navigationViewController = UINavigationController(rootViewController: listController)\n      \n      present(navigationViewController, animated: true, completion: nil)\n   }\n\n   /// Lets you know when a country is selected \n   func fpnDidSelectCountry(name: String, dialCode: String, code: String) {\n      print(name, dialCode, code) // Output \"France\", \"+33\", \"FR\"\n   }\n\n   /// Lets you know when the phone number is valid or not. Once a phone number is valid, you can get it in severals formats (E164, International, National, RFC3966)\n   func fpnDidValidatePhoneNumber(textField: FPNTextField, isValid: Bool) {\n      if isValid {\n         // Do something...         \n         textField.getFormattedPhoneNumber(format: .E164),           // Output \"+33600000001\"\n         textField.getFormattedPhoneNumber(format: .International),  // Output \"+33 6 00 00 00 01\"\n         textField.getFormattedPhoneNumber(format: .National),       // Output \"06 00 00 00 01\"\n         textField.getFormattedPhoneNumber(format: .RFC3966),        // Output \"tel:+33-6-00-00-00-01\"\n         textField.getRawPhoneNumber()                               // Output \"600000001\"\n      } else {\n         // Do something...\n      }\n   }\n}\n```\n\n## 🎨 Customization\n\nBy default, the picker view is showed but you can display the countries with a list view controller:\n\n```swift\nvar listController: FPNCountryListViewController = FPNCountryListViewController(style: .grouped)\n\nphoneNumberTextField.displayMode = .list // .picker by default\n\nlistController.setup(repository: textField.countryRepository)\nlistController.didSelect = { [weak self] country in\nself?.textField.setFlag(countryCode: country.code)\n```\n\nDon't forget to implement the `fpnDisplayCountryList`:\n\n```swift\nfunc fpnDisplayCountryList() {\n   let navigationViewController = UINavigationController(rootViewController: listController)\n\n   listController.title = \"Countries\"\n\n   self.present(navigationViewController, animated: true, completion: nil)\n}\n```\n\nFlagKit is used by default but you can customize the list with your own flag icons assets:\n```swift\n// Be sure to set it before initializing a FlagPhoneNumber instance.\nBundle.FlagIcons = YOUR_FLAG_ICONS_BUNDLE\n```\n\nYou can change the size of the flag button:\n```swift\nphoneNumberTextField.flagButtonSize = CGSize(width: 44, height: 44)\n```\n\nYou can customize the inputAccessoryView of the textfield:\n```swift\nphoneNumberTextField.textFieldInputAccessoryView = getCustomTextFieldInputAccessoryView(with: items)\n```\n\nYou can also customize the flag button's properties:\n```swift\n// This will freeze the flag.\n// Only one particular country's phone numbers will be formatted and validated.\n// You can set the country by setting the flag as shown earlier.\nphoneNumberTextField.flagButton.isUserInteractionEnabled = false\n```\n\nYou can have in the placeholder an example of a phone number according to the selected country or have your own placeholder:\n```swift\nphoneNumberTextField.hasPhoneNumberExample = false // true by default\nphoneNumberTextField.placeholder = \"Phone Number\"\n```\n\nYou can choose which country can appears in the list:\n```swift\nphoneNumberTextField.setCountries(including: [.FR, .ES, .IT, .BE, .LU, .DE])\n```\n\nOr exclude countries from the list:\n```swift\nphoneNumberTextField.setCountries(excluding: [.AM, .BW, .BA])\n```\n\nYou can choose to display the country phone code in the picker or in the list view controller:\n```swift\nphoneNumberTextField.pickerView.showCountryPhoneCode = false // true by default\nlistController.showCountryPhoneCode = false // true by default\n```\n\nYou can reuses `FPN` classes as you see fit !\n\n## ☕️ Conception\nThis library uses libPhoneNumber-iOS library (https://github.com/iziz/libPhoneNumber-iOS)\n\nOpen source time proudly sponsored by Chronotruck.\n\n## 💁🏻‍♂️ Author\ngrifas, aurelien.grifasi@chronotruck.com\n\nDon't hesitate to contact me or make a pull request to upgrade this library.\n\n## 📝 License\nFlagPhoneNumber is available under the Apache license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronotruck%2Fflagphonenumber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchronotruck%2Fflagphonenumber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronotruck%2Fflagphonenumber/lists"}