From 9883bd6214df931069fbe5a090bd4fbff461de71 Mon Sep 17 00:00:00 2001 From: vasavk Date: Thu, 22 Feb 2024 23:55:46 +0530 Subject: [PATCH] Digital ACT191 story ONEAPP-6682 Flex Height as per Layout and spacing --- .../TextFields/TextArea/TextArea.swift | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 7d70cb44..4494f1b7 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -5,7 +5,6 @@ // Created by Matt Bruce on 1/10/23. // -import Foundation import Foundation import UIKit import VDSColorTokens @@ -49,7 +48,7 @@ open class TextArea: EntryFieldBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - override var containerSize: CGSize { CGSize(width: 45, height: 88) } + override var containerSize: CGSize { CGSize(width: 182, height: 88) } /// UITextView shown in the TextArea. open var textView = UITextView().with { @@ -72,7 +71,7 @@ open class TextArea: EntryFieldBase { open override func setup() { super.setup() - minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: 0) + minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: containerSize.width) minWidthConstraint?.isActive = true controlContainerView.addSubview(textView) @@ -81,8 +80,8 @@ open class TextArea: EntryFieldBase { .pinLeading() .pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh) .pinBottom(0, .defaultHigh) - - textViewHeightConstraint = textView.heightAnchor.constraint(greaterThanOrEqualToConstant: 64) + textView.isScrollEnabled = true + textViewHeightConstraint = textView.heightAnchor.constraint(greaterThanOrEqualToConstant: containerSize.height) textViewHeightConstraint?.isActive = true backgroundColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success) borderColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessOnlight, VDSColor.feedbackSuccessOndark, forState: .success) @@ -132,17 +131,15 @@ extension TextArea: UITextViewDelegate { //if you want it to work "as-is" delete this code //since it will autogrow with the current settings if let textViewHeightConstraint, textView.isEditable { - let height = textView.frame.size.height - let constraintHeight = textViewHeightConstraint.constant - if height > constraintHeight { - if height > 64 && height < 152 { - textViewHeightConstraint.constant = 152 - } else if height > 152 { - textViewHeightConstraint.constant = 328 + let height = textView.contentSize.height + if height > 88 && height < 176 { + textViewHeightConstraint.constant = 176 + } else if height > 176 { + textViewHeightConstraint.constant = 352 } else { - textViewHeightConstraint.constant = 64 + textViewHeightConstraint.constant = 88 } - } + textViewHeightConstraint.isActive = true } //setting the value and firing control event