Digital ACT191 story ONEAPP-6682 Flex Height as per Layout and spacing

This commit is contained in:
vasavk 2024-02-22 23:55:46 +05:30
parent 8f9ecce1c1
commit 9883bd6214

View File

@ -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