mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Use name colors in reply headers
This commit is contained in:
@@ -100,6 +100,10 @@ public struct PresentationResourcesChat {
|
||||
}) as! PrincipalThemeAdditionalGraphics
|
||||
}
|
||||
|
||||
public static func chatBubbleVerticalLineImage(color: UIColor) -> UIImage? {
|
||||
return generateLineImage(color: color)
|
||||
}
|
||||
|
||||
public static func chatBubbleVerticalLineIncomingImage(_ theme: PresentationTheme) -> UIImage? {
|
||||
return theme.image(PresentationResourceKey.chatBubbleVerticalLineIncomingImage.rawValue, { theme in
|
||||
return generateLineImage(color: theme.chat.message.incoming.accentTextColor)
|
||||
|
||||
@@ -271,7 +271,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([
|
||||
return (result, needSeparateContainers, needReactions)
|
||||
}
|
||||
|
||||
private let chatMessagePeerIdColors: [UIColor] = [
|
||||
let chatMessagePeerIdColors: [UIColor] = [
|
||||
UIColor(rgb: 0xfc5c51),
|
||||
UIColor(rgb: 0xfa790f),
|
||||
UIColor(rgb: 0x895dd5),
|
||||
|
||||
@@ -74,11 +74,29 @@ class ChatMessageReplyInfoNode: ASDisplayNode {
|
||||
let lineImage: UIImage?
|
||||
let textColor: UIColor
|
||||
let dustColor: UIColor
|
||||
|
||||
|
||||
var authorNameColor: UIColor? = author.flatMap { chatMessagePeerIdColors[Int(clamping: $0.id.id._internalGetInt64Value() % 7)] }
|
||||
if let rawAuthorNameColor = authorNameColor {
|
||||
var dimColors = false
|
||||
switch presentationData.theme.theme.name {
|
||||
case .builtin(.nightAccent), .builtin(.night):
|
||||
dimColors = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
if dimColors {
|
||||
var hue: CGFloat = 0.0
|
||||
var saturation: CGFloat = 0.0
|
||||
var brightness: CGFloat = 0.0
|
||||
rawAuthorNameColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil)
|
||||
authorNameColor = UIColor(hue: hue, saturation: saturation * 0.7, brightness: min(1.0, brightness * 1.2), alpha: 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
switch type {
|
||||
case let .bubble(incoming):
|
||||
titleColor = incoming ? presentationData.theme.theme.chat.message.incoming.accentTextColor : presentationData.theme.theme.chat.message.outgoing.accentTextColor
|
||||
lineImage = incoming ? PresentationResourcesChat.chatBubbleVerticalLineIncomingImage(presentationData.theme.theme) : PresentationResourcesChat.chatBubbleVerticalLineOutgoingImage(presentationData.theme.theme)
|
||||
titleColor = incoming ? (authorNameColor ?? presentationData.theme.theme.chat.message.incoming.accentTextColor) : presentationData.theme.theme.chat.message.outgoing.accentTextColor
|
||||
lineImage = incoming ? (authorNameColor.flatMap({ PresentationResourcesChat.chatBubbleVerticalLineImage(color: $0) }) ?? PresentationResourcesChat.chatBubbleVerticalLineIncomingImage(presentationData.theme.theme)) : PresentationResourcesChat.chatBubbleVerticalLineOutgoingImage(presentationData.theme.theme)
|
||||
if isMedia {
|
||||
textColor = incoming ? presentationData.theme.theme.chat.message.incoming.secondaryTextColor : presentationData.theme.theme.chat.message.outgoing.secondaryTextColor
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user