more refinement of errors.
This commit is contained in:
parent
72553935c2
commit
dc8293b08b
@ -124,6 +124,7 @@ import UIKit
|
||||
}
|
||||
|
||||
@objc public func textFieldDidDelete() {
|
||||
|
||||
digitBoxDelegate?.digitFieldDidDelete?(digitField)
|
||||
}
|
||||
|
||||
|
||||
@ -65,8 +65,7 @@ import UIKit
|
||||
for (index, field) in digitBoxes.enumerated() {
|
||||
if index < newValue.count {
|
||||
let indexChar = newValue.index(newValue.startIndex, offsetBy: index)
|
||||
field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [
|
||||
NSAttributedString.Key.foregroundColor: UIColor.mfBattleshipGrey()])
|
||||
field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [NSAttributedString.Key.foregroundColor: UIColor.mfBattleshipGrey()])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ import UIKit
|
||||
public var errorMessage: String?
|
||||
|
||||
/// Determines whther the feedback label will clear itself after user interaction or display update.
|
||||
// public var fixedFeedback: Bool = false
|
||||
public var affixFeedback: Bool = false
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Computed Properties
|
||||
|
||||
@ -90,7 +90,9 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
|
||||
public var validationBlock: ((_ value: String?) -> Bool)? {
|
||||
didSet { valueChanged() }
|
||||
didSet { //valueChanged()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override var errorMessage: String? {
|
||||
@ -214,21 +216,19 @@ import UIKit
|
||||
/// Executes on UITextField.textDidChangeNotification
|
||||
@objc func valueChanged() {
|
||||
|
||||
if !showError {
|
||||
if !showError && !affixFeedback {
|
||||
feedback = ""
|
||||
}
|
||||
|
||||
let previousValidity = isValid
|
||||
|
||||
|
||||
// If validation not set, input will always be valid
|
||||
isValid = validationBlock?(text) ?? true
|
||||
|
||||
if previousValidity && !isValid {
|
||||
if !isValid {
|
||||
showError = true
|
||||
observingTextFieldDelegate?.isInvalid?(textfield: self)
|
||||
|
||||
} else if !previousValidity && isValid {
|
||||
showError = false
|
||||
} else if isValid {
|
||||
isSelected = true
|
||||
observingTextFieldDelegate?.isValid?(textfield: self)
|
||||
}
|
||||
}
|
||||
@ -240,8 +240,6 @@ import UIKit
|
||||
showError = false
|
||||
entryFieldContainer.bottomBar?.backgroundColor = UIColor.black.cgColor
|
||||
|
||||
} else if let errMessage = errorMessage {
|
||||
feedback = errMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user