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