Streamline country selection with ease. Customize themes, add countries, and optimize lists β all tailored to your app. A simple, powerful choice for an enhanced user experience. πβ¨
- Appearance available for both Light and Dark modes
- Customizable Font to match your App's style for Country, Country Code, and Search
- Enable or Disable Local Country on the Top option
- Customizable theme based on your App's primary, secondary, and text colors
- Add Custom Country if desired
- Alter Country List according to your preference (Top, Bottom, or After Local Country)
- Optimized Search based on Country Name (e.g., INDIA), Dial Code (e.g., 91), or Country Code (e.g., IN)
- Available for Cocoa Pods & Swift package manager
- Best practices followed
Give it a βοΈ if it simplifies your app development!
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/aksamitsah/CountryPickerAKS.git
- Select
Up to Next Major
for latest update
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!
target 'MyApp' do
pod 'CountryPickerAKS'
end
import CountryPickerAKS
CountryPicker.show(from: self) { result in
switch result {
case .success(let data):
debugPrint(data)
case .failure(let err):
debugPrint(err.localizedDescription)
}
}
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
config
updated 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)
}
}
- iOS 11.0+ with support for the latest release, iOS 17
- Latest Xcode 14.x with Swift
- Swift v5.0+