mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various Fixes
This commit is contained in:
@@ -1058,7 +1058,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
}
|
||||
}
|
||||
|
||||
override func asyncLayout() -> (_ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, Bool) -> Void) {
|
||||
override func asyncLayout() -> (_ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) {
|
||||
var currentContentClassesPropertiesAndLayouts: [(Message, AnyClass, Bool, (_ item: ChatMessageBubbleContentItem, _ layoutConstants: ChatMessageItemLayoutConstants, _ preparePosition: ChatMessageBubblePreparePosition, _ messageSelection: Bool?, _ constrainedSize: CGSize) -> (ChatMessageBubbleContentProperties, CGSize?, CGFloat, (CGSize, ChatMessageBubbleContentPosition) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> Void))))] = []
|
||||
for contentNode in self.contentNodes {
|
||||
if let message = contentNode.item?.message {
|
||||
@@ -1115,7 +1115,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
currentItem: ChatMessageItem?,
|
||||
currentForwardInfo: (Peer?, String?)?,
|
||||
isSelected: Bool?
|
||||
) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, Bool) -> Void) {
|
||||
) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) {
|
||||
let isPreview = item.presentationData.isPreview
|
||||
let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: isSelected)
|
||||
|
||||
@@ -2193,9 +2193,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
}
|
||||
}
|
||||
|
||||
return (layout, { animation, synchronousLoads in
|
||||
return (layout, { animation, applyInfo, synchronousLoads in
|
||||
return ChatMessageBubbleItemNode.applyLayout(selfReference: selfReference, animation, synchronousLoads,
|
||||
params: params,
|
||||
applyInfo: applyInfo,
|
||||
layout: layout,
|
||||
item: item,
|
||||
forwardSource: forwardSource,
|
||||
@@ -2236,6 +2237,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
|
||||
private static func applyLayout(selfReference: Weak<ChatMessageBubbleItemNode>, _ animation: ListViewItemUpdateAnimation, _ synchronousLoads: Bool,
|
||||
params: ListViewItemLayoutParams,
|
||||
applyInfo: ListViewItemApply,
|
||||
layout: ListViewItemNodeLayout,
|
||||
item: ChatMessageItem,
|
||||
forwardSource: Peer?,
|
||||
@@ -2285,11 +2287,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
strongSelf.updateAccessibilityData(accessibilityData)
|
||||
|
||||
var transition: ContainedViewLayoutTransition = .immediate
|
||||
var useDisplayLinkAnimations = false
|
||||
if case let .System(duration) = animation {
|
||||
if false, let subject = item.associatedData.subject, case .forwardedMessages = subject {
|
||||
transition = .animated(duration: duration, curve: .easeInOut)
|
||||
} else {
|
||||
transition = .animated(duration: duration, curve: .spring)
|
||||
transition = .animated(duration: duration, curve: .spring)
|
||||
|
||||
if let subject = item.associatedData.subject, case .forwardedMessages = subject {
|
||||
useDisplayLinkAnimations = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2404,11 +2407,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
strongSelf.adminBadgeNode = nil
|
||||
}
|
||||
|
||||
var timingFunction = kCAMediaTimingFunctionSpring
|
||||
if false, let subject = item.associatedData.subject, case .forwardedMessages = subject {
|
||||
timingFunction = CAMediaTimingFunctionName.easeInEaseOut.rawValue
|
||||
}
|
||||
|
||||
let beginAt = applyInfo.timestamp ?? CACurrentMediaTime()
|
||||
|
||||
let timingFunction = kCAMediaTimingFunctionSpring
|
||||
if let forwardInfoNode = forwardInfoSizeApply.1(bubbleContentWidth) {
|
||||
strongSelf.forwardInfoNode = forwardInfoNode
|
||||
var animateFrame = true
|
||||
@@ -2427,11 +2428,23 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
}
|
||||
}
|
||||
let previousForwardInfoNodeFrame = forwardInfoNode.frame
|
||||
forwardInfoNode.frame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + forwardInfoOriginY), size: CGSize(width: bubbleContentWidth, height: forwardInfoSizeApply.0.height))
|
||||
let forwardInfoFrame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + forwardInfoOriginY), size: CGSize(width: bubbleContentWidth, height: forwardInfoSizeApply.0.height))
|
||||
if case let .System(duration) = animation {
|
||||
if animateFrame {
|
||||
forwardInfoNode.layer.animateFrame(from: previousForwardInfoNodeFrame, to: forwardInfoNode.frame, duration: duration, timingFunction: timingFunction)
|
||||
if useDisplayLinkAnimations {
|
||||
let animation = ListViewAnimation(from: previousForwardInfoNodeFrame, to: forwardInfoFrame, duration: duration * UIView.animationDurationFactor(), curve: strongSelf.preferredAnimationCurve, beginAt: beginAt, update: { _, frame in
|
||||
forwardInfoNode.frame = frame
|
||||
})
|
||||
strongSelf.setAnimationForKey("forwardFrame", animation: animation)
|
||||
} else {
|
||||
forwardInfoNode.frame = forwardInfoFrame
|
||||
forwardInfoNode.layer.animateFrame(from: previousForwardInfoNodeFrame, to: forwardInfoFrame, duration: duration, timingFunction: timingFunction)
|
||||
}
|
||||
} else {
|
||||
forwardInfoNode.frame = forwardInfoFrame
|
||||
}
|
||||
} else {
|
||||
forwardInfoNode.frame = forwardInfoFrame
|
||||
}
|
||||
} else {
|
||||
if animation.isAnimated {
|
||||
@@ -2649,12 +2662,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
}
|
||||
|
||||
if let addedContentNodes = addedContentNodes {
|
||||
for (contentNodeMessage, isAttachent, contentNode) in addedContentNodes {
|
||||
for (contentNodeMessage, isAttachment, contentNode) in addedContentNodes {
|
||||
updatedContentNodes.append(contentNode)
|
||||
|
||||
let contextSourceNode: ContextExtractedContentContainingNode
|
||||
let containerSupernode: ASDisplayNode
|
||||
if isAttachent {
|
||||
if isAttachment {
|
||||
contextSourceNode = strongSelf.mainContextSourceNode
|
||||
containerSupernode = strongSelf.clippingNode
|
||||
} else {
|
||||
@@ -2705,7 +2718,6 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
let contentNode = strongSelf.contentNodes[contentNodeIndex]
|
||||
let contentNodeFrame = relativeFrame.offsetBy(dx: contentOrigin.x, dy: useContentOrigin ? contentOrigin.y : 0.0)
|
||||
let previousContentNodeFrame = contentNode.frame
|
||||
contentNode.frame = contentNodeFrame
|
||||
|
||||
if case let .System(duration) = animation {
|
||||
var animateFrame = false
|
||||
@@ -2721,13 +2733,26 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
}
|
||||
|
||||
if animateFrame {
|
||||
contentNode.layer.animateFrame(from: previousContentNodeFrame, to: contentNodeFrame, duration: duration, timingFunction: timingFunction)
|
||||
if useDisplayLinkAnimations {
|
||||
let animation = ListViewAnimation(from: previousContentNodeFrame, to: contentNodeFrame, duration: duration * UIView.animationDurationFactor(), curve: strongSelf.preferredAnimationCurve, beginAt: beginAt, update: { _, frame in
|
||||
contentNode.frame = frame
|
||||
})
|
||||
strongSelf.setAnimationForKey("contentNode\(contentNodeIndex)Frame", animation: animation)
|
||||
} else {
|
||||
contentNode.frame = contentNodeFrame
|
||||
contentNode.layer.animateFrame(from: previousContentNodeFrame, to: contentNodeFrame, duration: duration, timingFunction: timingFunction)
|
||||
}
|
||||
} else if animateAlpha {
|
||||
contentNode.frame = contentNodeFrame
|
||||
contentNode.animateInsertionIntoBubble(duration)
|
||||
var previousAlignedContentNodeFrame = contentNodeFrame
|
||||
previousAlignedContentNodeFrame.origin.x += backgroundFrame.size.width - strongSelf.backgroundNode.frame.size.width
|
||||
contentNode.layer.animateFrame(from: previousAlignedContentNodeFrame, to: contentNodeFrame, duration: duration, timingFunction: timingFunction)
|
||||
} else {
|
||||
contentNode.frame = contentNodeFrame
|
||||
}
|
||||
} else {
|
||||
contentNode.frame = contentNodeFrame
|
||||
}
|
||||
contentNodeIndex += 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user