Skip to content

Choose the country (flag, Mobile Code, Mobile Number Example,Currency), Support multiple controls ActionSheet , UIAlertViewController , SearchBarController

License

Notifications You must be signed in to change notification settings

mohshaat1990/CountrySelectorLib

Repository files navigation

CountrySelectorLib

  • Choose the country (flag, Mobile Code, Mobile Number Example)
  • Choose Currency
  • Support localization
  • Support multiple controls ActionSheet , UIAlertViewController , SearchBarController

Installation

using pods

pod 'CountrySelectorLib','~> 0.1.15'

Usage

Action Sheet

actionsheetGif

import CountrySelectorLib

let counterySelectorSearchBar  = CounterySelectorSearchBar( )     
counterySelectorSearchBar.showAlertViewController(parent:self,actionSheetStyle: .actionSheet)

// there are another optional parameters

counterySelectorSearchBar.showAlertViewController(parent: self, actionSheetStyle: .actionSheet, hideSarchBar: true, cancelTitle: "Cancel", searchTitle: "Search For Country")

Alert View

alertViewControllerGif

import CountrySelectorLib

let counterySelectorSearchBar  = CounterySelectorSearchBar( )     
counterySelectorSearchBar.showAlertViewController(parent:self,actionSheetStyle: .alert)

// there are another optional parameters

counterySelectorSearchBar.showAlertViewController(parent: self, actionSheetStyle: .alert, hideSarchBar: true, cancelTitle: "Cancel", searchTitle: "Search For Country")

SearchBarController

searchViewController

import CountrySelectorLib
showCounteryCodeViewController(delegate: self)

// there are another optional parameters

showCounteryCodeViewController(delegate: self, cancelTitle: "Cancel", searchPlaceHolder: "Search", viewControllerTilte: "Search For Country")

to show Currency

currency gif

let countryData: CountryDataType = .Currency
let counterySelectorSearchBar  = CounterySelectorSearchBar()
counterySelectorSearchBar.showAlertViewController(parent:self,countryDataType: countryData,actionSheetStyle: .alert)

to get specific country

let counterySelectorSearchBar  = CounterySelectorSearchBar()
counterySelectorSearchBar.delegate = self
counterySelectorSearchBar.getCountry(withRegionCode:"eg")

you should implement Delegate

extension ViewController: CounterySelectorDelegate {
func selectCountery(countery: Country) {
self.counteryImage.image = countery.counterFlag
self.countryNameLabel.text = countery.name
self.counteryCodeLabel.text = countery.phoneCode
self.mobileNumberExample.text = countery.phoneNumberExample
self.dismiss(animated: true, completion: nil)
}

func selectCountery(regionCode: String, country: Country?) {
if let country = country {
self.counteryImage.image = country.counterFlag
self.countryNameLabel.text = country.name
self.counteryCodeLabel.text = country.phoneCode
self.mobileNumberExample.text = country.phoneNumberExample
}
}
}

About

Choose the country (flag, Mobile Code, Mobile Number Example,Currency), Support multiple controls ActionSheet , UIAlertViewController , SearchBarController

Resources

License

Stars

Watchers

Forks

Packages

No packages published