Fix reaction selection glitches

This commit is contained in:
Isaac 2025-07-08 18:37:19 +04:00
parent 7d3e4ece26
commit 7d5185ed4d
3 changed files with 19 additions and 15 deletions

View file

@ -42,6 +42,7 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
private let backgroundView: BlurredBackgroundView
private let backgroundTintView: UIView
private let backgroundTintMaskOuterContainer: UIView
let backgroundTintMaskContainer: UIView
let vibrantExpandedContentContainer: UIView
@ -64,6 +65,7 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
self.backgroundTintView = UIView()
self.backgroundTintMaskContainer = UIView()
self.backgroundTintMaskOuterContainer = UIView()
self.maskLayer = SimpleLayer()
self.backgroundClippingLayer = SimpleLayer()
@ -91,7 +93,8 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
}
self.vibrantExpandedContentContainer = UIView()
self.backgroundTintMaskContainer.addSubview(self.vibrantExpandedContentContainer)
self.backgroundTintMaskOuterContainer.addSubview(self.backgroundTintMaskContainer)
self.backgroundTintMaskOuterContainer.addSubview(self.vibrantExpandedContentContainer)
super.init()
@ -103,11 +106,10 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
self.largeCircleShadowLayer.opacity = 0.0
self.smallCircleShadowLayer.opacity = 0.0
self.backgroundView.addSubview(self.backgroundTintView)
self.backgroundTintMaskContainer.backgroundColor = .white
self.backgroundTintMaskOuterContainer.backgroundColor = .white
self.view.addSubview(self.backgroundView)
self.backgroundView.addSubview(self.backgroundTintView)
self.maskLayer.addSublayer(self.smallCircleLayer)
self.maskLayer.addSublayer(self.largeCircleLayer)
@ -144,17 +146,17 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
if theme.overallDarkAppearance {
if let invertFilter = CALayer.colorInvert(), let filter = CALayer.luminanceToAlpha() {
self.backgroundTintMaskContainer.layer.filters = [invertFilter, filter]
self.backgroundTintMaskOuterContainer.layer.filters = [invertFilter, filter]
}
self.backgroundTintView.mask = self.backgroundTintMaskContainer
self.backgroundTintView.mask = self.backgroundTintMaskOuterContainer
self.backgroundView.updateColor(color: theme.contextMenu.backgroundColor, forceKeepBlur: true, transition: .immediate)
self.backgroundTintView.backgroundColor = UIColor(white: 1.0, alpha: 0.5)
} else {
if let filter = CALayer.luminanceToAlpha() {
self.backgroundTintMaskContainer.layer.filters = [filter]
self.backgroundTintMaskOuterContainer.layer.filters = [filter]
}
self.backgroundTintView.mask = self.backgroundTintMaskContainer
self.backgroundTintView.mask = self.backgroundTintMaskOuterContainer
self.backgroundView.updateColor(color: .clear, forceKeepBlur: true, transition: .immediate)
self.backgroundTintView.backgroundColor = theme.contextMenu.backgroundColor
@ -216,8 +218,10 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
transition.updateFrame(view: self.backgroundView, frame: contentBounds, beginWithCurrentState: true)
self.backgroundView.update(size: contentBounds.size, transition: transition)
transition.updateFrame(view: self.backgroundTintView, frame: CGRect(origin: CGPoint(x: -contentBounds.minX, y: -contentBounds.minY), size: contentBounds.size))
transition.updateFrame(view: self.backgroundTintMaskContainer, frame: CGRect(origin: CGPoint(), size: contentBounds.size))
transition.updateFrame(view: self.backgroundTintView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: contentBounds.width, height: contentBounds.height)))
transition.updateFrame(view: self.backgroundTintMaskOuterContainer, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: contentBounds.size))
transition.updateFrame(view: self.backgroundTintMaskContainer, frame: CGRect(origin: CGPoint(x: 10.0, y: 10.0), size: contentBounds.size))
transition.updateFrame(view: self.vibrantExpandedContentContainer, frame: CGRect(origin: CGPoint(x: 10.0, y: 10.0), size: contentBounds.size))
}
func animateIn() {

View file

@ -1090,7 +1090,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
if isSelected {
if selectionView.superview == nil {
self.mirrorContentScrollView.addSubview(selectionTintView)
self.scrollNode.view.addSubview(selectionView)
self.scrollNode.view.insertSubview(selectionView, belowSubview: itemNode.view)
selectionView.alpha = 1.0
selectionTintView.alpha = 1.0
@ -1207,7 +1207,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
let expandTintOffset: CGFloat
if self.highlightedReaction != nil {
expandItemSize = floor(30.0 * 0.9)
expandTintOffset = contentHeight - containerHeight
expandTintOffset = 0.0
} else {
expandItemSize = 30.0
expandTintOffset = 0.0

View file

@ -193,10 +193,10 @@ public final class ReactionNode: ASDisplayNode, ReactionItemNode {
self.useDirectRendering = useDirectRendering
self.selectionTintView = UIView()
self.selectionTintView?.backgroundColor = UIColor(white: 1.0, alpha: 0.2)
self.selectionTintView?.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
self.selectionView = UIView()
self.selectionView?.backgroundColor = theme.chat.inputMediaPanel.panelContentControlVibrantSelectionColor
self.selectionView?.backgroundColor = theme.chat.inputMediaPanel.panelContentControlVibrantOverlayColor.mixedWith(theme.contextMenu.backgroundColor.withMultipliedAlpha(0.4), alpha: 0.5)
self.staticAnimationNode = self.useDirectRendering ? DirectAnimatedStickerNode() : DefaultAnimatedStickerNodeImpl()
@ -722,7 +722,7 @@ final class EmojiItemNode: ASDisplayNode, ReactionItemNode {
self.emoji = emoji
self.selectionTintView = UIView()
self.selectionTintView?.backgroundColor = UIColor(white: 1.0, alpha: 0.2)
self.selectionTintView?.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
self.selectionView = UIView()
self.selectionView?.backgroundColor = theme.chat.inputMediaPanel.panelContentControlVibrantSelectionColor