Skip to content

Commit

Permalink
Update PhoneNumberTextField.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfrancmartin authored May 22, 2024
1 parent 24c2f39 commit 6695bee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PhoneNumberKit/UI/PhoneNumberTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ open class PhoneNumberTextField: UITextField, UITextFieldDelegate {
}
}

public var withPrefixPrefill: Bool = true

public var withFlag: Bool = false {
didSet {
leftView = self.withFlag ? self.flagButton : nil
Expand Down Expand Up @@ -497,7 +499,7 @@ open class PhoneNumberTextField: UITextField, UITextFieldDelegate {
}

open func textFieldDidBeginEditing(_ textField: UITextField) {
if self.withExamplePlaceholder, self.withPrefix, let countryCode = phoneNumberKit.countryCode(for: currentRegion)?.description, (text ?? "").isEmpty {
if self.withExamplePlaceholder, self.withPrefix, self.withPrefixPrefill, let countryCode = phoneNumberKit.countryCode(for: currentRegion)?.description, (text ?? "").isEmpty {
text = "+" + countryCode + " "
}
self._delegate?.textFieldDidBeginEditing?(textField)
Expand Down

0 comments on commit 6695bee

Please sign in to comment.