aksamitsah/CountryPickerAKS
Streamline country selection with ease. Customize themes, add countries, optimize lists β all tailored to your app. A simple, powerful choice for an enhanced user experience. πβ¨
π³ Features
- [x] Appearance available for both Light and Dark modes
- [x] CountryManager for more control
- [x] Customizable Font to match your App's style for Country, Country Code, and Search
- [x] Enable or Disable Local Country on the Top option
- [x] Customizable theme based on your App's primary, secondary, and text colors
- [x] Add Custom Country if desired
- [x] Alter Country List according to your preference (Top, Bottom, or After Local Country)
- [x] Optimized Search based on Country Name (e.g., INDIA), Dial Code (e.g., 91), or Country Code (e.g., IN)
- [x] Available for Cocoa Pods & Swift package manager
- [x] Best practices followed
Give it a βοΈ if it simplifies your app development!
π± Screenshots
<div align='center'> <img src="https://github.com/aksamitsah/CountryPickerAKS/assets/42860041/290d8165-447c-478e-930b-6fd2d139e9b0.png" width="300"> <img src="https://github.com/aksamitsah/CountryPickerAKS/assets/42860041/848783df-17ad-415a-8f68-775ae5940bd2.png" width="300">
<h4>LIGHT & DARK MODE</h4> </div>
π€ Installation
Swift Package Manager
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/aksamitsah/CountryPickerAKS.git - Select
Up to Next Majorfor latest update
CocoaPods
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!
target 'MyApp' do
pod 'CountryPickerAKS'
endβ³οΈ CountryPickerAKS - Docs
Default
import CountryPickerAKS
CountryPicker.show(from: self) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}πΊοΈ CountryManager
<a href="https://github.com/aksamitsah/CountryPickerAKS/blob/main/CountryManager.md"> The CountryManager class provides a convenient way to manage and retrieve country data based on different parameters such as country code, country name, dial code, and country emoji. It is a singleton class, ensuring that there is only one instance of the country data throughout the app. </a>
A More Advanced Example
With the powerful options, you can accomplish complex tasks with CountryPickerAKS in a simple way. For example, the code below:
- All the parameters have default values. If you want to override them, just pass the params
configupdated based on your needs.
- Alter Display Elements
- Case: If at least one parameter is required to display, give an error.
CountryPicker.show(from: self, config: Config(
display: ShowContent(Flag: true, CountryName: true)
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}- Update Theme
- Recommendation: If you use dark mode, then pass both appearances.
CountryPicker.show(from: self, config: Config(
color: ThemeColor(
primary: .systemGray6,
secondary: .systemBackground,
textColor: .systemBlue)
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}- Update Font
CountryPicker.show(from: self, config: Config(
font: ThemeFont(
searchBar: UIFont(name: "Lemonada-Medium", size: 16) ?? UIFont(),
countryName: UIFont(name: "Lemonada-Regular", size: 16) ?? UIFont(),
countryCode: UIFont(name: "Lemonada-Light", size: 16) ?? UIFont(),
countryFlag: UIFont(name: "Lemonada-Bold", size: 22) ?? UIFont())
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}- Show/Hide Local Country
CountryPicker.show(from: self, config: Config(
data: CustomizeCountryList(showLocalOnTop: false)
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}- Add New Country / Alter Position / Display & Remove Only
CountryPicker.show(from: self, config: Config(
data: CustomizeCountryList(
addNew: [
CountryList(name: "New Country", dial_code: "+12", emoji: "π«‘", code: "NCA"),
CountryList(name: "New Country B", dial_code: "+13", emoji: "π΅βπ«", code: "NCB")
],
alterExisting: [
.onTop(["NCA", "NCB"]),
.onTopAfterLocal(["NP"]),
.onBottom(["US"])
]
)
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}- Use Display Only
.displayOnly([code])Country: Used to display only a list of countries. - Use Remove Only
.removeOnly([code])Country: Used to remove a particular country.
CountryPicker.show(from: self, config: Config(
data: CustomizeCountryList(
addNew: [
CountryList(name: "New Country", dial_code: "+12", emoji: "π«‘", code: "NCA"),
CountryList(name: "New Country B", dial_code: "+13", emoji: "π΅βπ«", code: "NCB")
],
alterExisting: [
.onTop(["NCA", "NCB"]),
.onTopAfterLocal(["NP"]),
.onBottom(["US"]),
.displayOnly(["NCA","NCB"]),
.removeOnly(["NCB"])
]
)
)) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}π³ Requirements
- iOS 11.0+ with support for the latest release, iOS 17
- Latest Xcode 14.x with Swift
- Swift v5.0+
πͺͺ License
π Links
<div align='center'> <a href="https://www.amit-sah.com.np/"><img src="https://img.shields.io/badge/my_portfolio-000?style=for-the-badge&logo=ko-fi&logoColor=white"/></a> <a href="https://www.linkedin.com/in/aksamitsah/"><img src="https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white"/></a> <a href="#"><img src="https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white"/></a>
</div>
Package Metadata
Repository: aksamitsah/CountryPickerAKS
Stars: 5
Forks: 3
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: cocopods, framework, spm, swift, swift-package-manager
README: README.md