This commit is contained in:
Ali
2020-01-24 19:15:31 +04:00
parent 511f3ab727
commit 648553970e
3 changed files with 49 additions and 11 deletions

View File

@@ -293,11 +293,7 @@ public func messageBubbleImage(maxCornerRadius: CGFloat, minCornerRadius: CGFloa
drawingContext.withFlippedContext { context in
if onlyShadow {
context.clear(CGRect(origin: CGPoint(), size: rawSize))
//print("theme.message.outgoing.bubble.withWallpaper.fill.rgb \(theme.message.outgoing.bubble.withWallpaper.fill.rgb)")
if theme.message.outgoing.bubble.withWallpaper.fill.rgb == 14023347 {
return
}
return;
context.translateBy(x: rawSize.width / 2.0, y: rawSize.height / 2.0)
context.scaleBy(x: incoming ? -1.0 : 1.0, y: -1.0)

View File

@@ -549,21 +549,35 @@ public final class PresentationThemeChatList {
}
}
public struct PresentationThemeBubbleShadow {
public var color: UIColor
public var radius: CGFloat
public var verticalOffset: CGFloat
public init(color: UIColor, radius: CGFloat, verticalOffset: CGFloat) {
self.color = color
self.radius = radius
self.verticalOffset = verticalOffset
}
}
public final class PresentationThemeBubbleColorComponents {
public let fill: UIColor
public let gradientFill: UIColor
public let highlightedFill: UIColor
public let stroke: UIColor
//public let shadow: PresentationThemeBubbleShadow?
public init(fill: UIColor, gradientFill: UIColor? = nil, highlightedFill: UIColor, stroke: UIColor) {
public init(fill: UIColor, gradientFill: UIColor? = nil, highlightedFill: UIColor, stroke: UIColor/*, shadow: PresentationThemeBubbleShadow?*/) {
self.fill = fill
self.gradientFill = gradientFill ?? fill
self.highlightedFill = highlightedFill
self.stroke = stroke
//self.shadow = shadow
}
public func withUpdated(fill: UIColor? = nil, gradientFill: UIColor? = nil, highlightedFill: UIColor? = nil, stroke: UIColor? = nil) -> PresentationThemeBubbleColorComponents {
return PresentationThemeBubbleColorComponents(fill: fill ?? self.fill, gradientFill: gradientFill ?? self.gradientFill, highlightedFill: highlightedFill ?? self.highlightedFill, stroke: stroke ?? self.stroke)
return PresentationThemeBubbleColorComponents(fill: fill ?? self.fill, gradientFill: gradientFill ?? self.gradientFill, highlightedFill: highlightedFill ?? self.highlightedFill, stroke: stroke ?? self.stroke/*, shadow: self.shadow*/)
}
}

View File

@@ -979,21 +979,49 @@ extension PresentationThemeChatList: Codable {
}
}
extension PresentationThemeBubbleShadow: Codable {
enum CodingKeys: String, CodingKey {
case color
case radius
case verticalOffset
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
self.init(
color: try decodeColor(values, .color),
radius: try CGFloat(values.decode(Float.self, forKey: .radius)),
verticalOffset: try CGFloat(values.decode(Float.self, forKey: .verticalOffset))
)
}
public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: CodingKeys.self)
try encodeColor(&values, self.color, .color)
try values.encode(Float(self.radius), forKey: .radius)
try values.encode(Float(self.verticalOffset), forKey: .verticalOffset)
}
}
extension PresentationThemeBubbleColorComponents: Codable {
enum CodingKeys: String, CodingKey {
case bg
case gradientBg
case highlightedBg
case stroke
case shadow
}
public convenience init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
let codingPath = decoder.codingPath.map { $0.stringValue }.joined(separator: ".")
self.init(fill: try decodeColor(values, .bg),
gradientFill: try decodeColor(values, .gradientBg, decoder: decoder, fallbackKey: codingPath + ".bg"),
highlightedFill: try decodeColor(values, .highlightedBg),
stroke: try decodeColor(values, .stroke))
self.init(
fill: try decodeColor(values, .bg),
gradientFill: try decodeColor(values, .gradientBg, decoder: decoder, fallbackKey: codingPath + ".bg"),
highlightedFill: try decodeColor(values, .highlightedBg),
stroke: try decodeColor(values, .stroke)//,
//shadow: try? values.decode(PresentationThemeBubbleShadow.self, forKey: .shadow)
)
}
public func encode(to encoder: Encoder) throws {