more refinement of errors.

This commit is contained in:
Kevin G Christiano 2019-11-22 14:33:46 -05:00
parent 72553935c2
commit dc8293b08b
4 changed files with 11 additions and 13 deletions

View File

@ -124,6 +124,7 @@ import UIKit
}
@objc public func textFieldDidDelete() {
digitBoxDelegate?.digitFieldDidDelete?(digitField)
}

View File

@ -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()])
}
}

View File

@ -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

View File

@ -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
}
}