updated logic
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3ca168a53b
commit
d5489dc9af
@ -19,13 +19,20 @@ open class Icon: View {
|
|||||||
private var widthConstraint: NSLayoutConstraint?
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
private var heightConstraint: NSLayoutConstraint?
|
private var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
private var dimensions: CGSize {
|
||||||
|
guard let customSize else { return size.dimensions }
|
||||||
|
return .init(width: customSize, height: customSize)
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var imageView = UIImageView().with {
|
open var imageView = UIImageView().with {
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
|
$0.setContentHuggingPriority(.required, for: .vertical)
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
|
$0.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
$0.contentMode = .scaleAspectFill
|
$0.contentMode = .scaleAspectFill
|
||||||
$0.clipsToBounds = true
|
$0.clipsToBounds = true
|
||||||
}
|
}
|
||||||
@ -44,7 +51,7 @@ open class Icon: View {
|
|||||||
|
|
||||||
//functions
|
//functions
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
@ -85,12 +92,6 @@ open class Icon: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set the icon dimensions
|
//set the icon dimensions
|
||||||
var dimensions = size.dimensions
|
|
||||||
|
|
||||||
if let customSize {
|
|
||||||
dimensions = .init(width: customSize, height: customSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
heightConstraint?.constant = dimensions.height
|
heightConstraint?.constant = dimensions.height
|
||||||
widthConstraint?.constant = dimensions.width
|
widthConstraint?.constant = dimensions.width
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ open class Icon: View {
|
|||||||
} else {
|
} else {
|
||||||
imageView.image = nil
|
imageView.image = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getImage(for imageName: String) -> UIImage? {
|
private func getImage(for imageName: String) -> UIImage? {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user