diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 14d38d05..fc0ffa6e 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -240,7 +240,12 @@ open class TileContainerBase: Control where Padding heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: 0) - backgroundImageView.pin(layoutGuide) + backgroundImageView + .pinTop(layoutGuide.topAnchor) + .pinLeading(layoutGuide.leadingAnchor) + .pinTrailing(layoutGuide.trailingAnchor) + .pinBottom(layoutGuide.bottomAnchor, 0, .dragThatCanResizeScene) + backgroundImageView.isUserInteractionEnabled = false backgroundImageView.isHidden = true @@ -257,6 +262,7 @@ open class TileContainerBase: Control where Padding layer.cornerRadius = cornerRadius backgroundImageView.layer.cornerRadius = cornerRadius highlightView.layer.cornerRadius = cornerRadius + clipsToBounds = true } /// Resets to default settings. @@ -327,7 +333,14 @@ open class TileContainerBase: Control where Padding } applyBackgroundEffects() } - + + /// Used to update frames for the added CAlayers to our view + open override func layoutSubviews() { + super.layoutSubviews() + dropShadowLayers?.forEach { $0.frame = bounds } + gradientLayers?.forEach { $0.frame = bounds } + } + //-------------------------------------------------- // MARK: - Public Methods //-------------------------------------------------- diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index b1367736..fca3b4c2 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -349,6 +349,7 @@ open class Tilelet: TileContainerBase { If a Tilelet has only a Title or a Subtitle, then the Title or Subtitle is truncated and appended with an ellipsis when there is not enough space to display the full text. If a Tilelet has both Title and Subtitle, then only Subtitle will be truncated. If a Tilelet has Badge, Title and Subtitle, then Subtitle will be truncated first and Badge will be truncated second. Title will be truncated last (lowest priority). + Atleast one line text based on priority Minimum bottom space below Badge is 4px; less than 4px results in truncation. */ let labelPriority = UILayoutPriority.defaultHigh.rawValue @@ -576,8 +577,5 @@ open class Tilelet: TileContainerBase { extension Label { ///To calculate label single line height - fileprivate var minimumLineHeight: CGFloat { - guard let text, !text.isEmpty, let attributes = attributedText?.attributes(at: 0, longestEffectiveRange: nil, in: NSRange(location: 0, length: attributedText?.string.count ?? 0))[.paragraphStyle] as? NSParagraphStyle else { return font.lineHeight } - return attributes.minimumLineHeight - } + fileprivate var minimumLineHeight: CGFloat { textStyle.lineHeight } } diff --git a/VDS/Protocols/DropShadowable.swift b/VDS/Protocols/DropShadowable.swift index b569ecab..120abb98 100644 --- a/VDS/Protocols/DropShadowable.swift +++ b/VDS/Protocols/DropShadowable.swift @@ -50,7 +50,6 @@ extension ViewProtocol where Self: UIView { shadowLayer.shadowPath = shadowPath.cgPath shadowLayer.frame = bounds shadowLayer.position = .init(x: bounds.midX, y: bounds.midY) - shadowLayer.backgroundColor = backgroundColor?.cgColor shadowLayer.cornerRadius = layer.cornerRadius shadowLayer.shadowColor = config.shadowColorConfiguration.getColor(self).cgColor shadowLayer.shadowOpacity = Float(config.shadowOpacityConfiguration.value(for: self)) @@ -86,4 +85,8 @@ extension ViewProtocol where Self: UIView { func removeGradientLayer() { layer.sublayers?.removeAll { $0.name == "gradientLayer" } } + + //Helper variables to get gradient & shadow layers. These are exposed to update frame of layers when view's frame is updated. + var dropShadowLayers: [CALayer]? { layer.sublayers?.filter { $0.name == "dropShadowLayer" } } + var gradientLayers: [CAGradientLayer]? { layer.sublayers?.filter { $0.name == "gradientLayer" } as? [CAGradientLayer] } }