Skip to content

Commit

Permalink
Add textfield begin editing handler (#1)
Browse files Browse the repository at this point in the history
* Add handler in cardNumberTextField

* Add handler in cvvTextField
  • Loading branch information
oatThanut authored and mylifeasdog committed May 24, 2024
1 parent 8447582 commit e52951e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import UIKit
open class CardCVVTextField: OmiseTextField {
private let validLengths = 3...4

open var shouldBeginEditingHandler: (() -> Bool)?

open override var delegate: UITextFieldDelegate? {
get {
return self
Expand Down Expand Up @@ -62,4 +64,9 @@ extension CardCVVTextField {

return maxLength >= (self.text?.count ?? 0) - range.length + string.count
}

open func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool
{

Check failure on line 69 in OmiseSDK/Sources/Views/Components/TextFields/CardCVVTextField.swift

View workflow job for this annotation

GitHub Actions / lint

Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration (opening_brace)
return shouldBeginEditingHandler?() ?? true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ open class CardNumberTextField: OmiseTextField {
return pan.brand
}

open var shouldBeginEditingHandler: (() -> Bool)?

open override var tokenizer: UITextInputTokenizer {
return cardNumberStringTokenizer
}
Expand Down Expand Up @@ -310,4 +312,9 @@ extension CardNumberTextField {

return maxLength >= (self.text?.count ?? 0) - range.length + string.count
}

open func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool
{

Check failure on line 317 in OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift

View workflow job for this annotation

GitHub Actions / lint

Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration (opening_brace)
return shouldBeginEditingHandler?() ?? true
}
}

0 comments on commit e52951e

Please sign in to comment.