diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index 57e5c7f6..12db5a56 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -172,13 +172,13 @@ open class ButtonIcon: Control { SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, .clear).eraseToAnyColorable() }() var shadowColorConfiguration: AnyColorable = { - SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, .clear).eraseToAnyColorable() + SurfaceColorConfiguration(VDSColor.paletteBlack, .clear).eraseToAnyColorable() }() - var shadowOpacity: CGFloat = 0.5 - var shadowOffset: CGSize = .init(width: 1, height: 1) + var shadowOpacity: CGFloat = 0.16 + var shadowOffset: CGSize = .init(width: 0, height: 2) var shadowRadius: CGFloat = 2 } - + private struct HighContrastConfiguration: Configuration { var kind: Kind = .highContrast var surfaceType: SurfaceType = .colorFill @@ -280,7 +280,6 @@ open class ButtonIcon: Control { } else { icon.reset() } - setNeedsLayout() } @@ -316,26 +315,15 @@ open class ButtonIcon: Control { if let borderable = currentConfig as? Borderable { layer.borderColor = borderable.borderColorConfiguration.getColor(self).cgColor layer.borderWidth = borderable.borderWidth - icon.layer.borderWidth = borderable.borderWidth } else { layer.borderColor = nil layer.borderWidth = 0 - icon.layer.borderWidth = 0 } if let dropshadowable = currentConfig as? Dropshadowable { - layer.masksToBounds = false - layer.shadowColor = dropshadowable.shadowColorConfiguration.getColor(self).cgColor - layer.shadowOpacity = Float(dropshadowable.shadowOpacity) - layer.shadowOffset = dropshadowable.shadowOffset - layer.shadowRadius = dropshadowable.shadowRadius - layer.shadowPath = UIBezierPath(rect: bounds).cgPath - layer.shouldRasterize = true - layer.rasterizationScale = UIScreen.main.scale + addDropShadow(config: dropshadowable) } else { - layer.shadowOpacity = 0 - layer.shadowRadius = 0 - layer.shadowPath = nil + removeDropShadow() } } @@ -360,6 +348,25 @@ extension ButtonIcon: AppleGuidlinesTouchable { } +extension UIView { + fileprivate func addDropShadow(config: Dropshadowable) { + layer.masksToBounds = false + layer.shadowColor = config.shadowColorConfiguration.getColor(self).cgColor + layer.shadowOpacity = Float(config.shadowOpacity) + layer.shadowOffset = config.shadowOffset + layer.shadowRadius = config.shadowRadius + layer.shouldRasterize = true + layer.rasterizationScale = UIScreen.main.scale + layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius).cgPath + } + + fileprivate func removeDropShadow() { + layer.shadowOpacity = 0 + layer.shadowRadius = 0 + layer.shadowPath = nil + } +} + private protocol Borderable { var borderWidth: CGFloat { get set } var borderColorConfiguration: AnyColorable { get set }