mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Video chat improvements
This commit is contained in:
@@ -8,11 +8,15 @@ public final class BundleIconComponent: Component {
|
||||
public let name: String
|
||||
public let tintColor: UIColor?
|
||||
public let maxSize: CGSize?
|
||||
public let shadowColor: UIColor?
|
||||
public let shadowBlur: CGFloat
|
||||
|
||||
public init(name: String, tintColor: UIColor?, maxSize: CGSize? = nil) {
|
||||
public init(name: String, tintColor: UIColor?, maxSize: CGSize? = nil, shadowColor: UIColor? = nil, shadowBlur: CGFloat = 0.0) {
|
||||
self.name = name
|
||||
self.tintColor = tintColor
|
||||
self.maxSize = maxSize
|
||||
self.shadowColor = shadowColor
|
||||
self.shadowBlur = shadowBlur
|
||||
}
|
||||
|
||||
public static func ==(lhs: BundleIconComponent, rhs: BundleIconComponent) -> Bool {
|
||||
@@ -25,6 +29,12 @@ public final class BundleIconComponent: Component {
|
||||
if lhs.maxSize != rhs.maxSize {
|
||||
return false
|
||||
}
|
||||
if lhs.shadowColor != rhs.shadowColor {
|
||||
return false
|
||||
}
|
||||
if lhs.shadowBlur != rhs.shadowBlur {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -40,12 +50,24 @@ public final class BundleIconComponent: Component {
|
||||
}
|
||||
|
||||
func update(component: BundleIconComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.component?.name != component.name || self.component?.tintColor != component.tintColor {
|
||||
if self.component?.name != component.name || self.component?.tintColor != component.tintColor || self.component?.shadowColor != component.shadowColor || self.component?.shadowBlur != component.shadowBlur {
|
||||
var image: UIImage?
|
||||
if let tintColor = component.tintColor {
|
||||
self.image = generateTintedImage(image: UIImage(bundleImageName: component.name), color: tintColor, backgroundColor: nil)
|
||||
image = generateTintedImage(image: UIImage(bundleImageName: component.name), color: tintColor, backgroundColor: nil)
|
||||
} else {
|
||||
self.image = UIImage(bundleImageName: component.name)
|
||||
image = UIImage(bundleImageName: component.name)
|
||||
}
|
||||
if let imageValue = image, let shadowColor = component.shadowColor, component.shadowBlur != 0.0 {
|
||||
image = generateImage(CGSize(width: imageValue.size.width + component.shadowBlur * 2.0, height: imageValue.size.height + component.shadowBlur * 2.0), contextGenerator: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
context.setShadow(offset: CGSize(), blur: component.shadowBlur, color: shadowColor.cgColor)
|
||||
|
||||
if let cgImage = imageValue.cgImage {
|
||||
context.draw(cgImage, in: CGRect(origin: CGPoint(x: component.shadowBlur, y: component.shadowBlur), size: imageValue.size))
|
||||
}
|
||||
})
|
||||
}
|
||||
self.image = image
|
||||
}
|
||||
self.component = component
|
||||
|
||||
|
||||
Reference in New Issue
Block a user