diff --git a/submodules/RadialStatusNode/Sources/RadialStatusNode.swift b/submodules/RadialStatusNode/Sources/RadialStatusNode.swift index 2aa3acba77..18cb2f7ac7 100644 --- a/submodules/RadialStatusNode/Sources/RadialStatusNode.swift +++ b/submodules/RadialStatusNode/Sources/RadialStatusNode.swift @@ -243,18 +243,21 @@ public final class RadialStatusNode: ASControlNode { } private let enableBlur: Bool - + private let isPreview: Bool + public private(set) var state: RadialStatusNodeState = .none + private var staticBackgroundNode: ASImageNode? private var backgroundNode: NavigationBackgroundNode? private var currentBackgroundNodeColor: UIColor? private var contentNode: RadialStatusContentNode? private var nextContentNode: RadialStatusContentNode? - public init(backgroundNodeColor: UIColor, enableBlur: Bool = false) { - self.enableBlur = enableBlur + public init(backgroundNodeColor: UIColor, enableBlur: Bool = false, isPreview: Bool = false) { self.backgroundNodeColor = backgroundNodeColor + self.enableBlur = enableBlur + self.isPreview = isPreview super.init() } @@ -325,6 +328,7 @@ public final class RadialStatusNode: ASControlNode { } else { self.contentNode = node if let contentNode = self.contentNode { + contentNode.displaysAsynchronously = self.displaysAsynchronously contentNode.frame = self.bounds contentNode.prepareAnimateIn(from: nil) self.addSubnode(contentNode) @@ -354,27 +358,40 @@ public final class RadialStatusNode: ASControlNode { if updated { if let color = color { - if let backgroundNode = self.backgroundNode { - backgroundNode.updateColor(color: color, transition: .immediate) - self.currentBackgroundNodeColor = color - - completion() - } else { - let backgroundNode = NavigationBackgroundNode(color: color, enableBlur: self.enableBlur) - self.currentBackgroundNodeColor = color - - backgroundNode.frame = self.bounds - backgroundNode.update(size: backgroundNode.bounds.size, cornerRadius: backgroundNode.bounds.size.height / 2.0, transition: .immediate) - self.backgroundNode = backgroundNode - self.insertSubnode(backgroundNode, at: 0) - - if animated { - backgroundNode.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2, removeOnCompletion: false) - backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false, completion: { _ in - completion() - }) + if self.isPreview { + let backgroundNode: ASImageNode + if let current = self.staticBackgroundNode { + backgroundNode = current } else { + backgroundNode = ASImageNode() + backgroundNode.image = generateFilledCircleImage(diameter: 50.0, color: self.backgroundNodeColor) + self.insertSubnode(backgroundNode, at: 0) + self.staticBackgroundNode = backgroundNode + } + backgroundNode.frame = self.bounds + } else { + if let backgroundNode = self.backgroundNode { + backgroundNode.updateColor(color: color, transition: .immediate) + self.currentBackgroundNodeColor = color + completion() + } else { + let backgroundNode = NavigationBackgroundNode(color: color, enableBlur: self.enableBlur) + self.currentBackgroundNodeColor = color + + backgroundNode.frame = self.bounds + backgroundNode.update(size: backgroundNode.bounds.size, cornerRadius: backgroundNode.bounds.size.height / 2.0, transition: .immediate) + self.backgroundNode = backgroundNode + self.insertSubnode(backgroundNode, at: 0) + + if animated { + backgroundNode.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2, removeOnCompletion: false) + backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false, completion: { _ in + completion() + }) + } else { + completion() + } } } } else if let backgroundNode = self.backgroundNode { diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift index 41990cf8ba..55cf43a851 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift @@ -341,8 +341,8 @@ public final class PrincipalThemeEssentialGraphics { self.clockMediaMinImage = emptyImage self.clockFreeFrameImage = emptyImage self.clockFreeMinImage = emptyImage - self.dateAndStatusMediaBackground = emptyImage - self.dateAndStatusFreeBackground = emptyImage + self.dateAndStatusMediaBackground = generateStretchableFilledCircleImage(diameter: 18.0, color: theme.message.mediaDateAndStatusFillColor)! + self.dateAndStatusFreeBackground = generateStretchableFilledCircleImage(diameter: 18.0, color: serviceColor.dateFillStatic)! let impressionCountImage = UIImage(bundleImageName: "Chat/Message/ImpressionCount")! self.incomingDateAndStatusImpressionIcon = generateTintedImage(image: impressionCountImage, color: theme.message.incoming.secondaryTextColor)! diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index b34c6c8ec8..c3a345ec04 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -2092,7 +2092,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI let statusSuggestedWidthAndContinue = mosaicStatusLayout(ChatMessageDateAndStatusNode.Arguments( context: item.context, presentationData: item.presentationData, - edited: edited, + edited: edited && !item.presentationData.isPreview, impressionCount: viewCount, dateText: dateText, type: statusType, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift index 58da9b549c..ea633f8bc0 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -1225,7 +1225,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { if progressRequired { if self.statusNode == nil { - let statusNode = RadialStatusNode(backgroundNodeColor: item.presentationData.theme.theme.chat.message.mediaOverlayControlColors.fillColor) + let statusNode = RadialStatusNode(backgroundNodeColor: item.presentationData.theme.theme.chat.message.mediaOverlayControlColors.fillColor, isPreview: item.presentationData.isPreview) statusNode.displaysAsynchronously = !item.presentationData.isPreview self.isUserInteractionEnabled = false self.statusNode = statusNode diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift index 0c7da42cdf..a0e1606dc7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift @@ -1254,7 +1254,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr uploading = true } - if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !isStory && !uploading { + if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !isStory && !uploading && !presentationData.isPreview { updateVideoFile = file if hasCurrentVideoNode { if let currentFile = currentMedia as? TelegramMediaFile { @@ -1796,6 +1796,9 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr } } } + if isPreview { + progressRequired = true + } var radialStatusSize: CGFloat if isSecretMedia { @@ -1805,7 +1808,8 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr } if progressRequired { if self.statusNode == nil { - let statusNode = RadialStatusNode(backgroundNodeColor: theme.chat.message.mediaOverlayControlColors.fillColor) + let statusNode = RadialStatusNode(backgroundNodeColor: theme.chat.message.mediaOverlayControlColors.fillColor, isPreview: isPreview) + statusNode.displaysAsynchronously = !isPreview let imageSize = self.imageNode.bounds.size statusNode.frame = CGRect(origin: CGPoint(x: floor(imageSize.width / 2.0 - radialStatusSize / 2.0), y: floor(imageSize.height / 2.0 - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) self.statusNode = statusNode @@ -1893,6 +1897,10 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr automaticPlayback = false } + if isPreview { + muted = false + } + if let actualFetchStatus = self.actualFetchStatus { if automaticPlayback || message.forwardInfo != nil { fetchStatus = actualFetchStatus @@ -2069,6 +2077,9 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr } } } + if isPreview { + state = .play(messageTheme.mediaOverlayControlColors.foregroundColor) + } if isSecretMedia { let remainingTime: Int32? @@ -2119,12 +2130,11 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr }) statusNode.backgroundNodeColor = backgroundColor } - if let badgeContent = badgeContent { + if var badgeContent = badgeContent { if self.badgeNode == nil { let badgeNode = ChatMessageInteractiveMediaBadge() if isPreview { badgeNode.durationNode.displaysAsynchronously = false - badgeNode.sizeNode?.displaysAsynchronously = false } var inset: CGFloat = 6.0 @@ -2149,6 +2159,12 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr animated = false } + if isPreview { + mediaDownloadState = nil + if case let .mediaDownload(backgroundColor, foregroundColor, duration, _ ,_ , _) = badgeContent { + badgeContent = .text(inset: 0.0, backgroundColor: backgroundColor, foregroundColor: foregroundColor, text: NSAttributedString(string: duration), iconName: nil) + } + } self.badgeNode?.update(theme: theme, content: badgeContent, mediaDownloadState: mediaDownloadState, animated: animated) } else if let badgeNode = self.badgeNode { self.badgeNode = nil diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift index ad9b53bf06..fc1418cb77 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift @@ -83,7 +83,6 @@ public final class DrawingMessageRenderer { private let containerNode: ASDisplayNode private let messagesContainerNode: ASDisplayNode - private var dateHeaderNode: ListViewItemHeaderNode? private var avatarHeaderNode: ListViewItemHeaderNode? private var messageNodes: [ListViewItemNode]? @@ -156,7 +155,6 @@ public final class DrawingMessageRenderer { let size = layout.size let theme = presentationData.theme.withUpdated(preview: true) - let dateHeaderItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: presentationData.chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder) let avatarHeaderItem = self.context.sharedContext.makeChatMessageAvatarHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, peer: self.messages.first!.peers[self.messages.first!.author!.id]!, message: self.messages.first!, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: presentationData.chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder) @@ -235,17 +233,6 @@ public final class DrawingMessageRenderer { } } - let dateHeaderNode: ListViewItemHeaderNode - if let currentDateHeaderNode = self.dateHeaderNode { - dateHeaderNode = currentDateHeaderNode - dateHeaderItem.updateNode(dateHeaderNode, previous: nil, next: dateHeaderItem) - } else { - dateHeaderNode = dateHeaderItem.node(synchronousLoad: true) - dateHeaderNode.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0) -// self.messagesContainerNode.addSubnode(dateHeaderNode) - self.dateHeaderNode = dateHeaderNode - } - let avatarHeaderNode: ListViewItemHeaderNode if let currentAvatarHeaderNode = self.avatarHeaderNode { avatarHeaderNode = currentAvatarHeaderNode @@ -256,10 +243,7 @@ public final class DrawingMessageRenderer { self.messagesContainerNode.addSubnode(avatarHeaderNode) self.avatarHeaderNode = avatarHeaderNode } - - dateHeaderNode.frame = CGRect(origin: CGPoint(x: 0.0, y: bottomOffset), size: CGSize(width: layout.size.width, height: dateHeaderItem.height)) - dateHeaderNode.updateLayout(size: size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right) - + avatarHeaderNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 3.0), size: CGSize(width: layout.size.width, height: avatarHeaderItem.height)) avatarHeaderNode.updateLayout(size: size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)