Merge commit '1f4ab01e6555184552ea11bba71fca5f88ec8374'

This commit is contained in:
Ilya Laktyushin 2022-01-29 01:07:34 +03:00
commit a502867bdd
3 changed files with 24 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import Emoji
private let deletedIcon = UIImage(bundleImageName: "Avatar/DeletedIcon")?.precomposed()
private let phoneIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/PhoneIcon"), color: .white)
private let savedMessagesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/SavedMessagesIcon"), color: .white)
public let savedMessagesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/SavedMessagesIcon"), color: .white)
private let archivedChatsIcon = UIImage(bundleImageName: "Avatar/ArchiveAvatarIcon")?.precomposed()
private let repliesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/RepliesMessagesIcon"), color: .white)
@ -683,7 +683,7 @@ public enum AvatarBackgroundColor {
case violet
}
public func generateAvatarImage(size: CGSize, icon: UIImage?, color: AvatarBackgroundColor) -> UIImage? {
public func generateAvatarImage(size: CGSize, icon: UIImage?, iconScale: CGFloat = 1.0, color: AvatarBackgroundColor) -> UIImage? {
return generateImage(size, rotatedContext: { size, context in
context.clear(CGRect(origin: CGPoint(), size: size))
context.beginPath()
@ -730,7 +730,8 @@ public func generateAvatarImage(size: CGSize, icon: UIImage?, color: AvatarBackg
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
if let icon = icon {
let iconFrame = CGRect(origin: CGPoint(x: floor((size.width - icon.size.width) / 2.0), y: floor((size.height - icon.size.height) / 2.0)), size: icon.size)
let iconSize = CGSize(width: icon.size.width * iconScale, height: icon.size.height * iconScale)
let iconFrame = CGRect(origin: CGPoint(x: floor((size.width - iconSize.width) / 2.0), y: floor((size.height - iconSize.height) / 2.0)), size: iconSize)
context.draw(icon.cgImage!, in: iconFrame)
}
})

View File

@ -8547,7 +8547,24 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var items: [ContextMenuItem] = []
for peer in peers {
items.append(.action(ContextMenuActionItem(text: EnginePeer(peer).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), icon: { _ in return nil }, iconSource: ContextMenuActionItemIconSource(size: avatarSize, signal: peerAvatarCompleteImage(account: strongSelf.context.account, peer: EnginePeer(peer), size: avatarSize)), action: { _, f in
let title: String
let iconSource: ContextMenuActionItemIconSource?
if peer.id == strongSelf.context.account.peerId {
title = strongSelf.presentationData.strings.DialogList_SavedMessages
iconSource = nil
} else {
title = EnginePeer(peer).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)
iconSource = ContextMenuActionItemIconSource(size: avatarSize, signal: peerAvatarCompleteImage(account: strongSelf.context.account, peer: EnginePeer(peer), size: avatarSize))
}
let isSavedMessages = peer.id == strongSelf.context.account.peerId
items.append(.action(ContextMenuActionItem(text: title, icon: { _ in
if isSavedMessages {
return generateAvatarImage(size: avatarSize, icon: savedMessagesIcon, iconScale: 0.5, color: .blue)
}
return nil
}, iconSource: iconSource, action: { _, f in
f(.default)
guard let strongSelf = self, let navigationController = strongSelf.effectiveNavigationController else {

View File

@ -138,9 +138,9 @@ class ChatHistoryNavigationButtonNode: ContextControllerSourceNode {
let badgeSize = self.badgeTextNode.measure(CGSize(width: 200.0, height: 100.0))
let backgroundSize = CGSize(width: max(18.0, badgeSize.width + 10.0 + 1.0), height: 18.0)
let backgroundFrame = CGRect(origin: CGPoint(x: floor((38.0 - backgroundSize.width) / 2.0), y: -6.0), size: backgroundSize)
let backgroundFrame = CGRect(origin: CGPoint(x: floor((38.0 - backgroundSize.width) / 2.0), y: -9.0), size: backgroundSize)
self.badgeBackgroundNode.frame = backgroundFrame
self.badgeTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels(backgroundFrame.midX - badgeSize.width / 2.0), y: -5.0), size: badgeSize)
self.badgeTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels(backgroundFrame.midX - badgeSize.width / 2.0), y: -8.0), size: badgeSize)
} else {
self.badgeBackgroundNode.isHidden = true
self.badgeTextNode.isHidden = true