curent working order

This commit is contained in:
Kevin G Christiano 2020-05-08 15:06:25 -04:00
parent 4f3f52195e
commit e90be283dc
2 changed files with 33 additions and 4 deletions

View File

@ -179,7 +179,22 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
/// Validates the text of the entry field.
@objc public func validateTextField() {
text = textView.text
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
if let isValid = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) {
self.isValid = isValid
}
}
@objc public func updateValidation(_ isValid: Bool) {
let previousValidity = self.isValid
self.isValid = isValid
if previousValidity && !isValid {
// showError = true
// observingTextViewDelegate?.isInvalid?(textfield: self)
} else if (!previousValidity && isValid) {
// showError = false
// observingTextViewDelegate?.isValid?(textfield: self)
}
}
/// Executes on UITextField.textDidBeginEditingNotification
@ -241,9 +256,13 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
self.textView.setPlaceholderIfAvailable()
isSelected = false
if isValid {
showError = false
entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
} else {
showError = true
entryFieldContainer.disableAllBorders = false
}
proprietorTextDelegate?.textViewDidEndEditing?(textView)
}
@ -262,6 +281,16 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
heightConstraint?.isActive = true
}
model.updateUI = { [weak self] in
MVMCoreDispatchUtility.performBlock(onMainThread: {
guard let self = self else { return }
if self.isSelected {
self.updateValidation(model.isValid ?? true)
}
})
}
text = model.text
uiTextViewDelegate = delegateObject?.uiTextViewDelegate

View File

@ -19,7 +19,7 @@ import UIKit
let layer = CAShapeLayer()
layer.backgroundColor = UIColor.mvmBlack.cgColor
layer.drawsAsynchronously = true
layer.anchorPoint = CGPoint(x: 0.5, y: 1.0);
layer.anchorPoint = CGPoint(x: 0.5, y: 1.0)
return layer
}()
@ -140,7 +140,7 @@ import UIKit
borderPath.removeAllPoints()
if !disableAllBorders && !hideBorders {
if (disableAllBorders && showError) || (!disableAllBorders && !hideBorders) {
// Brings the other half of the line inside the view to prevent cropping.
let origin = bounds.origin
let size = frame.size
@ -260,7 +260,7 @@ import UIKit
open func refreshUI(bottomBarSize: CGFloat? = nil, updateMoleculeLayout: Bool = false) {
if !disableAllBorders {
if !disableAllBorders || (disableAllBorders && showError) {
let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1)
var heightChanged = false