From 81f73411489173ec726dc1f5eeca02bc8a84da09 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 15 Dec 2022 11:47:08 -0600 Subject: [PATCH] refactored to remove height now the a hit area exists Signed-off-by: Matt Bruce --- .../Buttons/TextLink/TextLink.swift | 9 +-------- .../Buttons/TextLinkCaret/TextLinkCaret.swift | 20 ++++++++----------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index 4f543ac5..ec03610c 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -17,7 +17,6 @@ open class TextLink: ButtonBase { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var heightConstraint: NSLayoutConstraint? private var lineHeightConstraint: NSLayoutConstraint? //-------------------------------------------------- @@ -83,9 +82,6 @@ open class TextLink: ButtonBase { lineHeightConstraint = line.heightAnchor.constraint(equalToConstant: 1.0) lineHeightConstraint?.isActive = true } - - heightConstraint = heightAnchor.constraint(equalToConstant: height) - heightConstraint?.isActive = true } open override func reset() { @@ -99,18 +95,15 @@ open class TextLink: ButtonBase { // MARK: - Overrides //-------------------------------------------------- open override var intrinsicContentSize: CGSize { - let size = titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize - return CGSize(width: size.width, height: height) + return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize } open override func updateView() { //need to set the properties so the super class //can render out the label correctly - heightConstraint?.constant = height line.backgroundColor = textColor //always call last so the label is rendered super.updateView() } - } diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index a6ac59c7..f6fa4a20 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -21,12 +21,10 @@ open class TextLinkCaret: ButtonBase { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var heightConstraint: NSLayoutConstraint? - open override var typograpicalStyle: TypographicalStyle { TypographicalStyle.BoldBodyLarge } - + private var caretView = CaretView().with { $0.size = CaretView.CaretSize.small(.vertical) $0.lineWidth = 2 @@ -64,7 +62,7 @@ open class TextLinkCaret: ButtonBase { open override var textColor: UIColor { textColorConfiguration.getColor(self) } - + private var textColorConfiguration = ControlColorConfiguration().with { $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal) $0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forState: .disabled) @@ -91,9 +89,7 @@ open class TextLinkCaret: ButtonBase { //-------------------------------------------------- open override func setup() { super.setup() - //constraints - heightAnchor.constraint(greaterThanOrEqualToConstant: height).isActive = true - + let size = caretView.size!.dimensions() caretView.frame = .init(x: 0, y: 0, width: size.width, height: size.height) } @@ -115,9 +111,9 @@ open class TextLinkCaret: ButtonBase { if let caretWidth = caretView.size?.dimensions().width { itemWidth += caretWidth } - return CGSize(width: itemWidth, height: height) + return CGSize(width: itemWidth, height: size.height) } - + open override func updateView() { let updatedText = text ?? "" @@ -129,9 +125,9 @@ open class TextLinkCaret: ButtonBase { let location = iconPosition == .right ? updatedText.count : 0 imageAttribute = ImageLabelAttribute(location: location, - image: image, - tintColor: textColor) - + image: image, + tintColor: textColor) + super.updateView() }