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:
@@ -250,10 +250,18 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
|
||||
incoming: chat.message.incoming.withUpdated(
|
||||
bubble: chat.message.incoming.bubble.withUpdated(
|
||||
withWallpaper: chat.message.incoming.bubble.withWallpaper.withUpdated(
|
||||
stroke: incomingBubbleStrokeColor
|
||||
stroke: incomingBubbleStrokeColor,
|
||||
reactionInactiveBackground: accentColor?.withMultipliedAlpha(0.1),
|
||||
reactionInactiveForeground: accentColor,
|
||||
reactionActiveBackground: accentColor,
|
||||
reactionActiveForeground: .clear
|
||||
),
|
||||
withoutWallpaper: chat.message.incoming.bubble.withoutWallpaper.withUpdated(
|
||||
stroke: incomingBubbleStrokeColor
|
||||
stroke: incomingBubbleStrokeColor,
|
||||
reactionInactiveBackground: accentColor?.withMultipliedAlpha(0.1),
|
||||
reactionInactiveForeground: accentColor,
|
||||
reactionActiveBackground: accentColor,
|
||||
reactionActiveForeground: .clear
|
||||
)
|
||||
),
|
||||
linkHighlightColor: accentColor?.withAlphaComponent(0.3),
|
||||
@@ -278,12 +286,20 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
|
||||
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
||||
fill: outgoingBubbleFillColors,
|
||||
highlightedFill: outgoingBubbleHighlightedFill,
|
||||
stroke: outgoingBubbleStrokeColor
|
||||
stroke: outgoingBubbleStrokeColor,
|
||||
reactionInactiveBackground: outgoingControlColor?.withMultipliedAlpha(0.1),
|
||||
reactionInactiveForeground: outgoingControlColor,
|
||||
reactionActiveBackground: outgoingControlColor,
|
||||
reactionActiveForeground: .clear
|
||||
),
|
||||
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
||||
fill: outgoingBubbleFillColors,
|
||||
highlightedFill: outgoingBubbleHighlightedFill,
|
||||
stroke: outgoingBubbleStrokeColor
|
||||
stroke: outgoingBubbleStrokeColor,
|
||||
reactionInactiveBackground: outgoingControlColor?.withMultipliedAlpha(0.1),
|
||||
reactionInactiveForeground: outgoingControlColor,
|
||||
reactionActiveBackground: outgoingControlColor,
|
||||
reactionActiveForeground: .clear
|
||||
)
|
||||
),
|
||||
primaryTextColor: outgoingPrimaryTextColor,
|
||||
|
||||
@@ -1101,6 +1101,7 @@ extension PresentationThemeBubbleColorComponents: Codable {
|
||||
case reactionInactiveFg
|
||||
case reactionActiveBg
|
||||
case reactionActiveFg
|
||||
case __workaroundNonexistingKey
|
||||
}
|
||||
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
@@ -1122,15 +1123,50 @@ 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