mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
384eb313bc
commit
84949750cd
@ -220,9 +220,7 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
let leftInset: CGFloat = 0.0
|
let leftInset: CGFloat = 0.0
|
||||||
let rightInset: CGFloat = 0.0
|
let rightInset: CGFloat = 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let (videoLayout, videoApply) = interactiveVideoLayout(ChatMessageBubbleContentItem(context: item.context, controllerInteraction: item.controllerInteraction, message: item.message, topMessage: item.message, read: item.read, chatLocation: item.chatLocation, presentationData: item.presentationData, associatedData: item.associatedData, attributes: item.attributes, isItemPinned: item.message.tags.contains(.pinned) && !isReplyThread, isItemEdited: false), constrainedSize.width - leftInset - rightInset - avatarInset, displaySize, maximumDisplaySize, isPlaying ? 1.0 : 0.0, .free, automaticDownload)
|
let (videoLayout, videoApply) = interactiveVideoLayout(ChatMessageBubbleContentItem(context: item.context, controllerInteraction: item.controllerInteraction, message: item.message, topMessage: item.message, read: item.read, chatLocation: item.chatLocation, presentationData: item.presentationData, associatedData: item.associatedData, attributes: item.attributes, isItemPinned: item.message.tags.contains(.pinned) && !isReplyThread, isItemEdited: false), constrainedSize.width - leftInset - rightInset - avatarInset, displaySize, maximumDisplaySize, isPlaying ? 1.0 : 0.0, .free, automaticDownload)
|
||||||
|
|
||||||
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)
|
||||||
@ -230,9 +228,6 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
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))
|
||||||
|
|
||||||
let width = videoFrame.width + 2.0
|
let width = videoFrame.width + 2.0
|
||||||
// if isExpanded {
|
|
||||||
// width = normalDisplaySize.width + 32.0
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (contentProperties, nil, width, { constrainedSize, position in
|
return (contentProperties, nil, width, { constrainedSize, position in
|
||||||
var refinedWidth = videoFrame.width + 2.0
|
var refinedWidth = videoFrame.width + 2.0
|
||||||
@ -240,7 +235,6 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
if isExpanded || !didSetupFileNode {
|
if isExpanded || !didSetupFileNode {
|
||||||
(refinedWidth, finishLayout) = refineLayout(CGSize(width: constrainedSize.width - layoutConstants.file.bubbleInsets.left - layoutConstants.file.bubbleInsets.right, height: constrainedSize.height))
|
(refinedWidth, finishLayout) = refineLayout(CGSize(width: constrainedSize.width - layoutConstants.file.bubbleInsets.left - layoutConstants.file.bubbleInsets.right, height: constrainedSize.height))
|
||||||
// refinedWidth = refinedWidth//max(refinedWidth, normalDisplaySize.width)
|
|
||||||
refinedWidth += layoutConstants.file.bubbleInsets.left + layoutConstants.file.bubbleInsets.right
|
refinedWidth += layoutConstants.file.bubbleInsets.left + layoutConstants.file.bubbleInsets.right
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
private var playerStatus: MediaPlayerStatus? {
|
private var playerStatus: MediaPlayerStatus? {
|
||||||
didSet {
|
didSet {
|
||||||
if self.playerStatus != oldValue {
|
if self.playerStatus != oldValue {
|
||||||
self.updateStatus()
|
self.updateStatus(animator: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,9 +465,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var previousVideoNode: UniversalVideoNode?
|
||||||
var updatedPlayerStatusSignal: Signal<MediaPlayerStatus?, NoError>?
|
var updatedPlayerStatusSignal: Signal<MediaPlayerStatus?, NoError>?
|
||||||
if let telegramFile = updatedFile {
|
if let telegramFile = updatedFile {
|
||||||
if updatedMedia {
|
if updatedMedia {
|
||||||
|
previousVideoNode = strongSelf.videoNode
|
||||||
if let durationBlurColor = durationBlurColor {
|
if let durationBlurColor = durationBlurColor {
|
||||||
if let durationBackgroundNode = strongSelf.durationBackgroundNode {
|
if let durationBackgroundNode = strongSelf.durationBackgroundNode {
|
||||||
durationBackgroundNode.updateColor(color: durationBlurColor.0, enableBlur: durationBlurColor.1, transition: .immediate)
|
durationBackgroundNode.updateColor(color: durationBlurColor.0, enableBlur: durationBlurColor.1, transition: .immediate)
|
||||||
@ -518,7 +520,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), content: NativeVideoContent(id: .message(item.message.stableId, telegramFile.fileId), fileReference: .message(message: MessageReference(item.message), media: telegramFile), streamVideo: streamVideo ? .conservative : .none, enableSound: false, fetchAutomatically: false, captureProtected: item.message.isCopyProtected()), priority: .embedded, autoplay: true)
|
}), content: NativeVideoContent(id: .message(item.message.stableId, telegramFile.fileId), fileReference: .message(message: MessageReference(item.message), media: telegramFile), streamVideo: streamVideo ? .conservative : .none, enableSound: false, fetchAutomatically: false, captureProtected: item.message.isCopyProtected()), priority: .embedded, autoplay: true)
|
||||||
let previousVideoNode = strongSelf.videoNode
|
if let previousVideoNode = previousVideoNode {
|
||||||
|
videoNode.bounds = previousVideoNode.bounds
|
||||||
|
videoNode.position = previousVideoNode.position
|
||||||
|
videoNode.transform = previousVideoNode.transform
|
||||||
|
}
|
||||||
strongSelf.videoNode = videoNode
|
strongSelf.videoNode = videoNode
|
||||||
strongSelf.insertSubnode(videoNode, belowSubnode: previousVideoNode ?? strongSelf.dateAndStatusNode)
|
strongSelf.insertSubnode(videoNode, belowSubnode: previousVideoNode ?? strongSelf.dateAndStatusNode)
|
||||||
videoNode.canAttachContent = strongSelf.shouldAcquireVideoContext
|
videoNode.canAttachContent = strongSelf.shouldAcquireVideoContext
|
||||||
@ -548,7 +554,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
|> deliverOnMainQueue).start(next: { status in
|
|> deliverOnMainQueue).start(next: { status in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.status = status
|
strongSelf.status = status
|
||||||
strongSelf.updateStatus()
|
strongSelf.updateStatus(animator: nil)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -658,12 +664,17 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
|
|
||||||
if let videoNode = strongSelf.videoNode {
|
if let videoNode = strongSelf.videoNode {
|
||||||
videoNode.bounds = CGRect(origin: CGPoint(), size: videoFrame.size)
|
videoNode.bounds = CGRect(origin: CGPoint(), size: videoFrame.size)
|
||||||
if imageScale != strongSelf.imageScale {
|
|
||||||
strongSelf.imageScale = imageScale
|
strongSelf.imageScale = imageScale
|
||||||
animation.animator.updateScale(layer: videoNode.layer, scale: imageScale, completion: nil)
|
animation.animator.updateScale(layer: videoNode.layer, scale: imageScale, completion: nil)
|
||||||
}
|
|
||||||
animation.animator.updatePosition(layer: videoNode.layer, position: displayVideoFrame.center, completion: nil)
|
animation.animator.updatePosition(layer: videoNode.layer, position: displayVideoFrame.center, completion: nil)
|
||||||
videoNode.updateLayout(size: arguments.boundingSize, transition: animation.transition)
|
videoNode.updateLayout(size: arguments.boundingSize, transition: animation.transition)
|
||||||
|
|
||||||
|
if let previousVideoNode = previousVideoNode {
|
||||||
|
animation.animator.updateScale(layer: previousVideoNode.layer, scale: imageScale, completion: nil)
|
||||||
|
animation.animator.updatePosition(layer: previousVideoNode.layer, position: displayVideoFrame.center, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
animation.animator.updateFrame(layer: strongSelf.secretVideoPlaceholderBackground.layer, frame: displayVideoFrame, completion: nil)
|
animation.animator.updateFrame(layer: strongSelf.secretVideoPlaceholderBackground.layer, frame: displayVideoFrame, completion: nil)
|
||||||
|
|
||||||
@ -677,7 +688,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
let applySecretPlaceholder = makeSecretPlaceholderLayout(arguments)
|
let applySecretPlaceholder = makeSecretPlaceholderLayout(arguments)
|
||||||
applySecretPlaceholder()
|
applySecretPlaceholder()
|
||||||
|
|
||||||
strongSelf.updateStatus()
|
strongSelf.updateStatus(animator: animation.animator)
|
||||||
|
|
||||||
if let telegramFile = updatedFile, previousAutomaticDownload != automaticDownload, automaticDownload {
|
if let telegramFile = updatedFile, previousAutomaticDownload != automaticDownload, automaticDownload {
|
||||||
strongSelf.fetchDisposable.set(messageMediaFileInteractiveFetched(context: item.context, message: item.message, file: telegramFile, userInitiated: false).start())
|
strongSelf.fetchDisposable.set(messageMediaFileInteractiveFetched(context: item.context, message: item.message, file: telegramFile, userInitiated: false).start())
|
||||||
@ -698,7 +709,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateStatus() {
|
private func updateStatus(animator: ControlledTransitionAnimator? = nil) {
|
||||||
guard let item = self.item, let status = self.status, let videoFrame = self.videoFrame else {
|
guard let item = self.item, let status = self.status, let videoFrame = self.videoFrame else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -800,8 +811,17 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let statusFrame = CGRect(origin: CGPoint(x: videoFrame.origin.x + floorToScreenPixels((videoFrame.size.width - 50.0) / 2.0), y: videoFrame.origin.y + floorToScreenPixels((videoFrame.size.height - 50.0) / 2.0)), size: CGSize(width: 50.0, height: 50.0))
|
let statusFrame = CGRect(origin: CGPoint(x: videoFrame.origin.x + floorToScreenPixels((videoFrame.size.width - 50.0) / 2.0), y: videoFrame.origin.y + floorToScreenPixels((videoFrame.size.height - 50.0) / 2.0)), size: CGSize(width: 50.0, height: 50.0))
|
||||||
self.statusNode?.frame = statusFrame
|
if let animator = animator {
|
||||||
self.disappearingStatusNode?.frame = statusFrame
|
if let statusNode = self.statusNode {
|
||||||
|
animator.updateFrame(layer: statusNode.layer, frame: statusFrame, completion: nil)
|
||||||
|
}
|
||||||
|
if let disappearingStatusNode = self.disappearingStatusNode {
|
||||||
|
animator.updateFrame(layer: disappearingStatusNode.layer, frame: statusFrame, completion: nil)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.statusNode?.frame = statusFrame
|
||||||
|
self.disappearingStatusNode?.frame = statusFrame
|
||||||
|
}
|
||||||
|
|
||||||
var state: RadialStatusNodeState
|
var state: RadialStatusNodeState
|
||||||
switch status.mediaStatus {
|
switch status.mediaStatus {
|
||||||
@ -1132,7 +1152,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
|
|
||||||
var updateTranscribeExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState, TranscribedText?) -> Void)?
|
var updateTranscribeExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState, TranscribedText?) -> Void)?
|
||||||
private func transcribe() {
|
private func transcribe() {
|
||||||
guard let context = self.item?.context, let message = self.item?.message else {
|
guard let context = self.item?.context, let message = self.item?.message, self.statusNode == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user