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. // Created by Matt Bruce on 1/10/23.
// //
import Foundation
import Foundation import Foundation
import UIKit import UIKit
import VDSColorTokens import VDSColorTokens
@ -49,7 +48,7 @@ open class TextArea: EntryFieldBase {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // 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. /// UITextView shown in the TextArea.
open var textView = UITextView().with { open var textView = UITextView().with {
@ -72,7 +71,7 @@ open class TextArea: EntryFieldBase {
open override func setup() { open override func setup() {
super.setup() super.setup()
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: 0) minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: containerSize.width)
minWidthConstraint?.isActive = true minWidthConstraint?.isActive = true
controlContainerView.addSubview(textView) controlContainerView.addSubview(textView)
@ -81,8 +80,8 @@ open class TextArea: EntryFieldBase {
.pinLeading() .pinLeading()
.pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh) .pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh)
.pinBottom(0, .defaultHigh) .pinBottom(0, .defaultHigh)
textView.isScrollEnabled = true
textViewHeightConstraint = textView.heightAnchor.constraint(greaterThanOrEqualToConstant: 64) textViewHeightConstraint = textView.heightAnchor.constraint(greaterThanOrEqualToConstant: containerSize.height)
textViewHeightConstraint?.isActive = true textViewHeightConstraint?.isActive = true
backgroundColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success) backgroundColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success)
borderColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessOnlight, VDSColor.feedbackSuccessOndark, 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 //if you want it to work "as-is" delete this code
//since it will autogrow with the current settings //since it will autogrow with the current settings
if let textViewHeightConstraint, textView.isEditable { if let textViewHeightConstraint, textView.isEditable {
let height = textView.frame.size.height let height = textView.contentSize.height
let constraintHeight = textViewHeightConstraint.constant if height > 88 && height < 176 {
if height > constraintHeight { textViewHeightConstraint.constant = 176
if height > 64 && height < 152 { } else if height > 176 {
textViewHeightConstraint.constant = 152 textViewHeightConstraint.constant = 352
} else if height > 152 {
textViewHeightConstraint.constant = 328
} else { } else {
textViewHeightConstraint.constant = 64 textViewHeightConstraint.constant = 88
} }
} textViewHeightConstraint.isActive = true
} }
//setting the value and firing control event //setting the value and firing control event