 import Foundation
 import libPhoneNumber_iOS
 
-public class CTKFlagPhoneNumberTextField: UITextField {
+public class CTKFlagPhoneNumberTextField: UITextField, UITextFieldDelegate, CountryPickerDelegate, CTKFlagPhoneNumberDelegate {
 		
 	public var flagSize = CGSize(width: 32, height: 32) {
 		didSet {

		text = phoneCode
		sendActions(for: .editingChanged)
	}
}

extension CTKFlagPhoneNumberTextField: CTKFlagPhoneNumberDelegate {
	func didSelect(country: Country) {
		if let code = country.code {
			countryPicker.setCountry(code)

	public func textFieldDidEndEditing(_ textField: UITextField) {
		set(phoneNumber: textField.text!)
	}
	
	// CountryPickerDelegate

	public func countryPhoneCodePicker(_ picker: CountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage) {
		self.phoneCode = phoneCode
		self.countryCode = countryCode
