latest functioning state

This commit is contained in:
Kevin G Christiano 2020-05-08 15:33:04 -04:00
parent e90be283dc
commit f923c4de52
2 changed files with 12 additions and 28 deletions

View File

@ -52,7 +52,11 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
guard let self = self else { return } guard let self = self else { return }
self.textView.isEnabled = enabled self.textView.isEnabled = enabled
self.textView.textColor = enabled ? self.textViewEntryFieldModel?.enabledTextColor.uiColor : self.textViewEntryFieldModel?.disabledTextColor.uiColor if self.textView.isShowingPlaceholder {
self.textView.textColor = self.textView.placeholderTextColor
} else {
self.textView.textColor = enabled ? self.textViewEntryFieldModel?.enabledTextColor.uiColor : self.textViewEntryFieldModel?.disabledTextColor.uiColor
}
} }
} }
} }
@ -184,19 +188,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
} }
} }
@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 /// Executes on UITextField.textDidBeginEditingNotification
@objc func startEditing() { @objc func startEditing() {
isSelected = true isSelected = true
@ -262,8 +253,8 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
} else { } else {
showError = true showError = true
entryFieldContainer.disableAllBorders = false
} }
proprietorTextDelegate?.textViewDidEndEditing?(textView) proprietorTextDelegate?.textViewDidEndEditing?(textView)
} }
@ -281,16 +272,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
heightConstraint?.isActive = true 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 text = model.text
uiTextViewDelegate = delegateObject?.uiTextViewDelegate uiTextViewDelegate = delegateObject?.uiTextViewDelegate
@ -302,6 +283,9 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
textView.textAlignment = model.textAlignment textView.textAlignment = model.textAlignment
textView.textColor = model.enabled ? model.enabledTextColor.uiColor : model.disabledTextColor.uiColor textView.textColor = model.enabled ? model.enabledTextColor.uiColor : model.disabledTextColor.uiColor
textView.font = model.fontStyle.getFont() textView.font = model.fontStyle.getFont()
textView.placeholder = model.placeholder ?? ""
textView.placeholderFontStyle = model.placeholderFontStyle
textView.placeholderTextColor = model.placeholderTextColor.uiColor
textView.setPlaceholderIfAvailable() textView.setPlaceholderIfAvailable()
switch model.type { switch model.type {

View File

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