{"id":19312064,"url":"https://github.com/weblineindia/swiftui-country-code-picker","last_synced_at":"2025-04-12T11:23:08.028Z","repository":{"id":181825103,"uuid":"667395425","full_name":"weblineindia/SwiftUI-Country-Code-Picker","owner":"weblineindia","description":"This Country Code Picker is a fully reusable demo or library that provides users with a convenient way to select and display country codes from a comprehensive list. It simplifies the process of selecting the correct country code and flag.","archived":false,"fork":false,"pushed_at":"2023-07-17T13:13:42.000Z","size":1292,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T21:04:03.172Z","etag":null,"topics":["country-code-picker","country-codes-component","ios","reusable-code","reusable-components","reusable-library","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://www.weblineindia.com/software-development-resources.html","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weblineindia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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}},"created_at":"2023-07-17T12:07:11.000Z","updated_at":"2025-02-15T20:13:42.000Z","dependencies_parsed_at":"2023-07-17T15:21:01.668Z","dependency_job_id":null,"html_url":"https://github.com/weblineindia/SwiftUI-Country-Code-Picker","commit_stats":null,"previous_names":["weblineindia/swiftui-country-code-picker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weblineindia%2FSwiftUI-Country-Code-Picker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weblineindia%2FSwiftUI-Country-Code-Picker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weblineindia%2FSwiftUI-Country-Code-Picker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weblineindia%2FSwiftUI-Country-Code-Picker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weblineindia","download_url":"https://codeload.github.com/weblineindia/SwiftUI-Country-Code-Picker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248558522,"owners_count":21124302,"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-code-picker","country-codes-component","ios","reusable-code","reusable-components","reusable-library","swift","swiftui"],"created_at":"2024-11-10T00:32:34.823Z","updated_at":"2025-04-12T11:23:08.009Z","avatar_url":"https://github.com/weblineindia.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftUI Country Code Picker\n\nThis Country Code Picker is a fully reusable demo that provides users with a convenient way to select and display country codes from a comprehensive list. It simplifies the process of selecting the correct country code and thier flag as well.\n\n## Table of Contents \n\n- [Demo](#demo)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [Need Help / Support?](#need-help)\n- [Collection of Components](#collection-of-Components)\n- [License](#license)\n- [Acknowledgements](#acknowledgements)\n- [Keywords](#keywords)\n\n# Demo 📱\n\nThis demo contains a screen which have country code selection and input field to enter mobile number.\n\n\u003cimg src=\"./demo.gif\" alt=\"Demo Normal Preview\"\u003e\n\n\n# Features 🥳\n\nApp has main feature as:\n\n* Country code picker feature.\n* Demo has signle screen with country code selection and one input field of mobile number.\n* Multiselection flag available to select multiple country code.\n* Fully customization available.\n* Not any third party dependency.\n* Minimum iOS Target 16.0\n\n# Installation 💾\n\nThe instructions on how to install or run this demo:\n\n* Clone the repository.\n* Open the project in Xcode.\n* Build and run the project.\n\n# Usage \u0026 Integration 👩🏾‍🔬\n\nHow to add the country code picker feature into your own SwiftUI project. follow below steps\n\n** Create your new SwiftUI project with main app content view.\n** Drag and drop folder name as `CountryPickerSource` source of files into your project. That contains all necessary files which needed for picker.\n\n** `CountryPickerRepresentable` - This File is using for swiftUI to present the view controller.\n** `CountryModel` - This file is using for JSON parsing of country list. \n** `CountryCodes` - This is JSON file of country list.\n** `Countries` - Array of country model object.\n** `CountriesViewController` - This file using to present the screen and render country data.\n** `Country` - Using to extract particular data as country name, code and flag by defining methods. \n** `CountriesViewControllerDelegate` - This contains the delegate methods of CountriesViewController\n** `SwiftyJSON`  This is one type of helper which is using for parsing of json data.\n\n### Put the code into your initial content view:\nHere integreated country picker on taping of a button and display data as flag and code after selection. And additionaly added one input field for mobile number.\n\n```swift\nstruct ContentView: View {\n@State private var selectedCountry: CountryModel?\n@State private var isPickerVisible = false\n@State private var mobile = \"\"\n\nvar body: some View {\n\nVStack(alignment: .center, spacing: 50) {\nImage(\"logo\").frame(width: 200,height: 100,alignment: .center)\nText(\"Country Code Picker\")\n.font(.title)\n.foregroundColor(.primary)\nHStack {\nButton(action: {\nisPickerVisible.toggle()\n}) {\nHStack {\nText(selectedCountry?.countryFlag ?? \"\")\n.frame( height: 20)\n\nText(selectedCountry?.countryCode ?? \"CountryCode\")\n.foregroundColor(.gray)\n}.padding(5)\n}\nDivider().background(Color.gray)\n.frame(width: 1).padding(5)\nTextField(\"Phone Number\", text: $mobile)\n}.frame(height: 50)\n.background(Color.secondary.opacity(0.1))\n.cornerRadius(8)\n.padding(10)\nSpacer()\n\n}.sheet(isPresented: $isPickerVisible) {\nCountryPicker(country: $selectedCountry)\n}\n}\n}\n\n```\n** `CountryPickerRepresentable` This file can modify as per requirement and customise the feature, by default its single selection of picker but its support multiple selection.\n\n```swift\n\nstruct CountryPicker: UIViewControllerRepresentable {\nlet countryPicker = CountriesViewController()\n@Binding var country: CountryModel?\n\nfunc makeUIViewController(context: Context) -\u003e CountriesViewController {\ncountryPicker.allowMultipleSelection = false\ncountryPicker.delegate = context.coordinator\nreturn countryPicker\n}\n\nfunc updateUIViewController(_ uiViewController: CountriesViewController, context: Context) {\n}\n\nfunc makeCoordinator() -\u003e Coordinator {\nreturn Coordinator(self)\n}\n\nclass Coordinator: NSObject, CountriesViewControllerDelegate {\nfunc countriesViewControllerDidCancel(_ countriesViewController: CountriesViewController) {\n}\n\nfunc countriesViewController(_ countriesViewController: CountriesViewController, didSelectCountry country: Country) {\nlet cModel = CountryModel()\nif let info = getCountryAndName(country.countryCode) {\ncModel.countryCode  = info.countryCode!\ncModel.countryFlag  = info.countryFlag!\n}\nparent.country = cModel\n}\n\nfunc countriesViewController(_ countriesViewController: CountriesViewController, didUnselectCountry country: Country) {\n}\n\nfunc countriesViewController(_ countriesViewController: CountriesViewController, didSelectCountries countries: [Country]) {\n}\n\nvar parent: CountryPicker\ninit(_ parent: CountryPicker) {\nself.parent = parent\n}\n}\n}\n\n```\n\n## UIKit - Swift Integration\n\nAnd also we can use same Source library for UIKit in swift project as well. Write below code to open country picker.\n\n```swift\nDispatchQueue.main.async {\nCountriesViewController.show(countriesViewController: self.countriesViewController, toVar: self)\n} \n\n```\n\n# Contributing\n\n- Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).\n- [Fork it](http://help.github.com/forking/).\n- Create new branch to contribute your changes.\n- Commit all your changes to your branch.\n- Submit a [pull request](http://help.github.com/pull-requests/).\n\n\n# Need Help? \n\nWe also provide a free, basic support for all users who want to use this coordinator master demo in project. In case you want to customize this demo input to suit your development needs, then feel free to contact our [iOS SwiftUI Developers](https://www.weblineindia.com/hire-ios-app-developers.html).\n\n# Collection of Components\n\nWe have built many other components and free resources for software development in various programming languages. Kindly click here to view our [Free Resources for Software Development.](https://www.weblineindia.com/software-development-resources.html)\n\n# Changelog\n\nDetailed changes for each release are documented in [CHANGELOG](./CHANGELOG).\n\n# License 📃\n\nThis project is licensed under the MIT License. Feel free to use, modify, and distribute the code as permitted by the license.\n\n# Acknowledgements\n\nThis app was created using SwiftUI and leverages various libraries and resources. We would like to acknowledge and express our gratitude to the following:\n* SwiftUI: Apple's declarative framework for building user interfaces.\n* Xcode: Integrated development environment (IDE) provided by Apple.\n* Open-source libraries: Various open-source libraries and frameworks used in the project.\n* Community contributors: Contributors who have provided support, bug fixes, and enhancements.\n\n# Keywords\n\nCountry Picker Master, SwiftUI Country Code Picker, Country Picker Reusable Component, Country Code, Swift5, iOS 16, WeblineIndia\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweblineindia%2Fswiftui-country-code-picker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweblineindia%2Fswiftui-country-code-picker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweblineindia%2Fswiftui-country-code-picker/lists"}