Fix press animation

This commit is contained in:
Ali 2022-11-18 20:04:38 +04:00
parent dd37aa9684
commit 6db8971ff9

View File

@ -665,6 +665,20 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} }
} }
func assignParentNode(parentNode: ASDisplayNode?) {
for (id, topicNode) in self.topicNodes {
if id == self.topicNodeOrder.first, let parentNode {
if topicNode.supernode !== parentNode {
parentNode.addSubnode(topicNode)
}
} else {
if topicNode.supernode !== self {
self.addSubnode(topicNode)
}
}
}
}
func asyncLayout() -> (_ context: AccountContext, _ constrainedWidth: CGFloat, _ theme: PresentationTheme, _ authorTitle: NSAttributedString?, _ topics: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32)]) -> (CGSize, () -> CGRect?) { func asyncLayout() -> (_ context: AccountContext, _ constrainedWidth: CGFloat, _ theme: PresentationTheme, _ authorTitle: NSAttributedString?, _ topics: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32)]) -> (CGSize, () -> CGRect?) {
let makeAuthorLayout = TextNode.asyncLayout(self.authorNode) let makeAuthorLayout = TextNode.asyncLayout(self.authorNode)
var makeExistingTopicLayouts: [Int64: (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32) -> (CGSize, () -> TopicItemNode)] = [:] var makeExistingTopicLayouts: [Int64: (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32) -> (CGSize, () -> TopicItemNode)] = [:]
@ -755,7 +769,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
if self.topicNodes[item.0] != itemNode { if self.topicNodes[item.0] != itemNode {
self.topicNodes[item.0]?.removeFromSupernode() self.topicNodes[item.0]?.removeFromSupernode()
self.topicNodes[item.0] = itemNode self.topicNodes[item.0] = itemNode
self.addSubnode(itemNode)
} }
let itemFrame = CGRect(origin: CGPoint(x: nextX - 1.0, y: 0.0), size: item.1) let itemFrame = CGRect(origin: CGPoint(x: nextX - 1.0, y: 0.0), size: item.1)
itemNode.frame = itemFrame itemNode.frame = itemFrame
@ -1124,10 +1137,12 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
return false return false
} }
strongSelf.contextContainer.additionalActivationProgressLayer = nil
if item.interaction.inlineNavigationLocation != nil { if item.interaction.inlineNavigationLocation != nil {
strongSelf.contextContainer.targetNodeForActivationProgress = strongSelf.avatarContainerNode strongSelf.contextContainer.targetNodeForActivationProgress = strongSelf.avatarContainerNode
} else if let value = strongSelf.hitTest(location, with: nil), value === strongSelf.compoundTextButtonNode?.view { } else if let value = strongSelf.hitTest(location, with: nil), value === strongSelf.compoundTextButtonNode?.view {
strongSelf.contextContainer.targetNodeForActivationProgress = strongSelf.compoundHighlightingNode strongSelf.contextContainer.targetNodeForActivationProgress = strongSelf.compoundTextButtonNode
strongSelf.contextContainer.additionalActivationProgressLayer = strongSelf.compoundHighlightingNode?.layer
} else { } else {
strongSelf.contextContainer.targetNodeForActivationProgress = nil strongSelf.contextContainer.targetNodeForActivationProgress = nil
} }
@ -2775,7 +2790,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
let authorNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height), size: authorLayout) let authorNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height), size: authorLayout)
strongSelf.authorNode.frame = authorNodeFrame strongSelf.authorNode.frame = authorNodeFrame
let textNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height - 1.0 + UIScreenPixel + (authorLayout.height.isZero ? 0.0 : (authorLayout.height - 3.0))), size: textLayout.size) let textNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height - 1.0 + UIScreenPixel + (authorLayout.height.isZero ? 0.0 : (authorLayout.height - 3.0))), size: textLayout.size)
strongSelf.textNode.textNode.frame = textNodeFrame
if let topForumTopicRect, !isSearching { if let topForumTopicRect, !isSearching {
let compoundHighlightingNode: LinkHighlightingNode let compoundHighlightingNode: LinkHighlightingNode
@ -2879,6 +2893,22 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} }
} }
if let compoundTextButtonNode = strongSelf.compoundTextButtonNode {
if strongSelf.textNode.textNode.supernode !== compoundTextButtonNode {
compoundTextButtonNode.addSubnode(strongSelf.textNode.textNode)
}
strongSelf.textNode.textNode.frame = textNodeFrame.offsetBy(dx: -compoundTextButtonNode.frame.minX, dy: -compoundTextButtonNode.frame.minY)
strongSelf.authorNode.assignParentNode(parentNode: compoundTextButtonNode)
} else {
if strongSelf.textNode.textNode.supernode !== strongSelf.mainContentContainerNode {
strongSelf.mainContentContainerNode.addSubnode(strongSelf.textNode.textNode)
}
strongSelf.textNode.textNode.frame = textNodeFrame
strongSelf.authorNode.assignParentNode(parentNode: nil)
}
if !textLayout.spoilers.isEmpty { if !textLayout.spoilers.isEmpty {
let dustNode: InvisibleInkDustNode let dustNode: InvisibleInkDustNode
if let current = strongSelf.dustNode { if let current = strongSelf.dustNode {