Various improvements

This commit is contained in:
Ilya Laktyushin
2025-03-21 18:41:49 +04:00
parent 454b77da4e
commit 5956d5142f
41 changed files with 998 additions and 214 deletions

View File

@@ -19,6 +19,7 @@ swift_library(
"//submodules/Postbox",
"//submodules/WallpaperBackgroundNode",
"//submodules/TelegramUI/Components/Chat/ChatMessageItemCommon",
"//submodules/ContextUI",
],
visibility = [
"//visibility:public",

View File

@@ -9,8 +9,12 @@ import TelegramCore
import Postbox
import WallpaperBackgroundNode
import ChatMessageItemCommon
import ContextUI
public class ChatMessageShareButton: ASDisplayNode {
private let referenceNode: ContextReferenceContentNode
private let containerNode: ContextControllerSourceNode
private var backgroundContent: WallpaperBubbleBackgroundNode?
private var backgroundBlurView: PortalView?
@@ -33,16 +37,25 @@ public class ChatMessageShareButton: ASDisplayNode {
public var pressed: (() -> Void)?
public var morePressed: (() -> Void)?
public var longPressAction: ((ASDisplayNode, ContextGesture) -> Void)?
override public init() {
self.referenceNode = ContextReferenceContentNode()
self.containerNode = ContextControllerSourceNode()
self.containerNode.animateScale = false
self.topButton = HighlightTrackingButtonNode()
self.topIconNode = ASImageNode()
self.topIconNode.displaysAsynchronously = false
self.topIconNode.isUserInteractionEnabled = false
super.init()
self.allowsGroupOpacity = true
self.containerNode.addSubnode(self.referenceNode)
self.topButton.addSubnode(self.containerNode)
self.addSubnode(self.topIconNode)
self.addSubnode(self.topButton)
@@ -63,6 +76,19 @@ public class ChatMessageShareButton: ASDisplayNode {
self.textNode?.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
}
}
self.containerNode.shouldBegin = { [weak self] location in
guard let strongSelf = self, let _ = strongSelf.longPressAction else {
return false
}
return true
}
self.containerNode.activated = { [weak self] gesture, _ in
guard let strongSelf = self else {
return
}
strongSelf.longPressAction?(strongSelf.containerNode, gesture)
}
}
required public init?(coder aDecoder: NSCoder) {
@@ -238,6 +264,8 @@ public class ChatMessageShareButton: ASDisplayNode {
self.topIconNode.frame = CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0) + self.topIconOffset.x, y: floor((size.width - image.size.width) / 2.0) - (offsetIcon ? 1.0 : 0.0) + self.topIconOffset.y), size: image.size)
}
self.topButton.frame = CGRect(origin: .zero, size: CGSize(width: size.width, height: size.width))
self.containerNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.width))
self.referenceNode.frame = self.containerNode.bounds
if let bottomIconNode = self.bottomIconNode, let bottomButton = self.bottomButton, let bottomImage = bottomIconNode.image {
bottomIconNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - bottomImage.size.width) / 2.0), y: size.height - size.width + floorToScreenPixels((size.width - bottomImage.size.height) / 2.0)), size: bottomImage.size)