mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +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(
|
incoming: chat.message.incoming.withUpdated(
|
||||||
bubble: chat.message.incoming.bubble.withUpdated(
|
bubble: chat.message.incoming.bubble.withUpdated(
|
||||||
withWallpaper: chat.message.incoming.bubble.withWallpaper.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(
|
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),
|
linkHighlightColor: accentColor?.withAlphaComponent(0.3),
|
||||||
@@ -278,12 +286,20 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
|
|||||||
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
||||||
fill: outgoingBubbleFillColors,
|
fill: outgoingBubbleFillColors,
|
||||||
highlightedFill: outgoingBubbleHighlightedFill,
|
highlightedFill: outgoingBubbleHighlightedFill,
|
||||||
stroke: outgoingBubbleStrokeColor
|
stroke: outgoingBubbleStrokeColor,
|
||||||
|
reactionInactiveBackground: outgoingControlColor?.withMultipliedAlpha(0.1),
|
||||||
|
reactionInactiveForeground: outgoingControlColor,
|
||||||
|
reactionActiveBackground: outgoingControlColor,
|
||||||
|
reactionActiveForeground: .clear
|
||||||
),
|
),
|
||||||
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
||||||
fill: outgoingBubbleFillColors,
|
fill: outgoingBubbleFillColors,
|
||||||
highlightedFill: outgoingBubbleHighlightedFill,
|
highlightedFill: outgoingBubbleHighlightedFill,
|
||||||
stroke: outgoingBubbleStrokeColor
|
stroke: outgoingBubbleStrokeColor,
|
||||||
|
reactionInactiveBackground: outgoingControlColor?.withMultipliedAlpha(0.1),
|
||||||
|
reactionInactiveForeground: outgoingControlColor,
|
||||||
|
reactionActiveBackground: outgoingControlColor,
|
||||||
|
reactionActiveForeground: .clear
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
primaryTextColor: outgoingPrimaryTextColor,
|
primaryTextColor: outgoingPrimaryTextColor,
|
||||||
|
|||||||
@@ -1101,6 +1101,7 @@ extension PresentationThemeBubbleColorComponents: Codable {
|
|||||||
case reactionInactiveFg
|
case reactionInactiveFg
|
||||||
case reactionActiveBg
|
case reactionActiveBg
|
||||||
case reactionActiveFg
|
case reactionActiveFg
|
||||||
|
case __workaroundNonexistingKey
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(from decoder: Decoder) throws {
|
public convenience init(from decoder: Decoder) throws {
|
||||||
@@ -1122,15 +1123,50 @@ extension PresentationThemeBubbleColorComponents: Codable {
|
|||||||
fill = [fillColor, gradientColor]
|
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(
|
self.init(
|
||||||
fill: fill,
|
fill: fill,
|
||||||
highlightedFill: try decodeColor(values, .highlightedBg),
|
highlightedFill: try decodeColor(values, .highlightedBg),
|
||||||
stroke: try decodeColor(values, .stroke),
|
stroke: try decodeColor(values, .stroke),
|
||||||
shadow: try? values.decode(PresentationThemeBubbleShadow.self, forKey: .shadow),
|
shadow: try? values.decode(PresentationThemeBubbleShadow.self, forKey: .shadow),
|
||||||
reactionInactiveBackground: try decodeColor(values, .reactionInactiveBg),
|
reactionInactiveBackground: reactionInactiveBackground,
|
||||||
reactionInactiveForeground: try decodeColor(values, .reactionInactiveFg),
|
reactionInactiveForeground: reactionInactiveForeground,
|
||||||
reactionActiveBackground: try decodeColor(values, .reactionActiveBg),
|
reactionActiveBackground: reactionActiveBackground,
|
||||||
reactionActiveForeground: try decodeColor(values, .reactionActiveFg)
|
reactionActiveForeground: reactionActiveForeground
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user