mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '1f4ab01e6555184552ea11bba71fca5f88ec8374'
This commit is contained in:
commit
a502867bdd
@ -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)
|
||||
}
|
||||
})
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user