Add reaction badge color

This commit is contained in:
Ali 2022-02-08 23:56:21 +04:00
parent 090673b4c9
commit 736f575e68
6 changed files with 130 additions and 11 deletions

View File

@ -461,6 +461,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
unreadBadgeActiveTextColor: UIColor(rgb: 0x000000),
unreadBadgeInactiveBackgroundColor: UIColor(rgb: 0x666666),
unreadBadgeInactiveTextColor:UIColor(rgb: 0x000000),
reactionBadgeActiveBackgroundColor: UIColor(rgb: 0xFF2D55),
pinnedBadgeColor: UIColor(rgb: 0x767677),
pinnedSearchBarColor: UIColor(rgb: 0x272728),
regularSearchBarColor: UIColor(rgb: 0x272728),

View File

@ -215,6 +215,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
unreadBadgeActiveTextColor: secondaryBadgeTextColor,
unreadBadgeInactiveBackgroundColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
unreadBadgeInactiveTextColor: additionalBackgroundColor,
reactionBadgeActiveBackgroundColor: UIColor(rgb: 0xFF2D55),
pinnedBadgeColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
pinnedSearchBarColor: mainInputColor,
regularSearchBarColor: accentColor?.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.12),
@ -688,6 +689,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
unreadBadgeActiveTextColor: secondaryBadgeTextColor,
unreadBadgeInactiveBackgroundColor: mainSecondaryTextColor.withAlphaComponent(0.4),
unreadBadgeInactiveTextColor: additionalBackgroundColor,
reactionBadgeActiveBackgroundColor: UIColor(rgb: 0xFF2D55),
pinnedBadgeColor: mainSecondaryTextColor.withAlphaComponent(0.5),
pinnedSearchBarColor: accentColor.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.12),
regularSearchBarColor: accentColor.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.12),

View File

@ -532,6 +532,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
unreadBadgeActiveTextColor: UIColor(rgb: 0xffffff),
unreadBadgeInactiveBackgroundColor: UIColor(rgb: 0xb6b6bb),
unreadBadgeInactiveTextColor: UIColor(rgb: 0xffffff),
reactionBadgeActiveBackgroundColor: UIColor(rgb: 0xFF2D55),
pinnedBadgeColor: UIColor(rgb: 0xb6b6bb),
pinnedSearchBarColor: UIColor(rgb: 0xe5e5e5),
regularSearchBarColor: UIColor(rgb: 0xe9e9e9),

View File

