Contents

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 Major for 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 config updated based on your needs.
  1. 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)
   }
}
  1. 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)
   }
}
  1. 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)
   }
}
  1. 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)
   }
}
  1. 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

MIT Β© 2023

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