diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index eb5f007d65..f36990b98a 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -1205,7 +1205,11 @@ private final class GroupExpandActionButton: UIButton { self.currentTextLayout = (title, color, textConstrainedWidth, textSize) } - let size = CGSize(width: textSize.width + 10.0 * 2.0, height: 28.0) + var sideInset: CGFloat = 10.0 + if textSize.width > 24.0 { + sideInset = 6.0 + } + let size = CGSize(width: textSize.width + sideInset * 2.0, height: 28.0) let textFrame = CGRect(origin: CGPoint(x: floor((size.width - textSize.width) / 2.0), y: floor((size.height - textSize.height) / 2.0)), size: textSize) self.textLayer.frame = textFrame @@ -2834,6 +2838,7 @@ public final class EmojiPagerContentComponent: Component { let groupHeaderPoint = self.scrollView.convert(locationInScrollView, to: groupHeader) if let clearIconLayer = groupHeader.clearIconLayer, clearIconLayer.frame.insetBy(dx: -4.0, dy: -4.0).contains(groupHeaderPoint) { component.inputInteractionHolder.inputInteraction?.clearGroup(id) + return } else { if groupHeader.tapGesture(recognizer) { return @@ -3019,8 +3024,16 @@ public final class EmojiPagerContentComponent: Component { let contentAnimation = transition.userData(ContentAnimation.self) var transitionHintInstalledGroupId: AnyHashable? - if let contentAnimation = contentAnimation, case let .groupInstalled(groupId) = contentAnimation.type { - transitionHintInstalledGroupId = groupId + var transitionHintExpandedGroupId: AnyHashable? + if let contentAnimation = contentAnimation { + switch contentAnimation.type { + case let .groupInstalled(groupId): + transitionHintInstalledGroupId = groupId + case let .groupExpanded(groupId): + transitionHintExpandedGroupId = groupId + default: + break + } } for groupItems in itemLayout.visibleItems(for: effectiveVisibleBounds) { @@ -3504,8 +3517,19 @@ public final class EmojiPagerContentComponent: Component { for (id, button) in self.visibleGroupExpandActionButtons { if !validGroupExpandActionButtons.contains(id) { removedGroupExpandActionButtonIds.append(id) - button.removeFromSuperview() - button.tintContainerLayer.removeFromSuperlayer() + + if !transition.animation.isImmediate && transitionHintExpandedGroupId == id { + button.alpha = 0.0 + button.layer.animateScale(from: 1.0, to: 0.5, duration: 0.2) + let tintContainerLayer = button.tintContainerLayer + button.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak button, weak tintContainerLayer] _ in + button?.removeFromSuperview() + tintContainerLayer?.removeFromSuperlayer() + }) + } else { + button.removeFromSuperview() + button.tintContainerLayer.removeFromSuperlayer() + } } } for id in removedGroupExpandActionButtonIds { diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift index 9028825dd1..694a8b0956 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift @@ -700,7 +700,7 @@ final class EntityKeyboardStaticStickersPanelComponent: Component { for i in 0 ..< items.count { if AnyHashable(items[i].rawValue) == scrollToItem { let itemFrame = itemLayout.frame(at: i) - self.scrollView.scrollRectToVisible(itemFrame.insetBy(dx: -itemLayout.sideInset, dy: 0.0), animated: true) + self.scrollView.scrollRectToVisible(itemFrame.insetBy(dx: -itemLayout.sideInset - (itemLayout.itemSpacing + itemFrame.width) * 2.0, dy: 0.0), animated: true) break } } @@ -1898,7 +1898,13 @@ final class EntityKeyboardTopPanelComponent: Component { for i in 0 ..< component.items.count { if component.items[i].id == itemId { let itemFrame = itemLayout.containerFrame(at: i) - self.scrollView.scrollRectToVisible(itemFrame.insetBy(dx: -2.0, dy: 0.0), animated: true) + let expandedInset: CGFloat + if itemLayout.isExpanded { + expandedInset = -2.0 + } else { + expandedInset = -itemLayout.sideInset - (itemFrame.width + itemLayout.itemSpacing) * 2.0 + } + self.scrollView.scrollRectToVisible(itemFrame.insetBy(dx: expandedInset, dy: 0.0), animated: true) break } } diff --git a/submodules/TelegramUI/Components/MultiAnimationRenderer/Sources/MultiAnimationRenderer.swift b/submodules/TelegramUI/Components/MultiAnimationRenderer/Sources/MultiAnimationRenderer.swift index 126894163b..85d5dc1f55 100644 --- a/submodules/TelegramUI/Components/MultiAnimationRenderer/Sources/MultiAnimationRenderer.swift +++ b/submodules/TelegramUI/Components/MultiAnimationRenderer/Sources/MultiAnimationRenderer.swift @@ -535,26 +535,37 @@ public final class MultiAnimationRendererImpl: MultiAnimationRenderer { private var groupContext: GroupContext? private var frameSkip: Int - private var displayLink: ConstantDisplayLinkAnimator? + private var displayTimer: Foundation.Timer? private(set) var isPlaying: Bool = false { didSet { if self.isPlaying != oldValue { if self.isPlaying { - if self.displayLink == nil { - self.displayLink = ConstantDisplayLinkAnimator { [weak self] in + if self.displayTimer == nil { + final class TimerTarget: NSObject { + private let f: () -> Void + + init(_ f: @escaping () -> Void) { + self.f = f + } + + @objc func timerEvent() { + self.f() + } + } + let displayTimer = Foundation.Timer(timeInterval: CGFloat(self.frameSkip) / 60.0, target: TimerTarget { [weak self] in guard let strongSelf = self else { return } strongSelf.animationTick() - } - self.displayLink?.frameInterval = self.frameSkip - self.displayLink?.isPaused = false + }, selector: #selector(TimerTarget.timerEvent), userInfo: nil, repeats: true) + self.displayTimer = displayTimer + RunLoop.main.add(displayTimer, forMode: .common) } } else { - if let displayLink = self.displayLink { - self.displayLink = nil - displayLink.invalidate() + if let displayTimer = self.displayTimer { + self.displayTimer = nil + displayTimer.invalidate() } } } diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift index b4dc54ec9c..4971c3243e 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift @@ -376,7 +376,9 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee switch attribute { case let .CustomEmoji(_, alt, _): if !alt.isEmpty, let keyword = allEmoticons[alt] { - result.append((alt, item.file, keyword)) + if !item.file.isPremiumEmoji || hasPremium { + result.append((alt, item.file, keyword)) + } } default: break diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 928cadb6c7..6d5a77b118 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -60,11 +60,11 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode { self.addSubnode(self.iconImageNode) switch item { - case .input, .botInput: - self.iconImageNode.isHidden = true - self.animationView = ComponentView() - default: - break + case .input, .botInput: + self.iconImageNode.isHidden = true + self.animationView = ComponentView() + default: + break } if let text = text { @@ -84,9 +84,11 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode { if highlighted { strongSelf.layer.removeAnimation(forKey: "opacity") strongSelf.alpha = 0.4 + strongSelf.layer.allowsGroupOpacity = true } else { strongSelf.alpha = 1.0 strongSelf.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2) + strongSelf.layer.allowsGroupOpacity = false } } } @@ -269,7 +271,7 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode { var colors: [String: UIColor] = [:] for colorKey in colorKeys { - colors[colorKey] = self.theme.chat.inputPanel.inputControlColor + colors[colorKey] = self.theme.chat.inputPanel.inputControlColor.blitOver(self.theme.chat.inputPanel.inputBackgroundColor, alpha: 1.0) } let _ = animationView.update(