diff --git a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift index 74d7524433..a5bdc906ea 100644 --- a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift +++ b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift @@ -11,7 +11,7 @@ public final class AudioTranscriptionButtonComponent: Component { public static func == (lhs: AudioTranscriptionButtonComponent.Theme, rhs: AudioTranscriptionButtonComponent.Theme) -> Bool { switch lhs { case let .bubble(lhsTheme): - if case let .bubble(rhsTheme) = lhs { + if case let .bubble(rhsTheme) = rhs { return lhsTheme === rhsTheme } else { return false diff --git a/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift index 73f5a25956..9c4d7719f6 100644 --- a/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift @@ -28,6 +28,7 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { private let backgroundMaskNode: ASImageNode private var linkHighlightingNode: LinkHighlightingNode? + private var mediaBackgroundContent: WallpaperBubbleBackgroundNode? private let mediaBackgroundNode: NavigationBackgroundNode private let titleNode: TextNode private let subtitleNode: TextNode @@ -233,7 +234,7 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { let imageFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((backgroundSize.width - giftSize.width) / 2.0), y: labelLayout.size.height + 16.0), size: giftSize) let mediaBackgroundFrame = imageFrame.insetBy(dx: -2.0, dy: -2.0) strongSelf.mediaBackgroundNode.frame = mediaBackgroundFrame - + strongSelf.mediaBackgroundNode.updateColor(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), transition: .immediate) strongSelf.mediaBackgroundNode.update(size: mediaBackgroundFrame.size, transition: .immediate) strongSelf.buttonNode.backgroundColor = item.presentationData.theme.theme.overallDarkAppearance ? UIColor(rgb: 0xffffff, alpha: 0.12) : UIColor(rgb: 0x000000, alpha: 0.12) @@ -263,6 +264,24 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { strongSelf.buttonNode.frame = CGRect(origin: CGPoint(x: mediaBackgroundFrame.minX + floorToScreenPixels((mediaBackgroundFrame.width - buttonSize.width) / 2.0), y: subtitleFrame.maxY + 10.0), size: buttonSize) strongSelf.buttonStarsNode.frame = CGRect(origin: .zero, size: buttonSize) + if item.controllerInteraction.presentationContext.backgroundNode?.hasExtraBubbleBackground() == true { + if strongSelf.mediaBackgroundContent == nil, let backgroundContent = item.controllerInteraction.presentationContext.backgroundNode?.makeBubbleBackground(for: .free) { + strongSelf.mediaBackgroundNode.isHidden = true + backgroundContent.clipsToBounds = true + backgroundContent.allowsGroupOpacity = true + backgroundContent.cornerRadius = 24.0 + + strongSelf.mediaBackgroundContent = backgroundContent + strongSelf.insertSubnode(backgroundContent, at: 0) + } + + strongSelf.mediaBackgroundContent?.frame = mediaBackgroundFrame + } else { + strongSelf.mediaBackgroundNode.isHidden = false + strongSelf.mediaBackgroundContent?.removeFromSupernode() + strongSelf.mediaBackgroundContent = nil + } + let baseBackgroundFrame = labelFrame.offsetBy(dx: 0.0, dy: -11.0) if let (offset, image) = backgroundMaskImage { if strongSelf.backgroundNode == nil { @@ -287,9 +306,6 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { if let backgroundNode = strongSelf.backgroundNode { backgroundNode.frame = CGRect(origin: CGPoint(x: baseBackgroundFrame.minX + offset.x, y: baseBackgroundFrame.minY + offset.y), size: image.size) - if let (rect, size) = strongSelf.absoluteRect { - strongSelf.updateAbsoluteRect(rect, within: size) - } } strongSelf.backgroundMaskNode.image = image strongSelf.backgroundMaskNode.frame = CGRect(origin: CGPoint(), size: image.size) @@ -297,6 +313,9 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { strongSelf.cachedMaskBackgroundImage = (offset, image, labelRects) } + if let (rect, size) = strongSelf.absoluteRect { + strongSelf.updateAbsoluteRect(rect, within: size) + } } }) }) @@ -306,6 +325,13 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { override func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) { self.absoluteRect = (rect, containerSize) + + if let mediaBackgroundContent = self.mediaBackgroundContent { + var backgroundFrame = mediaBackgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += rect.minY + mediaBackgroundContent.update(rect: backgroundFrame, within: containerSize, transition: .immediate) + } if let backgroundNode = self.backgroundNode { var backgroundFrame = backgroundNode.frame diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift index 64d8542df0..f0cb9b3d92 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift @@ -1479,13 +1479,17 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { foregroundNodeColor = .white } else { backgroundNodeColor = messageTheme.mediaActiveControlColor - foregroundNodeColor = .clear + if incoming && messageTheme.mediaActiveControlColor.rgb != 0xffffff { + foregroundNodeColor = .white + } else { + foregroundNodeColor = .clear + } } if state != .none && self.statusNode == nil { var image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>? = nil - if file.isMusic { + if file.isMusic || file.isInstantVideo { if file.fileName?.lowercased().hasSuffix(".ogg") == true { } else { var title: String? diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index 2457223a86..83dc46b817 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -1099,11 +1099,17 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode } } + private var isAnimating = false private var isLooping = false func animateEvent(transition: ContainedViewLayoutTransition, extendAnimation: Bool) { + guard !(self.isLooping && self.isAnimating) else { + return + } + self.isAnimating = true self.gradientBackgroundNode?.animateEvent(transition: transition, extendAnimation: extendAnimation, backwards: false, completion: { [weak self] in if let strongSelf = self { + strongSelf.isAnimating = false if strongSelf.isLooping { strongSelf.animateEvent(transition: transition, extendAnimation: extendAnimation) } @@ -1946,16 +1952,19 @@ final class WallpaperBackgroundNodeMergedImpl: ASDisplayNode, WallpaperBackgroun private var isLooping = false func animateEvent(transition: ContainedViewLayoutTransition, extendAnimation: Bool) { if let gradient = self.gradient { + guard !(self.isLooping && self.isAnimating) else { + return + } self.isAnimating = true self.componentsUpdated() gradient.gradientBackground.animateEvent(transition: transition, extendAnimation: extendAnimation, backwards: false, completion: { [weak self] in guard let strongSelf = self else { return } + strongSelf.isAnimating = false if strongSelf.isLooping { strongSelf.animateEvent(transition: transition, extendAnimation: extendAnimation) } else { - strongSelf.isAnimating = false strongSelf.componentsUpdated() } })