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 heightConstraint: NSLayoutConstraint?
|
||||
|
||||
private var dimensions: CGSize {
|
||||
guard let customSize else { return size.dimensions }
|
||||
return .init(width: customSize, height: customSize)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
open var imageView = UIImageView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.setContentHuggingPriority(.required, for: .vertical)
|
||||
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||
$0.setContentHuggingPriority(.required, for: .horizontal)
|
||||
$0.contentMode = .scaleAspectFill
|
||||
$0.clipsToBounds = true
|
||||
}
|
||||
@ -44,7 +51,7 @@ open class Icon: View {
|
||||
|
||||
//functions
|
||||
//--------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
|
||||
open override func setup() {
|
||||
@ -85,12 +92,6 @@ open class Icon: View {
|
||||
}
|
||||
|
||||
//set the icon dimensions
|
||||
var dimensions = size.dimensions
|
||||
|
||||
if let customSize {
|
||||
dimensions = .init(width: customSize, height: customSize)
|
||||
}
|
||||
|
||||
heightConstraint?.constant = dimensions.height
|
||||
widthConstraint?.constant = dimensions.width
|
||||
|
||||
@ -101,8 +102,9 @@ open class Icon: View {
|
||||
} else {
|
||||
imageView.image = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private func getImage(for imageName: String) -> UIImage? {
|
||||
|
||||
return BundleManager.shared.image(for: imageName)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user