From 648553970e604d0a0dcdb43fd4db7de6f62a60fe Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 24 Jan 2020 19:15:31 +0400 Subject: [PATCH] Temp --- .../Sources/ChatMessageBubbleImages.swift | 6 +--- .../Sources/PresentationTheme.swift | 18 ++++++++-- .../Sources/PresentationThemeCodable.swift | 36 ++++++++++++++++--- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift b/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift index c5b70db909..dfe03cedeb 100644 --- a/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift +++ b/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift @@ -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) diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index e9ab5e256a..c20bc02c28 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -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*/) } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index 876a2f188c..9ed40a2f67 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -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 {