Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SURYAKANTSHARMA/CountryPicker
A simple, customizable Country picker for picking country or dialing code. 🇮🇳 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
https://github.com/SURYAKANTSHARMA/CountryPicker
carthage cocoapods country-flags country-picker country-selection countrycodes countrylist countrypicker darkmode-ios13 dialing filter-countries filter-options hacktoberfest ios ios16 ipados spm swift swift5 xcode
Last synced: about 1 month ago
JSON representation
A simple, customizable Country picker for picking country or dialing code. 🇮🇳 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
- Host: GitHub
- URL: https://github.com/SURYAKANTSHARMA/CountryPicker
- Owner: SURYAKANTSHARMA
- License: mit
- Created: 2017-10-28T12:31:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T06:43:40.000Z (2 months ago)
- Last Synced: 2024-11-30T18:17:14.633Z (about 1 month ago)
- Topics: carthage, cocoapods, country-flags, country-picker, country-selection, countrycodes, countrylist, countrypicker, darkmode-ios13, dialing, filter-countries, filter-options, hacktoberfest, ios, ios16, ipados, spm, swift, swift5, xcode
- Language: Swift
- Homepage:
- Size: 122 MB
- Stars: 298
- Watchers: 8
- Forks: 86
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ios - SKCountryPicker - A simple, customizable Country picker for picking country or dialing code. (UI / PickerView)
- awesome-ios-star - SKCountryPicker - A simple, customizable Country picker for picking country or dialing code. (UI / PickerView)
README
![CountryPicker](https://user-images.githubusercontent.com/6416095/50628070-6fe1fd00-0f5c-11e9-9e9b-7e6dac866d43.png)
# CountryPicker
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/vsouza/awesome-ios)
[![Build Status](https://img.shields.io/badge/Build-BUILD_STATUS_PLACEHOLDER-red)](https://github.com/SURYAKANTSHARMA/CountryPicker/actions)[![codecov](https://codecov.io/gh/SURYAKANTSHARMA/CountryPicker/branch/master/graph/badge.svg)](https://codecov.io/gh/SURYAKANTSHARMA/CountryPicker)
![Version Badge](https://img.shields.io/github/v/release/SURYAKANTSHARMA/CountryPicker?style=flat)[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
[![License](https://img.shields.io/badge/License-MIT-8D6E63.svg)](LICENSE)CountryPicker is a Swift library that provides a simple and easy-to-use interface for selecting countries from a predefined list. It's perfect for adding country selection functionality to your iOS app with minimal effort.
## If you like CountryPicker, give it a ★ at the top right of this page.
## Features
- [x] Navigate through search and index title of section e.g (in Contact app in iOS)
- [x] Auto scroll to previous selected country
- [x] Filtering country options
- [x] Styling view options
- [x] Image size are optimized
- [x] Cocoa Pods integrated
- [x] Carthage integrated
- [x] Swift package manager integrated
- [x] Best practices followed
- [x] Dark mode supported
- [x] Support Dynamic font size for ContentSizeCategory
- [x] Unit tests coverage 94%
- [x] Picker view support added with customization
- [x] Swift UI Support with example project
- [x] Rewritten with swiftUI and combine in version 3.0.0
## Requirements- iOS 15.0+ Support latest release iOS 17 for older user older than 3.0.0
- latest Xcode 15.x with Swift## Demo Project
To run the example project, clone the repo, and run pod update from the Example directory first.#### Swift UI Combine new project
|##
## Screenshots
| Home Scene | Country Picker Scene | Filtering Scene | Dark Mode Scene | Picker View |
|:-----------------:|:---------------------:|:--------------:|:--------------:|:--------------:|
||| | | |## Installation
CountryPicker is available through Cocoapods and Carthage.
#### [CocoaPods](http://cocoapods.org):
Add the following line to your Podfile:```ruby
For iOS 15 and above (Combine and Swiftui version) currently only supported by cocoapods
pod 'SKCountryPicker'```
Please note iOS 15 will be discontinued after in 2024.
#### [Carthage](https://github.com/Carthage/Carthage)
The steps required to use Carthage for dependency management are described [here](https://github.com/Carthage/Carthage#getting-started) but lets add them to this README as well for good measure.First you need to add the following line to your Cartfile
```
github "SURYAKANTSHARMA/CountryPicker"
```to include the latest version of CountryPicker.
(if you don't have a Cartfile, you need to create one first in your favorite texteditor)
Next run
```
carthage update --platform iOS
```This will have Carthage:
- Fetch the source code for CountryPicker from Github
- Compile the source code into a framework for you to useonce Carthage finishes building, you need to add the framework to your project.
In Xcode:
- Navigate to the "General" tab of your project and tap the plus sign under "Frameworks, Libraries and Embedded Content"
- Select "Add other" and locate the Carthage folder (typically in the root of your project)
- The SKCountryPicker.framework is located under `Carthage/Build/iOS/`
- Select it and verify that it is added as a framework.The final step is to add the `copy-frameworks` build script to your "Build Phases".
- Navigate to "Build Phases" and tap the + at the top.
- Select "New Run Script Phase"
- Paste this line as the script to run `/usr/local/bin/carthage copy-frameworks`
- Add the SKCountryPicker.framework under Input Files like so: `$(SRCROOT)/Carthage/Build/iOS/SKCountryPicker.framework`Done!
#### [SPM](https://swift.org/package-manager/)
Add the following line to your Package.swift file in the dependencies section:
```
.package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git, from "4.0.0")
```## Getting Started
Please check [baseiOS11Example](https://github.com/SURYAKANTSHARMA/CountryPicker/tree/master/Examples) project for customization and different option available for using with old uikit.Please check [baseiOS15Example](https://github.com/SURYAKANTSHARMA/CountryPicker/tree/master/CountryPickeriOS15%2B/CountryPicker13%2BExample) project for using it in swift ui app with minimum deployment target iOS 15
## Filter Options
There are 3 main filter options `countryName`, `countryCode`, `countryDialCode` and by default country picker has been configured to filter countries based on `countryName`.If you want to add/remove filter options, do as follows:
```swift// Adding filter
CountryManager.shared.addFilter(.countryCode)// Removing filter
CountryManager.shared.removeFilter(.countryCode)// Removing all filters
CountryManager.shared.clearAllFilters()
```Incase you want to retrieve `country` info
```swift// Get country based on digit code e.g: 60, +255
CountryManager.shared.country(withDigitCode: "255")// Get country based on country name
CountryManager.shared.country(withName: "Tanzania")// Get country based on country code e.g: MY, TZ
CountryManager.shared.country(withCode: "MY")```
## Dependency Graph![Dependecy graph](https://user-images.githubusercontent.com/6416095/181878996-43ef2361-5d81-4bef-9f84-f4c54a640ed6.png)
#### For swift ui- [x] use 3.0.0 and above version
## Contributing
Any contribution making project better is welcome.
## Authors
[***Suryakant Sharma**](https://github.com/SURYAKANTSHARMA)
See also the list of [contributors](https://github.com/SURYAKANTSHARMA/CountyPicker/contributors) who participated in this project. Thanks from bottom of my heart to inspiration behind Hardeep Singh
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details