more changes
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d8f3819063
commit
c2c2bfeb4a
@ -51,7 +51,9 @@ open class TextLinkCaret: ButtonBase {
|
||||
$0.setSurfaceColors(VDSColor.interactiveActiveOnlight, VDSColor.interactiveActiveOndark, forState: .highlighted)
|
||||
}
|
||||
|
||||
private var imageAttribute: CaretLabelAttribute?
|
||||
private var imageAttribute: CaretLabelAttribute? {
|
||||
iconPosition == .right ? CaretLabelAttribute(tintColor: textColor, position: iconPosition) : nil
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
@ -81,19 +83,12 @@ open class TextLinkCaret: ButtonBase {
|
||||
super.setup()
|
||||
accessibilityTraits = .link
|
||||
titleLabel?.numberOfLines = 0
|
||||
if let caret = BundleManager.shared.image(for: Icon.Name.leftCaretBold.rawValue) {
|
||||
setImage(caret, for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to make changes to the View based off a change events or from local properties.
|
||||
open override func updateView() {
|
||||
if iconPosition == .right {
|
||||
imageAttribute = CaretLabelAttribute(tintColor: textColor, position: iconPosition)
|
||||
} else {
|
||||
imageAttribute = nil
|
||||
}
|
||||
imageView?.isHidden = iconPosition == .right
|
||||
setImage(iconPosition == .right ? nil : BundleManager.shared.image(for: Icon.Name.leftCaretBold.rawValue), for: .normal)
|
||||
imageEdgeInsets = iconPosition == .right ? .zero : .init(top: 0, left: -spacing, bottom: 0, right: 0)
|
||||
super.updateView()
|
||||
}
|
||||
|
||||
@ -110,13 +105,14 @@ open class TextLinkCaret: ButtonBase {
|
||||
if iconPosition == .right {
|
||||
return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize
|
||||
} else {
|
||||
let width = imageSize.width + 4.0 + (titleLabel?.intrinsicContentSize.width ?? super.intrinsicContentSize.width)
|
||||
let width = imageSize.width + spacing + (titleLabel?.intrinsicContentSize.width ?? super.intrinsicContentSize.width)
|
||||
let height = titleLabel?.intrinsicContentSize.height ?? super.intrinsicContentSize.height
|
||||
return .init(width: width, height: height)
|
||||
}
|
||||
}
|
||||
private let imageSize = Icon.Size.xsmall.dimensions
|
||||
private let spacing = 4.0
|
||||
|
||||
// private var activeConstraints: [NSLayoutConstraint] = []
|
||||
//
|
||||
// private func setupConstraints() {
|
||||
@ -159,21 +155,26 @@ open class TextLinkCaret: ButtonBase {
|
||||
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
guard let imageView, let titleLabel else { return }
|
||||
|
||||
if imageView.isHidden {
|
||||
titleLabel.frame.origin.x = 0
|
||||
contentEdgeInsets = .zero
|
||||
} else {
|
||||
imageView.frame.origin.x = 0
|
||||
titleLabel.frame.origin.x = imageSize.width + spacing
|
||||
|
||||
let totalWidth = titleLabel.frame.maxX
|
||||
let leftInset = (bounds.width - totalWidth) / 2
|
||||
contentEdgeInsets = .init(top: 0, left: leftInset, bottom: 0, right: leftInset)
|
||||
}
|
||||
imageView?.frame.size = imageSize
|
||||
imageView?.frame.origin = .init(x: 0, y: spacing)
|
||||
}
|
||||
// open override func layoutSubviews() {
|
||||
// super.layoutSubviews()
|
||||
//
|
||||
// guard let imageView, let titleLabel else { return }
|
||||
//
|
||||
// if imageView.isHidden {
|
||||
// titleLabel.frame.origin.x = 0
|
||||
// contentEdgeInsets = .zero
|
||||
// } else {
|
||||
// imageView.frame.origin.x = 0
|
||||
// titleLabel.frame.origin.x = imageSize.width + spacing
|
||||
//
|
||||
// let totalWidth = titleLabel.frame.maxX
|
||||
// let leftInset = (bounds.width - totalWidth) / 2
|
||||
// contentEdgeInsets = .init(top: 0, left: leftInset, bottom: 0, right: leftInset)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user