mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Support custom themes
This commit is contained in:
@@ -1101,6 +1101,7 @@ extension PresentationThemeBubbleColorComponents: Codable {
|
||||
case reactionInactiveFg
|
||||
case reactionActiveBg
|
||||
case reactionActiveFg
|
||||
case __workaroundNonexistingKey
|
||||
}
|
||||
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
@@ -1121,16 +1122,51 @@ extension PresentationThemeBubbleColorComponents: Codable {
|
||||
|
||||
fill = [fillColor, gradientColor]
|
||||
}
|
||||
|
||||
|
||||
let fallbackKeyPrefix: String
|
||||
if codingPath.hasPrefix("chat.message.incoming.") {
|
||||
fallbackKeyPrefix = "chat.message.incoming."
|
||||
} else {
|
||||
fallbackKeyPrefix = "chat.message.outgoing."
|
||||
}
|
||||
|
||||
let reactionInactiveBackground: UIColor
|
||||
if let color = try? decodeColor(values, .reactionInactiveBg) {
|
||||
reactionInactiveBackground = color
|
||||
} else {
|
||||
reactionInactiveBackground = (try decodeColor(values, .__workaroundNonexistingKey, fallbackKey: "\(fallbackKeyPrefix).accentControl")).withMultipliedAlpha(0.1)
|
||||
}
|
||||
|
||||
let reactionInactiveForeground: UIColor
|
||||
if let color = try? decodeColor(values, .reactionInactiveFg) {
|
||||
reactionInactiveForeground = color
|
||||
} else {
|
||||
reactionInactiveForeground = try decodeColor(values, .__workaroundNonexistingKey, fallbackKey: "\(fallbackKeyPrefix).accentControl")
|
||||
}
|
||||
|
||||
let reactionActiveBackground: UIColor
|
||||
if let color = try? decodeColor(values, .reactionActiveBg) {
|
||||
reactionActiveBackground = color
|
||||
} else {
|
||||
reactionActiveBackground = try decodeColor(values, .__workaroundNonexistingKey, fallbackKey: "\(fallbackKeyPrefix).accentControl")
|
||||
}
|
||||
|
||||
let reactionActiveForeground: UIColor
|
||||
if let color = try? decodeColor(values, .reactionActiveFg) {
|
||||
reactionActiveForeground = color
|
||||
} else {
|
||||
reactionActiveForeground = .clear
|
||||
}
|
||||
|
||||
self.init(
|
||||
fill: fill,
|
||||
highlightedFill: try decodeColor(values, .highlightedBg),
|
||||
stroke: try decodeColor(values, .stroke),
|
||||
shadow: try? values.decode(PresentationThemeBubbleShadow.self, forKey: .shadow),
|
||||
reactionInactiveBackground: try decodeColor(values, .reactionInactiveBg),
|
||||
reactionInactiveForeground: try decodeColor(values, .reactionInactiveFg),
|
||||
reactionActiveBackground: try decodeColor(values, .reactionActiveBg),
|
||||
reactionActiveForeground: try decodeColor(values, .reactionActiveFg)
|
||||
reactionInactiveBackground: reactionInactiveBackground,
|
||||
reactionInactiveForeground: reactionInactiveForeground,
|
||||
reactionActiveBackground: reactionActiveBackground,
|
||||
reactionActiveForeground: reactionActiveForeground
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user