All Projects → SURYAKANTSHARMA → Countrypicker

SURYAKANTSHARMA / Countrypicker

Licence: mit
A simple, customizable Country picker for picking country or dialing code. 🇮🇳 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Countrypicker

Badgehub
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
Stars: ✭ 592 (+240.23%)
Mutual labels:  hacktoberfest, xcode, cocoapods
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+578.16%)
Mutual labels:  hacktoberfest, xcode, cocoapods
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+785.06%)
Mutual labels:  hacktoberfest, xcode, cocoapods
Cloudkitgdpr
Framework for allowing users to manage data stored in iCloud
Stars: ✭ 126 (-27.59%)
Mutual labels:  xcode, cocoapods
Croc
Swift emoji string parsing library
Stars: ✭ 124 (-28.74%)
Mutual labels:  xcode, cocoapods
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-28.16%)
Mutual labels:  xcode, cocoapods
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-36.21%)
Mutual labels:  xcode, cocoapods
Djsemimodalviewcontroller
Simple semi modal presentation dialog with stacked content
Stars: ✭ 137 (-21.26%)
Mutual labels:  presentation, cocoapods
Testdrive
Quickly try out any Swift pod or framework in a playground
Stars: ✭ 1,612 (+826.44%)
Mutual labels:  xcode, cocoapods
Donut
Donut is a library for arranging views circularly like a donut.
Stars: ✭ 141 (-18.97%)
Mutual labels:  xcode, cocoapods
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (-12.64%)
Mutual labels:  xcode, cocoapods
Tuist
🚀 Create, maintain, and interact with Xcode projects at scale
Stars: ✭ 2,234 (+1183.91%)
Mutual labels:  hacktoberfest, xcode
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-31.61%)
Mutual labels:  xcode, cocoapods
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-1.15%)
Mutual labels:  xcode, cocoapods
Microfeatures Example
📦📱 Example of iOS app built using the uFeatures architecture
Stars: ✭ 112 (-35.63%)
Mutual labels:  xcode, cocoapods
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-24.71%)
Mutual labels:  xcode, cocoapods
Nearbyweather
NearbyWeather is an open source weather app for iOS, which uses the OpenWeatherMap API. With this project developers are invited to learn advanced iOS concepts, as well as to contribute further advancements. Fork this repo to get started.
Stars: ✭ 146 (-16.09%)
Mutual labels:  xcode, cocoapods
Accordionswift
The best way of implement an accordion menu using an UITableView in Swift
Stars: ✭ 156 (-10.34%)
Mutual labels:  xcode, cocoapods
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-9.2%)
Mutual labels:  xcode, cocoapods
Materialactivityindicator
Material Activity Indicator
Stars: ✭ 109 (-37.36%)
Mutual labels:  xcode, cocoapods

CountryPicker

CountryPicker

Awesome Travis CI codecov Version Carthage compatible Swift Package Manager compatible License

A simple, customizable Country picker for picking country or dialing code.

This library is for country picker used in many app for selecting country code of user. User can select country by searching and then selecting country in list.

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 in iOS 13
  • [x] Support Dynamic font size for ContentSizeCategory
  • [x] Unit tests coverage 94%
  • [x] Picker view support added with customization

Requirements

  • iOS 10.0+ Support latest release iOS 13
  • Xcode 10.2+ Support latest Xcode 11 with Swift

Demo Project

To run the example project, clone the repo, and run pod update from the Example directory first.

Screenshots

Home Scene Country Picker Scene Filtering Scene Dark Mode Scene Picker View

Installation

CountryPicker is available through Cocoapods and Carthage.

CocoaPods:

Add the following line to your Podfile:

pod 'SKCountryPicker'

Current version compatible with Swift 5. If you want support Swift 4.1/3.3

pod 'SKCountryPicker' '~> 1.2.0'

Carthage

The steps required to use Carthage for dependency management are described here 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 use

once 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

Add the following line to your Package.swift file in the dependencies section:

.package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git, from "1.2.7")

Getting Started

Example: Please check example project for customization and different option available.

private extension ViewController {
    
    /// Dynamically presents country picker scene with an option of including `Selection Control`.
    ///
    /// By default, invoking this function without defining `selectionControlEnabled` parameter. Its set to `True`
    /// unless otherwise and the `Selection Control` will be included into the list view.
    ///
    /// - Parameter selectionControlEnabled: Section Control State. By default its set to `True` unless otherwise.
    
    func presentCountryPickerScene(withSelectionControlEnabled selectionControlEnabled: Bool = true) {
        switch selectionControlEnabled {
        case true:
            // Present country picker with `Section Control` enabled
            let countryController = CountryPickerWithSectionViewController.presentController(on: self) { [weak self] (country: Country) in
                
                guard let self = self else { return }
                
                self.countryImageView.isHidden = false
                self.countryImageView.image = country.flag
                self.countryCodeButton.setTitle(country.dialingCode, for: .normal)
            }
            
            countryController.flagStyle = .circular
            countryController.isCountryFlagHidden = !showCountryFlagSwitch.isOn
            countryController.isCountryDialHidden = !showDialingCodeSwitch.isOn
            countryController.favoriteCountriesLocaleIdentifiers = ["IN", "US"]
        case false:
            // Present country picker without `Section Control` enabled
            let countryController = CountryPickerController.presentController(on: self) { [weak self] (country: Country) in
                
                guard let self = self else { return }
                
                self.countryImageView.isHidden = false
                self.countryImageView.image = country.flag
                self.countryCodeButton.setTitle(country.dialingCode, for: .normal)
            }
            
            countryController.flagStyle = .corner
            countryController.isCountryFlagHidden = !showCountryFlagSwitch.isOn
            countryController.isCountryDialHidden = !showDialingCodeSwitch.isOn
            countryController.favoriteCountriesLocaleIdentifiers = ["IN", "US"]
        }
    }
}

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:

 // 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

// 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")

Styling Options

There are few styling options provided by the library such auto-hiding or styling views.

let countryController = CountryPickerWithSectionViewController.presentController(on: self) { ... }

// Styling country flag image view
countryController.flagStyle = .corner    // E.g .corner, ,circular or .normal

// Hide flag image view
countryController.isCountryFlagHidden = true // False

// Hide country dial code
countryController.isCountryDialHidden = true  // False

Contributing

Any contribution making project better is welcome.

Authors

*Suryakant Sharma

See also the list of 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 file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].