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