fixed issues with TileContainer

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-31 11:53:32 -05:00
parent 5d6bba44ba
commit c7393aee84
2 changed files with 31 additions and 20 deletions

View File

@ -187,29 +187,40 @@ open class TileContainer: Control {
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
open override func setup() { open override func setup() {
super.setup() super.setup()
let layoutGuide = UILayoutGuide()
addLayoutGuide(layoutGuide)
layoutGuide
.pinTop()
.pinLeading()
.pinTrailing(0, .defaultHigh)
.pinBottom(0, .defaultHigh)
addSubview(backgroundImageView) addSubview(backgroundImageView)
addSubview(containerView) addSubview(containerView)
addSubview(highlightView) addSubview(highlightView)
widthConstraint = widthAnchor.constraint(equalToConstant: 0) widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0)
widthConstraint?.priority = .defaultHigh
heightGreaterThanConstraint = heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0) heightGreaterThanConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0)
heightGreaterThanConstraint?.isActive = false heightGreaterThanConstraint?.isActive = false
heightConstraint = heightAnchor.constraint(equalToConstant: 0) heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: 0)
heightConstraint?.priority = .defaultHigh
backgroundImageView.pinToSuperView() backgroundImageView.pin(layoutGuide)
backgroundImageView.isUserInteractionEnabled = false backgroundImageView.isUserInteractionEnabled = false
backgroundImageView.isHidden = true backgroundImageView.isHidden = true
containerView.backgroundColor = .clear containerView.backgroundColor = .clear
containerTopConstraint = containerView.pinTop(anchor: topAnchor, constant: padding.value) containerTopConstraint = containerView.pinTop(anchor: layoutGuide.topAnchor, constant: padding.value)
containerBottomConstraint = containerView.pinBottom(anchor: bottomAnchor, constant: padding.value) containerBottomConstraint = containerView.pinBottom(anchor: layoutGuide.bottomAnchor, constant: padding.value)
containerLeadingConstraint = containerView.pinLeading(anchor: leadingAnchor, constant: padding.value) containerLeadingConstraint = containerView.pinLeading(anchor: layoutGuide.leadingAnchor, constant: padding.value)
containerTrailingConstraint = containerView.pinTrailing(anchor: trailingAnchor, constant: padding.value) containerTrailingConstraint = containerView.pinTrailing(anchor: layoutGuide.trailingAnchor, constant: padding.value)
highlightView.pinToSuperView() highlightView.pin(layoutGuide)
highlightView.isHidden = true highlightView.isHidden = true
highlightView.backgroundColor = .clear highlightView.backgroundColor = .clear

View File

@ -31,19 +31,19 @@ extension LayoutConstraintable {
@discardableResult @discardableResult
/// Pins each to the all 4 anchor points to a view. /// Pins each to the all 4 anchor points to a view.
/// - Parameters: /// - Parameters:
/// - view: View that you will be pinned within. /// - layoutConstrainable: LayoutConstrainable that you will be pinned within.
/// - edges: Insets for each side. /// - edges: Insets for each side.
/// - Returns: Yourself. /// - Returns: Yourself.
public func pin(_ view: UIView, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { public func pin(_ layoutConstrainable: LayoutConstraintable, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self {
pinLeading(view.leadingAnchor, edges.left) pinLeading(layoutConstrainable.leadingAnchor, edges.left)
pinTrailing(view.trailingAnchor, edges.right) pinTrailing(layoutConstrainable.trailingAnchor, edges.right)
pinTop(view.topAnchor, edges.top) pinTop(layoutConstrainable.topAnchor, edges.top)
pinBottom(view.bottomAnchor, edges.bottom) pinBottom(layoutConstrainable.bottomAnchor, edges.bottom)
return self return self
} }
@discardableResult
@discardableResult
/// Pins each to the all 4 anchor points to the view you are set within. /// Pins each to the all 4 anchor points to the view you are set within.
/// - Parameter edges: Insets for each side. /// - Parameter edges: Insets for each side.
/// - Returns: Yourself. /// - Returns: Yourself.