diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift index 7355d17c..182e2cee 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift @@ -18,13 +18,14 @@ import Foundation public let arrow = Arrow(frame: .zero) public let arrowAndLabel2Stack: Stack let view = MVMCoreUICommonViewsUtility.commonView() + public var alignmentConstraint: NSLayoutConstraint? //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - arrowAndLabel2Stack = Stack.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .trailing)), - (view: rightLabel, model: StackItemModel(horizontalAlignment: .trailing))], + arrowAndLabel2Stack = Stack.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .center)), + (view: rightLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .center))], axis: .horizontal, spacing: 8) rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) @@ -40,29 +41,35 @@ import Foundation // MARK: - View Lifecycle //----------------------------------------------------- + public override func alignAccessoryToHero() { + super.alignAccessoryToHero() + + // Aligns the center of the right side to the headline. + if let heroCenter = heroAccessoryCenter { + let convertedPoint = view.convert(heroCenter, from: self) + alignmentConstraint?.constant = convertedPoint.y - view.bounds.midY + } + } + override open func setupView() { super.setupView() arrow.pinHeightAndWidth() arrowAndLabel2Stack.restack() - view.addSubview(eyebrowHeadlineBodyLink) view.addSubview(arrowAndLabel2Stack) contentView.addSubview(view) containerHelper.constrainView(view) - //constraints - arrowAndLabel2Stack.leadingAnchor.constraint(equalTo: eyebrowHeadlineBodyLink.trailingAnchor, constant: PaddingTen).isActive = true - arrowAndLabel2Stack.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true - arrowAndLabel2Stack.topAnchor.constraint(equalTo: view.topAnchor, constant: PaddingTwo).isActive = true - - eyebrowHeadlineBodyLink.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true - eyebrowHeadlineBodyLink.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - eyebrowHeadlineBodyLink.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + NSLayoutConstraint.pinViews(leftView: eyebrowHeadlineBodyLink, rightView: arrowAndLabel2Stack, alignTop: false) + alignmentConstraint = view.constraintsAffectingLayout(for: .vertical).first { (layout) -> Bool in + return layout.firstAnchor == arrowAndLabel2Stack.centerYAnchor && layout.firstAttribute == .centerY + } } public override func updateView(_ size: CGFloat) { super.updateView(size) eyebrowHeadlineBodyLink.updateView(size) + arrowAndLabel2Stack.updateView(size) } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -79,6 +86,8 @@ import Foundation open override func reset() { super.reset() + eyebrowHeadlineBodyLink.reset() + arrowAndLabel2Stack.reset() rightLabel.styleB2(true) } } diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index dc4d270a..8170e402 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -26,7 +26,7 @@ import UIKit /// For subclasses that want to use a custom accessory view. open var customAccessoryView = false - private var heroAccessoryCenter: CGPoint? + public var heroAccessoryCenter: CGPoint? private var initialSetupPerformed = false