@ -569,6 +569,7 @@ public final class PresentationThemeChatList {
public let unreadBadgeActiveTextColor: UIColor
public let unreadBadgeInactiveBackgroundColor: UIColor
public let unreadBadgeInactiveTextColor: UIColor
public let reactionBadgeActiveBackgroundColor: UIColor
public let pinnedBadgeColor: UIColor
public let pinnedSearchBarColor: UIColor
public let regularSearchBarColor: UIColor
@ -581,7 +582,42 @@ public final class PresentationThemeChatList {
public let unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors
public let onlineDotColor: UIColor
init(backgroundColor: UIColor, itemSeparatorColor: UIColor, itemBackgroundColor: UIColor, pinnedItemBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor, itemSelectedBackgroundColor: UIColor, titleColor: UIColor, secretTitleColor: UIColor, dateTextColor: UIColor, authorNameColor: UIColor, messageTextColor: UIColor, messageHighlightedTextColor: UIColor, messageDraftTextColor: UIColor, checkmarkColor: UIColor, pendingIndicatorColor: UIColor, failedFillColor: UIColor, failedForegroundColor: UIColor, muteIconColor: UIColor, unreadBadgeActiveBackgroundColor: UIColor, unreadBadgeActiveTextColor: UIColor, unreadBadgeInactiveBackgroundColor: UIColor, unreadBadgeInactiveTextColor: UIColor, pinnedBadgeColor: UIColor, pinnedSearchBarColor: UIColor, regularSearchBarColor: UIColor, sectionHeaderFillColor: UIColor, sectionHeaderTextColor: UIColor, verifiedIconFillColor: UIColor, verifiedIconForegroundColor: UIColor, secretIconColor: UIColor, pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors, unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors, onlineDotColor: UIColor) {
init(
backgroundColor: UIColor,
itemSeparatorColor: UIColor,
itemBackgroundColor: UIColor,
pinnedItemBackgroundColor: UIColor,
itemHighlightedBackgroundColor: UIColor,
itemSelectedBackgroundColor: UIColor,
titleColor: UIColor,
secretTitleColor: UIColor,
dateTextColor: UIColor,
authorNameColor: UIColor,
messageTextColor: UIColor,
messageHighlightedTextColor: UIColor,
messageDraftTextColor: UIColor,
checkmarkColor: UIColor,
pendingIndicatorColor: UIColor,
failedFillColor: UIColor,
failedForegroundColor: UIColor,
muteIconColor: UIColor,
unreadBadgeActiveBackgroundColor: UIColor,
unreadBadgeActiveTextColor: UIColor,
unreadBadgeInactiveBackgroundColor: UIColor,
unreadBadgeInactiveTextColor: UIColor,
reactionBadgeActiveBackgroundColor: UIColor,
pinnedBadgeColor: UIColor,
pinnedSearchBarColor: UIColor,
regularSearchBarColor: UIColor,
sectionHeaderFillColor: UIColor,
sectionHeaderTextColor: UIColor,
verifiedIconFillColor: UIColor,
verifiedIconForegroundColor: UIColor,
secretIconColor: UIColor,
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors,
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors,
onlineDotColor: UIColor
) {
self.backgroundColor = backgroundColor
self.itemSeparatorColor = itemSeparatorColor
self.itemBackgroundColor = itemBackgroundColor
@ -604,6 +640,7 @@ public final class PresentationThemeChatList {
self.unreadBadgeActiveTextColor = unreadBadgeActiveTextColor
self.unreadBadgeInactiveBackgroundColor = unreadBadgeInactiveBackgroundColor
self.unreadBadgeInactiveTextColor = unreadBadgeInactiveTextColor
self.reactionBadgeActiveBackgroundColor = reactionBadgeActiveBackgroundColor
self.pinnedBadgeColor = pinnedBadgeColor
self.pinnedSearchBarColor = pinnedSearchBarColor
self.regularSearchBarColor = regularSearchBarColor
@ -617,8 +654,78 @@ public final class PresentationThemeChatList {
self.onlineDotColor = onlineDotColor
}
public func withUpdated(backgroundColor: UIColor? = nil, itemSeparatorColor: UIColor? = nil, itemBackgroundColor: UIColor? = nil, pinnedItemBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, itemSelectedBackgroundColor: UIColor? = nil, titleColor: UIColor? = nil, secretTitleColor: UIColor? = nil, dateTextColor: UIColor? = nil, authorNameColor: UIColor? = nil, messageTextColor: UIColor? = nil, messageHighlightedTextColor: UIColor? = nil, messageDraftTextColor: UIColor? = nil, checkmarkColor: UIColor? = nil, pendingIndicatorColor: UIColor? = nil, failedFillColor: UIColor? = nil, failedForegroundColor: UIColor? = nil, muteIconColor: UIColor? = nil, unreadBadgeActiveBackgroundColor: UIColor? = nil, unreadBadgeActiveTextColor: UIColor? = nil, unreadBadgeInactiveBackgroundColor: UIColor? = nil, unreadBadgeInactiveTextColor: UIColor? = nil, pinnedBadgeColor: UIColor? = nil, pinnedSearchBarColor: UIColor? = nil, regularSearchBarColor: UIColor? = nil, sectionHeaderFillColor: UIColor? = nil, sectionHeaderTextColor: UIColor? = nil, verifiedIconFillColor: UIColor? = nil, verifiedIconForegroundColor: UIColor? = nil, secretIconColor: UIColor? = nil, pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil, unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil, onlineDotColor: UIColor? = nil) -> PresentationThemeChatList {
return PresentationThemeChatList(backgroundColor: backgroundColor ?? self.backgroundColor, itemSeparatorColor: itemSeparatorColor ?? self.itemSeparatorColor, itemBackgroundColor: itemBackgroundColor ?? self.itemBackgroundColor, pinnedItemBackgroundColor: pinnedItemBackgroundColor ?? self.pinnedItemBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, itemSelectedBackgroundColor: itemSelectedBackgroundColor ?? self.itemSelectedBackgroundColor, titleColor: titleColor ?? self.titleColor, secretTitleColor: secretTitleColor ?? self.secretTitleColor, dateTextColor: dateTextColor ?? self.dateTextColor, authorNameColor: authorNameColor ?? self.authorNameColor, messageTextColor: messageTextColor ?? self.messageTextColor, messageHighlightedTextColor: messageHighlightedTextColor ?? self.messageHighlightedTextColor, messageDraftTextColor: messageDraftTextColor ?? self.messageDraftTextColor, checkmarkColor: checkmarkColor ?? self.checkmarkColor, pendingIndicatorColor: pendingIndicatorColor ?? self.pendingIndicatorColor, failedFillColor: failedFillColor ?? self.failedFillColor, failedForegroundColor: failedForegroundColor ?? self.failedForegroundColor, muteIconColor: muteIconColor ?? self.muteIconColor, unreadBadgeActiveBackgroundColor: unreadBadgeActiveBackgroundColor ?? self.unreadBadgeActiveBackgroundColor, unreadBadgeActiveTextColor: unreadBadgeActiveTextColor ?? self.unreadBadgeActiveTextColor, unreadBadgeInactiveBackgroundColor: unreadBadgeInactiveBackgroundColor ?? self.unreadBadgeInactiveBackgroundColor, unreadBadgeInactiveTextColor: unreadBadgeInactiveTextColor ?? self.unreadBadgeInactiveTextColor, pinnedBadgeColor: pinnedBadgeColor ?? self.pinnedBadgeColor, pinnedSearchBarColor: pinnedSearchBarColor ?? self.pinnedSearchBarColor, regularSearchBarColor: regularSearchBarColor ?? self.regularSearchBarColor, sectionHeaderFillColor: sectionHeaderFillColor ?? self.sectionHeaderFillColor, sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor, verifiedIconFillColor: verifiedIconFillColor ?? self.verifiedIconFillColor, verifiedIconForegroundColor: verifiedIconForegroundColor ?? self.verifiedIconForegroundColor, secretIconColor: secretIconColor ?? self.secretIconColor, pinnedArchiveAvatarColor: pinnedArchiveAvatarColor ?? self.pinnedArchiveAvatarColor, unpinnedArchiveAvatarColor: unpinnedArchiveAvatarColor ?? self.unpinnedArchiveAvatarColor, onlineDotColor: onlineDotColor ?? self.onlineDotColor)
public func withUpdated(
backgroundColor: UIColor? = nil,
itemSeparatorColor: UIColor? = nil,
itemBackgroundColor: UIColor? = nil,
pinnedItemBackgroundColor: UIColor? = nil,
itemHighlightedBackgroundColor: UIColor? = nil,
itemSelectedBackgroundColor: UIColor? = nil,
titleColor: UIColor? = nil,
secretTitleColor: UIColor? = nil,
dateTextColor: UIColor? = nil,
authorNameColor: UIColor? = nil,
messageTextColor: UIColor? = nil,
messageHighlightedTextColor: UIColor? = nil,
messageDraftTextColor: UIColor? = nil,
checkmarkColor: UIColor? = nil,
pendingIndicatorColor: UIColor? = nil,
failedFillColor: UIColor? = nil,
failedForegroundColor: UIColor? = nil,
muteIconColor: UIColor? = nil,
unreadBadgeActiveBackgroundColor: UIColor? = nil,
unreadBadgeActiveTextColor: UIColor? = nil,
unreadBadgeInactiveBackgroundColor: UIColor? = nil,
unreadBadgeInactiveTextColor: UIColor? = nil,
reactionBadgeActiveBackgroundColor: UIColor? = nil,
pinnedBadgeColor: UIColor? = nil,
pinnedSearchBarColor: UIColor? = nil,
regularSearchBarColor: UIColor? = nil,
sectionHeaderFillColor: UIColor? = nil,
sectionHeaderTextColor: UIColor? = nil,
verifiedIconFillColor: UIColor? = nil,
verifiedIconForegroundColor: UIColor? = nil,
secretIconColor: UIColor? = nil,
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil,
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil,
onlineDotColor: UIColor? = nil
) -> PresentationThemeChatList {
return PresentationThemeChatList(
backgroundColor: backgroundColor ?? self.backgroundColor,
itemSeparatorColor: itemSeparatorColor ?? self.itemSeparatorColor,
itemBackgroundColor: itemBackgroundColor ?? self.itemBackgroundColor,
pinnedItemBackgroundColor: pinnedItemBackgroundColor ?? self.pinnedItemBackgroundColor,
itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor,
itemSelectedBackgroundColor: itemSelectedBackgroundColor ?? self.itemSelectedBackgroundColor,
titleColor: titleColor ?? self.titleColor,
secretTitleColor: secretTitleColor ?? self.secretTitleColor,
dateTextColor: dateTextColor ?? self.dateTextColor,
authorNameColor: authorNameColor ?? self.authorNameColor,
messageTextColor: messageTextColor ?? self.messageTextColor,
messageHighlightedTextColor: messageHighlightedTextColor ?? self.messageHighlightedTextColor,
messageDraftTextColor: messageDraftTextColor ?? self.messageDraftTextColor,
checkmarkColor: checkmarkColor ?? self.checkmarkColor,
pendingIndicatorColor: pendingIndicatorColor ?? self.pendingIndicatorColor,
failedFillColor: failedFillColor ?? self.failedFillColor,
failedForegroundColor: failedForegroundColor ?? self.failedForegroundColor,
muteIconColor: muteIconColor ?? self.muteIconColor,
unreadBadgeActiveBackgroundColor: unreadBadgeActiveBackgroundColor ?? self.unreadBadgeActiveBackgroundColor,
unreadBadgeActiveTextColor: unreadBadgeActiveTextColor ?? self.unreadBadgeActiveTextColor,
unreadBadgeInactiveBackgroundColor: unreadBadgeInactiveBackgroundColor ?? self.unreadBadgeInactiveBackgroundColor,
unreadBadgeInactiveTextColor: unreadBadgeInactiveTextColor ?? self.unreadBadgeInactiveTextColor,
reactionBadgeActiveBackgroundColor: reactionBadgeActiveBackgroundColor ?? self.reactionBadgeActiveBackgroundColor,
pinnedBadgeColor: pinnedBadgeColor ?? self.pinnedBadgeColor,
pinnedSearchBarColor: pinnedSearchBarColor ?? self.pinnedSearchBarColor,
regularSearchBarColor: regularSearchBarColor ?? self.regularSearchBarColor,
sectionHeaderFillColor: sectionHeaderFillColor ?? self.sectionHeaderFillColor,
sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor,
verifiedIconFillColor: verifiedIconFillColor ?? self.verifiedIconFillColor,
verifiedIconForegroundColor: verifiedIconForegroundColor ?? self.verifiedIconForegroundColor,
secretIconColor: secretIconColor ?? self.secretIconColor,
pinnedArchiveAvatarColor: pinnedArchiveAvatarColor ?? self.pinnedArchiveAvatarColor,
unpinnedArchiveAvatarColor: unpinnedArchiveAvatarColor ?? self.unpinnedArchiveAvatarColor,
onlineDotColor: onlineDotColor ?? self.onlineDotColor
)
}
}

View File

@ -977,6 +977,7 @@ extension PresentationThemeChatList: Codable {
case unreadBadgeActiveText
case unreadBadgeInactiveBg
case unreadBadgeInactiveText
case reactionBadgeActiveBg
case pinnedBadge
case pinnedSearchBar
case regularSearchBar
@ -992,6 +993,7 @@ extension PresentationThemeChatList: Codable {
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(backgroundColor: try decodeColor(values, .bg),
itemSeparatorColor: try decodeColor(values, .itemSeparator),
itemBackgroundColor: try decodeColor(values, .itemBg),
@ -1014,6 +1016,7 @@ extension PresentationThemeChatList: Codable {
unreadBadgeActiveTextColor: try decodeColor(values, .unreadBadgeActiveText),
unreadBadgeInactiveBackgroundColor: try decodeColor(values, .unreadBadgeInactiveBg),
unreadBadgeInactiveTextColor: try decodeColor(values, .unreadBadgeInactiveText),
reactionBadgeActiveBackgroundColor: try decodeColor(values, .reactionBadgeActiveBg, fallbackKey: "\(codingPath).unreadBadgeActiveBg"),
pinnedBadgeColor: try decodeColor(values, .pinnedBadge),
pinnedSearchBarColor: try decodeColor(values, .pinnedSearchBar),
regularSearchBarColor: try decodeColor(values, .regularSearchBar),
@ -1051,6 +1054,7 @@ extension PresentationThemeChatList: Codable {
try encodeColor(&values, self.unreadBadgeActiveTextColor, .unreadBadgeActiveText)
try encodeColor(&values, self.unreadBadgeInactiveBackgroundColor, .unreadBadgeInactiveBg)
try encodeColor(&values, self.unreadBadgeInactiveTextColor, .unreadBadgeInactiveText)
try encodeColor(&values, self.reactionBadgeActiveBackgroundColor, .reactionBadgeActiveBg)
try encodeColor(&values, self.pinnedBadgeColor, .pinnedBadge)
try encodeColor(&values, self.pinnedSearchBarColor, .pinnedSearchBar)
try encodeColor(&values, self.regularSearchBarColor, .regularSearchBar)

View File

@ -20,11 +20,15 @@ private func generateStatusCheckImage(theme: PresentationTheme, single: Bool) ->
})
}
private func generateBadgeBackgroundImage(theme: PresentationTheme, diameter: CGFloat, active: Bool, icon: UIImage? = nil) -> UIImage? {
private func generateBadgeBackgroundImage(theme: PresentationTheme, diameter: CGFloat, active: Bool, reaction: Bool, icon: UIImage? = nil) -> UIImage? {
return generateImage(CGSize(width: diameter, height: diameter), contextGenerator: { size, context in
context.clear(CGRect(origin: CGPoint(), size: size))
if active {
context.setFillColor(theme.chatList.unreadBadgeActiveBackgroundColor.cgColor)
if reaction {
context.setFillColor(theme.chatList.reactionBadgeActiveBackgroundColor.cgColor)
} else {
context.setFillColor(theme.chatList.unreadBadgeActiveBackgroundColor.cgColor)
}
} else {
context.setFillColor(theme.chatList.unreadBadgeInactiveBackgroundColor.cgColor)
}
@ -173,37 +177,37 @@ public struct PresentationResourcesChatList {
public static func badgeBackgroundActive(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.chatListBadgeBackgroundActive(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true)
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true, reaction: false)
})
}
public static func badgeBackgroundInactive(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.chatListBadgeBackgroundInactive(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false)
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false, reaction: false)
})
}
public static func badgeBackgroundMention(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.chatListBadgeBackgroundMention(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/MentionBadgeIcon"), color: theme.chatList.unreadBadgeActiveTextColor))
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true, reaction: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/MentionBadgeIcon"), color: theme.chatList.unreadBadgeActiveTextColor))
})
}
public static func badgeBackgroundInactiveMention(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.chatListBadgeBackgroundInactiveMention(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/MentionBadgeIcon"), color: theme.chatList.unreadBadgeInactiveTextColor))
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false, reaction: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/MentionBadgeIcon"), color: theme.chatList.unreadBadgeInactiveTextColor))
})
}
public static func badgeBackgroundReactions(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.badgeBackgroundReactions(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/ReactionsBadgeIcon"), color: theme.chatList.unreadBadgeActiveTextColor))
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: true, reaction: true, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/ReactionsBadgeIcon"), color: theme.chatList.unreadBadgeActiveTextColor))
})
}
public static func badgeBackgroundInactiveReactions(_ theme: PresentationTheme, diameter: CGFloat) -> UIImage? {
return theme.image(PresentationResourceParameterKey.badgeBackgroundInactiveReactions(diameter), { theme in
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/ReactionsBadgeIcon"), color: theme.chatList.unreadBadgeInactiveTextColor))
return generateBadgeBackgroundImage(theme: theme, diameter: diameter, active: false, reaction: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/ReactionsBadgeIcon"), color: theme.chatList.unreadBadgeInactiveTextColor))
})
}