Improve pic display for ads

This commit is contained in:
Ilya Laktyushin 2024-03-29 18:30:56 +04:00
parent 651c57a010
commit 03e318fef3
4 changed files with 13 additions and 3 deletions

View File

@ -1089,7 +1089,14 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
if let (titleBadgeLayout, titleBadgeApply) = titleBadgeLayoutAndApply {
let titleBadgeLabel = titleBadgeApply()
let titleBadgeFrame = CGRect(origin: CGPoint(x: titleFrame.maxX + titleBadgeSpacing + titleBadgePadding, y: floorToScreenPixels(titleFrame.midY - titleBadgeLayout.size.height / 2.0)), size: titleBadgeLayout.size)
var titleLineWidth: CGFloat = 0.0
if let firstLine = titleLayout.linesRects().first {
titleLineWidth = firstLine.width
} else {
titleLineWidth = titleFrame.width
}
let titleBadgeFrame = CGRect(origin: CGPoint(x: titleFrame.minX + titleLineWidth + titleBadgeSpacing + titleBadgePadding, y: floorToScreenPixels(titleFrame.midY - titleBadgeLayout.size.height / 2.0)), size: titleBadgeLayout.size)
let badgeBackgroundFrame = titleBadgeFrame.insetBy(dx: -titleBadgePadding, dy: -1.0 + UIScreenPixel)
let button: HighlightTrackingButtonNode

View File

@ -1415,7 +1415,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
ignoreForward = true
effectiveAuthor = author
displayAuthorInfo = !mergedTop.merged && incoming
hasAvatar = adAttribute.displayAvatar
hasAvatar = adAttribute.displayAvatar && !adAttribute.canReport
} else {
effectiveAuthor = firstMessage.author

View File

@ -341,7 +341,7 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
}
if let adAttribute = message.adAttribute {
if adAttribute.displayAvatar {
if adAttribute.displayAvatar && !adAttribute.canReport {
hasAvatar = adAttribute.displayAvatar
}
}

View File

@ -510,6 +510,9 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
break
}
}
if adAttribute.displayAvatar && adAttribute.canReport, let profileImage = item.message.author?.smallProfileImage {
mediaAndFlags = (TelegramMediaImage(imageId: MediaId(namespace: 0, id: 0), representations: [profileImage], immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: []), [.preferMediaInline])
}
if adAttribute.canReport {
titleBadge = item.presentationData.strings.Message_AdWhatIsThis