diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryField.swift index b11181fa..f16c4e12 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryField.swift @@ -82,8 +82,9 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele public var placeholder: String? { get { return textViewEntryFieldModel?.placeholder } set { - textViewEntryFieldModel?.placeholder = newValue textView.placeholder = newValue ?? "" + textViewEntryFieldModel?.placeholder = newValue + textView.setPlaceholderIfAvailable() } } @@ -92,6 +93,19 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele //-------------------------------------------------- public var heightConstraint: NSLayoutConstraint? + private var topConstraint: NSLayoutConstraint? + private var leadingConstraint: NSLayoutConstraint? + private var trailingConstraint: NSLayoutConstraint? + private var bottomConstraint: NSLayoutConstraint? + + private func adjustMarginConstraints(constant: CGFloat) { + + topConstraint?.constant = constant + leadingConstraint?.constant = constant + trailingConstraint?.constant = constant + bottomConstraint?.constant = constant + layoutIfNeeded() + } //-------------------------------------------------- // MARK: - Delegate Properties @@ -139,14 +153,17 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele @objc open override func setupFieldContainerContent(_ container: UIView) { container.addSubview(textView) - - NSLayoutConstraint.activate([ - textView.topAnchor.constraint(equalTo: container.topAnchor, constant: Padding.Three), - textView.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: Padding.Three), - container.trailingAnchor.constraint(equalTo: textView.trailingAnchor, constant: Padding.Three), - container.bottomAnchor.constraint(equalTo: textView.bottomAnchor, constant: Padding.Three) - ]) - + + topConstraint = textView.topAnchor.constraint(equalTo: container.topAnchor, constant: Padding.Three) + leadingConstraint = textView.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: Padding.Three) + trailingConstraint = container.trailingAnchor.constraint(equalTo: textView.trailingAnchor, constant: Padding.Three) + bottomConstraint = container.bottomAnchor.constraint(equalTo: textView.bottomAnchor, constant: Padding.Three) + + topConstraint?.isActive = true + leadingConstraint?.isActive = true + trailingConstraint?.isActive = true + bottomConstraint?.isActive = true + heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0) accessibilityElements = [titleLabel, textView, feedbackLabel] } @@ -160,6 +177,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele super.reset() textView.reset() + adjustMarginConstraints(constant: Padding.Three) heightConstraint?.constant = 0 heightConstraint?.isActive = false } @@ -224,7 +242,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele textView.placeholder = model.placeholder ?? "" textView.placeholderFontStyle = model.placeholderFontStyle textView.placeholderTextColor = model.placeholderTextColor.uiColor - textView.setPlaceholderIfAvailable() + switch model.type { case .secure, .password: @@ -251,8 +269,13 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele } } - if !model.enabled { - isEnabled = false + if model.hideBorders { + adjustMarginConstraints(constant: 0) } + + textView.setPlaceholderIfAvailable() +// if !model.enabled { +// isEnabled = false +// } } } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryFieldModel.swift index 3d1e1407..ce1173ae 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextViewEntryFieldModel.swift @@ -19,7 +19,7 @@ class TextViewEntryFieldModel: TextEntryFieldModel { } public var accessibilityText: String? - public var fontStyle: Styler.Font = Styler.Font.RegularBodySmall + public var fontStyle: Styler.Font = Styler.Font.RegularBodyLarge public var height: CGFloat? public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3) public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro diff --git a/MVMCoreUI/BaseClasses/TextView.swift b/MVMCoreUI/BaseClasses/TextView.swift index f11efde9..2c609e02 100644 --- a/MVMCoreUI/BaseClasses/TextView.swift +++ b/MVMCoreUI/BaseClasses/TextView.swift @@ -72,7 +72,7 @@ import UIKit } open func updateView(_ size: CGFloat) { - font = fontStyle.getFont() + font = (isShowingPlaceholder ? placeholderFontStyle : fontStyle).getFont() } /// Will be called only once. @@ -109,7 +109,10 @@ import UIKit fontStyle = Styler.Font.RegularBodyLarge placeholderFontStyle = Styler.Font.RegularMicro placeholderTextColor = .mvmCoolGray3 + textColor = .mvmBlack isEnabled = true + text = "" + isShowingPlaceholder = false inputAccessoryView?.removeFromSuperview() defaultConfiguration() }