Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 3 additional delegates set, more below #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Sources/FPNTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ open class FPNTextField: UITextField, FPNCountryPickerDelegate, FPNDelegate {
setupPhoneCodeTextField()
setupLeftView()
setupCountryPicker()



self.delegate = self // sets itself as the delegate for the UITextFieldDelegate in line 416

keyboardType = .phonePad
autocorrectionType = .no
addTarget(self, action: #selector(didEditText), for: .editingChanged)
addTarget(self, action: #selector(displayNumberKeyBoard), for: .touchDown)

addTarget(self, action: #selector(textFieldTapped), for: .editingChanged) // **let us know when this textField is tapped
}

private func setupFlagButton() {
Expand Down Expand Up @@ -181,6 +186,9 @@ open class FPNTextField: UITextField, FPNCountryPickerDelegate, FPNDelegate {
}

@objc private func displayCountryKeyboard() {

(delegate as? FPNTextFieldDelegate)?.detectWhenFlagTapped() // **let's us know when the flag is tapped

inputView = countryPicker
inputAccessoryView = getToolBar(with: getCountryListBarButtonItems())
tintColor = .clear
Expand All @@ -196,6 +204,8 @@ open class FPNTextField: UITextField, FPNCountryPickerDelegate, FPNDelegate {
inputView = nil
inputAccessoryView = nil
resignFirstResponder()

(delegate as? FPNTextFieldDelegate)?.detectWhenDoneButtonTapped() // **let's us know when the Done button is tapped
}

// - Public
Expand Down Expand Up @@ -437,3 +447,11 @@ open class FPNTextField: UITextField, FPNCountryPickerDelegate, FPNDelegate {
setFlag(for: country.code)
}
}

extension FPNTextField: UITextFieldDelegate {

@objc private func textFieldTapped() {

(delegate as? FPNTextFieldDelegate)?.detectWhenTextFieldTapped()
}
}