diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 96a42903..68ba7f97 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -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)