Improve round message display in link previews

This commit is contained in:
Ilya Laktyushin
2024-07-18 20:12:20 +04:00
parent cd212bd5a9
commit 9b54260171

View File

@@ -1543,7 +1543,14 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
} }
} }
let arguments = TransformImageArguments(corners: corners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments) var videoCorners = corners
var imageCorners = corners
if let file = media as? TelegramMediaFile, file.isInstantVideo {
videoCorners = ImageCorners(radius: boundingSize.width / 2.0)
imageCorners = ImageCorners(radius: 0.0)
}
let arguments = TransformImageArguments(corners: imageCorners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments)
let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid
let cleanImageFrame = CGRect(origin: imageFrame.origin, size: CGSize(width: imageFrame.width - arguments.corners.extendedEdges.right, height: imageFrame.height)) let cleanImageFrame = CGRect(origin: imageFrame.origin, size: CGSize(width: imageFrame.width - arguments.corners.extendedEdges.right, height: imageFrame.height))
@@ -1628,7 +1635,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
} }
if currentReplaceVideoNode, let updatedVideoFile = updateVideoFile { if currentReplaceVideoNode, let updatedVideoFile = updateVideoFile {
let decoration = ChatBubbleVideoDecoration(corners: arguments.corners, nativeSize: nativeSize, contentMode: contentMode.bubbleVideoDecorationContentMode, backgroundColor: arguments.emptyColor ?? .black) let decoration = ChatBubbleVideoDecoration(corners: videoCorners, nativeSize: nativeSize, contentMode: contentMode.bubbleVideoDecorationContentMode, backgroundColor: arguments.emptyColor ?? .black)
strongSelf.videoNodeDecoration = decoration strongSelf.videoNodeDecoration = decoration
let mediaManager = context.sharedContext.mediaManager let mediaManager = context.sharedContext.mediaManager
@@ -1702,8 +1709,15 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
} }
if let videoNode = strongSelf.videoNode { if let videoNode = strongSelf.videoNode {
if !(replaceVideoNode ?? false), let decoration = videoNode.decoration as? ChatBubbleVideoDecoration, decoration.corners != corners { if !(replaceVideoNode ?? false), let decoration = videoNode.decoration as? ChatBubbleVideoDecoration, decoration.corners != videoCorners {
decoration.updateCorners(corners) decoration.updateCorners(videoCorners)
}
if !videoCorners.isEmpty && imageCorners.isEmpty {
strongSelf.imageNode.clipsToBounds = true
strongSelf.imageNode.cornerRadius = videoCorners.topLeft.radius
} else {
strongSelf.imageNode.cornerRadius = 0.0
} }
videoNode.updateLayout(size: arguments.drawingSize, transition: .immediate) videoNode.updateLayout(size: arguments.drawingSize, transition: .immediate)