mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-24 20:20:51 +00:00
Merge commit '5c9a7b80683cc06f087160715b2db0b881c52343'
This commit is contained in:
commit
c78e71991c
@ -71,6 +71,8 @@ public class ChatMessageBackground: ASDisplayNode {
|
|||||||
private let outlineImageNode: ASImageNode
|
private let outlineImageNode: ASImageNode
|
||||||
private weak var backgroundNode: WallpaperBackgroundNode?
|
private weak var backgroundNode: WallpaperBackgroundNode?
|
||||||
|
|
||||||
|
public var backgroundFrame: CGRect = .zero
|
||||||
|
|
||||||
public var hasImage: Bool {
|
public var hasImage: Bool {
|
||||||
self.imageNode.image != nil
|
self.imageNode.image != nil
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ struct ChatMessageBubbleContentProperties {
|
|||||||
let forceFullCorners: Bool
|
let forceFullCorners: Bool
|
||||||
let forceAlignment: ChatMessageBubbleContentAlignment
|
let forceAlignment: ChatMessageBubbleContentAlignment
|
||||||
let shareButtonOffset: CGPoint?
|
let shareButtonOffset: CGPoint?
|
||||||
|
let hidesHeaders: Bool
|
||||||
|
|
||||||
init(
|
init(
|
||||||
hidesSimpleAuthorHeader: Bool,
|
hidesSimpleAuthorHeader: Bool,
|
||||||
@ -34,7 +35,8 @@ struct ChatMessageBubbleContentProperties {
|
|||||||
hidesBackground: ChatMessageBubbleContentBackgroundHiding,
|
hidesBackground: ChatMessageBubbleContentBackgroundHiding,
|
||||||
forceFullCorners: Bool,
|
forceFullCorners: Bool,
|
||||||
forceAlignment: ChatMessageBubbleContentAlignment,
|
forceAlignment: ChatMessageBubbleContentAlignment,
|
||||||
shareButtonOffset: CGPoint? = nil
|
shareButtonOffset: CGPoint? = nil,
|
||||||
|
hidesHeaders: Bool = false
|
||||||
) {
|
) {
|
||||||
self.hidesSimpleAuthorHeader = hidesSimpleAuthorHeader
|
self.hidesSimpleAuthorHeader = hidesSimpleAuthorHeader
|
||||||
self.headerSpacing = headerSpacing
|
self.headerSpacing = headerSpacing
|
||||||
@ -42,6 +44,7 @@ struct ChatMessageBubbleContentProperties {
|
|||||||
self.forceFullCorners = forceFullCorners
|
self.forceFullCorners = forceFullCorners
|
||||||
self.forceAlignment = forceAlignment
|
self.forceAlignment = forceAlignment
|
||||||
self.shareButtonOffset = shareButtonOffset
|
self.shareButtonOffset = shareButtonOffset
|
||||||
|
self.hidesHeaders = hidesHeaders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,6 +1527,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hidesHeaders = false
|
||||||
var shareButtonOffset: CGPoint?
|
var shareButtonOffset: CGPoint?
|
||||||
var index = 0
|
var index = 0
|
||||||
for (message, _, attributes, bubbleAttributes, prepareLayout) in contentPropertiesAndPrepareLayouts {
|
for (message, _, attributes, bubbleAttributes, prepareLayout) in contentPropertiesAndPrepareLayouts {
|
||||||
@ -1586,6 +1587,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
if let offset = properties.shareButtonOffset {
|
if let offset = properties.shareButtonOffset {
|
||||||
shareButtonOffset = offset
|
shareButtonOffset = offset
|
||||||
}
|
}
|
||||||
|
if properties.hidesHeaders {
|
||||||
|
hidesHeaders = true
|
||||||
|
}
|
||||||
|
|
||||||
contentPropertiesAndLayouts.append((unboundSize, properties, prepareContentPosition, bubbleAttributes, nodeLayout, needSeparateContainers && !bubbleAttributes.isAttachment ? message.stableId : nil, itemSelection))
|
contentPropertiesAndLayouts.append((unboundSize, properties, prepareContentPosition, bubbleAttributes, nodeLayout, needSeparateContainers && !bubbleAttributes.isAttachment ? message.stableId : nil, itemSelection))
|
||||||
|
|
||||||
@ -1626,7 +1630,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
var currentCredibilityIcon: EmojiStatusComponent.Content?
|
var currentCredibilityIcon: EmojiStatusComponent.Content?
|
||||||
|
|
||||||
var initialDisplayHeader = true
|
var initialDisplayHeader = true
|
||||||
if let backgroundHiding = backgroundHiding, case .always = backgroundHiding {
|
if hidesHeaders {
|
||||||
|
initialDisplayHeader = false
|
||||||
|
} else if let backgroundHiding = backgroundHiding, case .always = backgroundHiding {
|
||||||
initialDisplayHeader = false
|
initialDisplayHeader = false
|
||||||
} else {
|
} else {
|
||||||
if inlineBotNameString == nil && (ignoreForward || firstMessage.forwardInfo == nil) && replyMessage == nil {
|
if inlineBotNameString == nil && (ignoreForward || firstMessage.forwardInfo == nil) && replyMessage == nil {
|
||||||
@ -2378,7 +2384,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
mosaicStatusOrigin: mosaicStatusOrigin,
|
mosaicStatusOrigin: mosaicStatusOrigin,
|
||||||
mosaicStatusSizeAndApply: mosaicStatusSizeAndApply,
|
mosaicStatusSizeAndApply: mosaicStatusSizeAndApply,
|
||||||
needsShareButton: needsShareButton,
|
needsShareButton: needsShareButton,
|
||||||
shareButtonOffset: shareButtonOffset
|
shareButtonOffset: shareButtonOffset,
|
||||||
|
hidesHeaders: hidesHeaders
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2423,7 +2430,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
mosaicStatusOrigin: CGPoint?,
|
mosaicStatusOrigin: CGPoint?,
|
||||||
mosaicStatusSizeAndApply: (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)?,
|
mosaicStatusSizeAndApply: (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)?,
|
||||||
needsShareButton: Bool,
|
needsShareButton: Bool,
|
||||||
shareButtonOffset: CGPoint?
|
shareButtonOffset: CGPoint?,
|
||||||
|
hidesHeaders: Bool
|
||||||
) -> Void {
|
) -> Void {
|
||||||
guard let strongSelf = selfReference.value else {
|
guard let strongSelf = selfReference.value else {
|
||||||
return
|
return
|
||||||
@ -2479,6 +2487,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
|
|
||||||
strongSelf.backgroundType = backgroundType
|
strongSelf.backgroundType = backgroundType
|
||||||
|
|
||||||
|
strongSelf.backgroundNode.backgroundFrame = backgroundFrame
|
||||||
|
|
||||||
let isFailed = item.content.firstMessage.effectivelyFailed(timestamp: item.context.account.network.getApproximateRemoteTimestamp())
|
let isFailed = item.content.firstMessage.effectivelyFailed(timestamp: item.context.account.network.getApproximateRemoteTimestamp())
|
||||||
if isFailed {
|
if isFailed {
|
||||||
let deliveryFailedNode: ChatMessageDeliveryFailedNode
|
let deliveryFailedNode: ChatMessageDeliveryFailedNode
|
||||||
@ -2523,6 +2533,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
}
|
}
|
||||||
strongSelf.clippingNode.addSubnode(nameNode)
|
strongSelf.clippingNode.addSubnode(nameNode)
|
||||||
nameNode.frame = nameNodeFrame
|
nameNode.frame = nameNodeFrame
|
||||||
|
|
||||||
|
if animation.isAnimated {
|
||||||
|
nameNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
animation.animator.updateFrame(layer: nameNode.layer, frame: nameNodeFrame, completion: nil)
|
animation.animator.updateFrame(layer: nameNode.layer, frame: nameNodeFrame, completion: nil)
|
||||||
}
|
}
|
||||||
@ -2536,6 +2550,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
credibilityIconView.isUserInteractionEnabled = false
|
credibilityIconView.isUserInteractionEnabled = false
|
||||||
strongSelf.credibilityIconView = credibilityIconView
|
strongSelf.credibilityIconView = credibilityIconView
|
||||||
strongSelf.clippingNode.view.addSubview(credibilityIconView)
|
strongSelf.clippingNode.view.addSubview(credibilityIconView)
|
||||||
|
|
||||||
|
if animation.isAnimated {
|
||||||
|
credibilityIconView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let credibilityIconComponent = EmojiStatusComponent(
|
let credibilityIconComponent = EmojiStatusComponent(
|
||||||
@ -2570,6 +2588,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
}
|
}
|
||||||
strongSelf.clippingNode.addSubnode(adminBadgeNode)
|
strongSelf.clippingNode.addSubnode(adminBadgeNode)
|
||||||
adminBadgeNode.frame = adminBadgeFrame
|
adminBadgeNode.frame = adminBadgeFrame
|
||||||
|
|
||||||
|
if animation.isAnimated {
|
||||||
|
adminBadgeNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//let previousAdminBadgeFrame = adminBadgeNode.frame
|
//let previousAdminBadgeFrame = adminBadgeNode.frame
|
||||||
animation.animator.updateFrame(layer: adminBadgeNode.layer, frame: adminBadgeFrame, completion: nil)
|
animation.animator.updateFrame(layer: adminBadgeNode.layer, frame: adminBadgeFrame, completion: nil)
|
||||||
@ -2579,12 +2601,33 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
strongSelf.adminBadgeNode = nil
|
strongSelf.adminBadgeNode = nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strongSelf.nameNode?.removeFromSupernode()
|
if animation.isAnimated {
|
||||||
strongSelf.nameNode = nil
|
if let nameNode = strongSelf.nameNode {
|
||||||
strongSelf.adminBadgeNode?.removeFromSupernode()
|
strongSelf.nameNode = nil
|
||||||
strongSelf.adminBadgeNode = nil
|
nameNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak nameNode] _ in
|
||||||
strongSelf.credibilityIconView?.removeFromSuperview()
|
nameNode?.removeFromSupernode()
|
||||||
strongSelf.credibilityIconView = nil
|
})
|
||||||
|
}
|
||||||
|
if let adminBadgeNode = strongSelf.adminBadgeNode {
|
||||||
|
strongSelf.adminBadgeNode = nil
|
||||||
|
adminBadgeNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak adminBadgeNode] _ in
|
||||||
|
adminBadgeNode?.removeFromSupernode()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if let credibilityIconView = strongSelf.credibilityIconView {
|
||||||
|
strongSelf.credibilityIconView = nil
|
||||||
|
credibilityIconView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak credibilityIconView] _ in
|
||||||
|
credibilityIconView?.removeFromSuperview()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strongSelf.nameNode?.removeFromSupernode()
|
||||||
|
strongSelf.nameNode = nil
|
||||||
|
strongSelf.adminBadgeNode?.removeFromSupernode()
|
||||||
|
strongSelf.adminBadgeNode = nil
|
||||||
|
strongSelf.credibilityIconView?.removeFromSuperview()
|
||||||
|
strongSelf.credibilityIconView = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let beginAt = applyInfo.timestamp ?? CACurrentMediaTime()
|
let beginAt = applyInfo.timestamp ?? CACurrentMediaTime()
|
||||||
@ -2903,10 +2946,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
|
|
||||||
let contentNode = strongSelf.contentNodes[contentNodeIndex]
|
let contentNode = strongSelf.contentNodes[contentNodeIndex]
|
||||||
|
|
||||||
var useContentOrigin = useContentOrigin
|
|
||||||
if contentNode.disablesClipping {
|
if contentNode.disablesClipping {
|
||||||
shouldClipOnTransitions = false
|
shouldClipOnTransitions = false
|
||||||
useContentOrigin = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let contentNodeFrame = relativeFrame.offsetBy(dx: contentOrigin.x, dy: useContentOrigin ? contentOrigin.y : 0.0)
|
let contentNodeFrame = relativeFrame.offsetBy(dx: contentOrigin.x, dy: useContentOrigin ? contentOrigin.y : 0.0)
|
||||||
|
@ -226,7 +226,7 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
let videoFrame = CGRect(origin: CGPoint(x: 1.0, y: 1.0), size: videoLayout.contentSize)
|
let videoFrame = CGRect(origin: CGPoint(x: 1.0, y: 1.0), size: videoLayout.contentSize)
|
||||||
|
|
||||||
let contentProperties = ChatMessageBubbleContentProperties(hidesSimpleAuthorHeader: false, headerSpacing: 0.0, hidesBackground: .never, forceFullCorners: false, forceAlignment: .none, shareButtonOffset: isExpanded ? .zero : CGPoint(x: -16.0, y: -24.0))
|
let contentProperties = ChatMessageBubbleContentProperties(hidesSimpleAuthorHeader: false, headerSpacing: 0.0, hidesBackground: .never, forceFullCorners: false, forceAlignment: .none, shareButtonOffset: isExpanded ? .zero : CGPoint(x: -16.0, y: -24.0), hidesHeaders: !isExpanded)
|
||||||
|
|
||||||
let width = videoFrame.width + 2.0
|
let width = videoFrame.width + 2.0
|
||||||
|
|
||||||
@ -282,16 +282,17 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
strongSelf.maskLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 640.0, height: 640.0))
|
strongSelf.maskLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 640.0, height: 640.0))
|
||||||
strongSelf.backdropMaskLayer.frame = strongSelf.maskLayer.frame
|
strongSelf.backdropMaskLayer.frame = strongSelf.maskLayer.frame
|
||||||
|
|
||||||
|
let bubbleSize = strongSelf.bubbleBackgroundNode?.backgroundFrame.size ?? finalSize
|
||||||
|
|
||||||
let radius: CGFloat = displaySize.width / 2.0
|
let radius: CGFloat = displaySize.width / 2.0
|
||||||
let maskCornerRadius = isExpanded ? 1.0 : radius
|
let maskCornerRadius = isExpanded ? 1.0 : radius
|
||||||
let maskFrame = CGRect(origin: CGPoint(x: isExpanded ? 1.0 : (incoming ? 7.0 : 1.0), y: isExpanded ? 0.0 : 1.0), size: isExpanded ? finalSize : CGSize(width: radius * 2.0, height: radius * 2.0))
|
let maskFrame = CGRect(origin: CGPoint(x: isExpanded ? 1.0 : (incoming ? 7.0 : 1.0), y: isExpanded ? 0.0 : 1.0), size: isExpanded ? bubbleSize : CGSize(width: radius * 2.0, height: radius * 2.0))
|
||||||
animation.animator.updateCornerRadius(layer: strongSelf.maskForeground, cornerRadius: maskCornerRadius, completion: nil)
|
animation.animator.updateCornerRadius(layer: strongSelf.maskForeground, cornerRadius: maskCornerRadius, completion: nil)
|
||||||
animation.animator.updateFrame(layer: strongSelf.maskForeground, frame: maskFrame, completion: nil)
|
animation.animator.updateFrame(layer: strongSelf.maskForeground, frame: maskFrame, completion: nil)
|
||||||
|
|
||||||
let backdropMaskFrame = CGRect(origin: CGPoint(x: isExpanded ? (incoming ? 8.0 : 2.0) : (incoming ? 8.0 : 2.0), y: isExpanded ? 2.0 : 2.0), size: isExpanded ? CGSize(width: finalSize.width - 11.0, height: finalSize.height - 2.0) : CGSize(width: radius * 2.0, height: radius * 2.0))
|
let backdropMaskFrame = CGRect(origin: CGPoint(x: isExpanded ? (incoming ? 8.0 : 2.0) : (incoming ? 8.0 : 2.0), y: isExpanded ? 2.0 : 2.0), size: isExpanded ? CGSize(width: bubbleSize.width - 8.0, height: bubbleSize.height - 3.0) : CGSize(width: radius * 2.0, height: radius * 2.0))
|
||||||
|
|
||||||
|
|
||||||
let topLeftCornerRadius: CGFloat
|
let topLeftCornerRadius: CGFloat
|
||||||
let topRightCornerRadius: CGFloat
|
let topRightCornerRadius: CGFloat
|
||||||
let bottomLeftCornerRadius: CGFloat
|
let bottomLeftCornerRadius: CGFloat
|
||||||
|
Loading…
x
Reference in New Issue
Block a user