funcational,

This commit is contained in:
Kevin G Christiano 2019-10-16 16:27:27 -04:00
parent 19310bff89
commit d0264d45eb

View File

@ -145,22 +145,22 @@ import UIKit
public var errorMessage: String? {
didSet {
DispatchQueue.main.async { [weak self] in
guard let errorMessage = self?.errorMessage else { return }
if let enabled = self?.enabled, enabled {
self?.separatorHeightConstraint?.constant = 4
self?.errorShowing = true
self?.separatorView?.backgroundColor = UIColor.mfPumpkin()
self?.placeholderErrorLabel?.text = errorMessage
self?.placeholderErrorLabel?.numberOfLines = 0
self?.textField?.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "",
self?.textField?.text ?? "",
errorMessage)
self?.setNeedsDisplay()
self?.layoutIfNeeded()
}
guard enabled else { return }
self.separatorHeightConstraint?.constant = 4
self.errorShowing = true
self.separatorView?.backgroundColor = UIColor.mfPumpkin()
if let errorMessage = self.errorMessage {
self.placeholderErrorLabel?.text = errorMessage
self.placeholderErrorLabel?.numberOfLines = 0
self.textField?.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", self.textField?.text ?? "", errorMessage)
}
DispatchQueue.main.async {
self.setNeedsDisplay()
self.layoutIfNeeded()
}
}
}
@ -243,7 +243,6 @@ import UIKit
formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .horizontal)
formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .vertical)
formLabel.setContentCompressionResistancePriority(.required, for: .vertical)
formLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true
addSubview(formLabel)
@ -258,7 +257,7 @@ import UIKit
textFieldContainerView.translatesAutoresizingMaskIntoConstraints = false
addSubview(textFieldContainerView)
constrainContent(textFieldContainerView)
constrainTextFieldContent(textFieldContainerView)
textFieldContainerView.topAnchor.constraint(equalTo: formLabel.bottomAnchor, constant: 4).isActive = true
textContainerLeftPin = textFieldContainerView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor)
@ -270,23 +269,24 @@ import UIKit
self.placeholderErrorLabel = placeholderErrorLabel
placeholderErrorLabel.font = MFStyler.fontForTextFieldUnderLabel()
placeholderErrorLabel.textColor = .black
placeholderErrorLabel.setContentHuggingPriority(.required, for: .vertical)
placeholderErrorLabel.setContentHuggingPriority(UILayoutPriority(251), for: .horizontal)
placeholderErrorLabel.setContentHuggingPriority(UILayoutPriority(251), for: .horizontal)
placeholderErrorLabel.setContentCompressionResistancePriority(.required, for: .vertical)
addSubview(placeholderErrorLabel)
placeholderErrorLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 15).isActive = true
placeholderErrorLabel.topAnchor.constraint(equalTo: textFieldContainerView.bottomAnchor).isActive = true
errorLableLeftPin = placeholderErrorLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor)
errorLableLeftPin?.isActive = true
errorLableRightPin = layoutMarginsGuide.trailingAnchor.constraint(equalTo: placeholderErrorLabel.trailingAnchor)
errorLableRightPin?.isActive = true
layoutMarginsGuide.bottomAnchor.constraint(equalTo: placeholderErrorLabel.bottomAnchor).isActive = true
setNeedsLayout()
}
/// Configuration logic for the text container view.
private func constrainContent(_ parentView: UIView) {
private func constrainTextFieldContent(_ parentView: UIView) {
let backgroundView = UIView(frame: .zero)
self.backgroundView = backgroundView
@ -510,7 +510,7 @@ import UIKit
}
if let text = map[KeyDisable] as? String, text.isEqual(StringY) || map.boolForKey(KeyDisable) {
enable(false)
isEnabled(false)
}
if let errMessage = map[KeyErrorMessage] as? String {
@ -592,7 +592,7 @@ import UIKit
}
}
public func enable(_ enable: Bool) {
public func isEnabled(_ enable: Bool) {
// Set outside the dispatch so that registerAnimations can know about it
enabled = enable