fixed tilecontainer issue
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2630dc43bf
commit
d995ac3954
@ -12,6 +12,24 @@ import UIKit
|
|||||||
@objc(VDSTileContainer)
|
@objc(VDSTileContainer)
|
||||||
open class TileContainer: Control {
|
open class TileContainer: Control {
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializers
|
||||||
|
//--------------------------------------------------
|
||||||
|
required public init() {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder: NSCoder) {
|
||||||
|
super.init(coder: coder)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
|
||||||
public enum ContainerBackgroundColor: String, CaseIterable {
|
public enum ContainerBackgroundColor: String, CaseIterable {
|
||||||
case white
|
case white
|
||||||
case black
|
case black
|
||||||
@ -96,22 +114,18 @@ open class TileContainer: Control {
|
|||||||
return 48.0
|
return 48.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private lazy var widthConstraint: NSLayoutConstraint = {
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
let constraint = widthAnchor.constraint(equalToConstant: width)
|
private var heightConstraint: NSLayoutConstraint?
|
||||||
constraint.isActive = true
|
internal var containerTopConstraint: NSLayoutConstraint?
|
||||||
return constraint
|
internal var containerBottomConstraint: NSLayoutConstraint?
|
||||||
}()
|
internal var containerLeadingConstraint: NSLayoutConstraint?
|
||||||
|
internal var containerTrailingConstraint: NSLayoutConstraint?
|
||||||
private lazy var heightConstraint: NSLayoutConstraint = {
|
|
||||||
let constraint = heightAnchor.constraint(equalToConstant: 100)
|
|
||||||
constraint.isActive = true
|
|
||||||
return constraint
|
|
||||||
}()
|
|
||||||
|
|
||||||
//functions
|
//functions
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
@ -122,13 +136,28 @@ open class TileContainer: Control {
|
|||||||
addSubview(backgroundImageView)
|
addSubview(backgroundImageView)
|
||||||
addSubview(containerView)
|
addSubview(containerView)
|
||||||
addSubview(highlightView)
|
addSubview(highlightView)
|
||||||
|
|
||||||
|
widthConstraint = widthAnchor.constraint(equalToConstant: width)
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
|
||||||
|
heightConstraint = heightAnchor.constraint(equalToConstant: width)
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
|
||||||
backgroundImageView.pinToSuperView()
|
backgroundImageView.pinToSuperView()
|
||||||
backgroundImageView.isUserInteractionEnabled = false
|
backgroundImageView.isUserInteractionEnabled = false
|
||||||
backgroundImageView.isHidden = true
|
backgroundImageView.isHidden = true
|
||||||
|
|
||||||
containerView.pinToSuperView()
|
|
||||||
containerView.isUserInteractionEnabled = false
|
containerView.isUserInteractionEnabled = false
|
||||||
containerView.backgroundColor = .clear
|
containerView.backgroundColor = .clear
|
||||||
|
|
||||||
|
containerTopConstraint = containerView.topAnchor.constraint(lessThanOrEqualTo: topAnchor, constant: padding)
|
||||||
|
containerTopConstraint?.isActive = true
|
||||||
|
containerBottomConstraint = containerView.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor, constant: padding)
|
||||||
|
containerBottomConstraint?.isActive = true
|
||||||
|
containerLeadingConstraint = containerView.leadingAnchor.constraint(lessThanOrEqualTo: leadingAnchor, constant: padding)
|
||||||
|
containerLeadingConstraint?.isActive = true
|
||||||
|
containerTrailingConstraint = containerView.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor, constant: padding)
|
||||||
|
containerTrailingConstraint?.isActive = true
|
||||||
|
|
||||||
highlightView.pinToSuperView()
|
highlightView.pinToSuperView()
|
||||||
highlightView.isUserInteractionEnabled = false
|
highlightView.isUserInteractionEnabled = false
|
||||||
@ -138,6 +167,7 @@ open class TileContainer: Control {
|
|||||||
//corner radius
|
//corner radius
|
||||||
layer.cornerRadius = cornerRadius
|
layer.cornerRadius = cornerRadius
|
||||||
backgroundImageView.layer.cornerRadius = 8
|
backgroundImageView.layer.cornerRadius = 8
|
||||||
|
highlightView.layer.cornerRadius = 8
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,16 +245,19 @@ open class TileContainer: Control {
|
|||||||
|
|
||||||
layer.borderColor = borderColorConfig.getColor(self).cgColor
|
layer.borderColor = borderColorConfig.getColor(self).cgColor
|
||||||
layer.borderWidth = showBorder ? 1 : 0
|
layer.borderWidth = showBorder ? 1 : 0
|
||||||
|
|
||||||
containerView.layoutMargins = UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding)
|
containerTopConstraint?.constant = padding
|
||||||
|
containerLeadingConstraint?.constant = padding
|
||||||
|
containerBottomConstraint?.constant = -padding
|
||||||
|
containerTrailingConstraint?.constant = -padding
|
||||||
|
|
||||||
if let height {
|
if let height {
|
||||||
widthConstraint.constant = width
|
widthConstraint?.constant = width
|
||||||
heightConstraint.constant = height
|
heightConstraint?.constant = height
|
||||||
} else {
|
} else {
|
||||||
let size = ratioSize
|
let size = ratioSize
|
||||||
widthConstraint.constant = size.width
|
widthConstraint?.constant = size.width
|
||||||
heightConstraint.constant = size.height
|
heightConstraint?.constant = size.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user