Video improvements

This commit is contained in:
Isaac
2024-10-25 15:59:12 +02:00
parent b976c24444
commit 153fa93a81
7 changed files with 80 additions and 38 deletions

View File

@@ -481,6 +481,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
weak var copyProtectionTooltipController: TooltipController?
weak var emojiPackTooltipController: TooltipScreen?
weak var birthdayTooltipController: TooltipScreen?
weak var scheduledVideoProcessingTooltipController: TooltipScreen?
weak var slowmodeTooltipController: ChatSlowmodeHintController?
@@ -10361,9 +10362,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
func displayProcessingVideoTooltip(messageId: EngineMessage.Id) {
self.checksTooltipController?.dismiss()
var latestNode: (Int32, ASDisplayNode)?
var latestNode: ChatMessageItemView?
self.chatDisplayNode.historyNode.forEachVisibleItemNode { itemNode in
if let itemNode = itemNode as? ChatMessageItemView, let item = itemNode.item, let statusNode = itemNode.getStatusNode() {
if let itemNode = itemNode as? ChatMessageItemView, let item = itemNode.item {
var found = false
for (message, _) in item.content {
if message.id == messageId {
@@ -10374,36 +10375,42 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if !found {
return
}
if !item.content.effectivelyIncoming(self.context.account.peerId) {
if let (latestTimestamp, _) = latestNode {
if item.message.timestamp > latestTimestamp {
latestNode = (item.message.timestamp, statusNode)
}
} else {
latestNode = (item.message.timestamp, statusNode)
}
}
latestNode = itemNode
}
}
if let (_, latestStatusNode) = latestNode {
let bounds = latestStatusNode.view.convert(latestStatusNode.view.bounds, to: self.chatDisplayNode.view)
let location = CGPoint(x: bounds.maxX - 7.0, y: bounds.minY - 11.0)
if let itemNode = latestNode, let statusNode = itemNode.getStatusNode() {
let bounds = statusNode.view.convert(statusNode.view.bounds, to: self.chatDisplayNode.view)
let location = CGPoint(x: bounds.midX, y: bounds.minY - 11.0)
let contentNode = ChatStatusChecksTooltipContentNode(presentationData: self.presentationData)
let tooltipController = TooltipController(content: .custom(contentNode), baseFontSize: self.presentationData.listsFontSize.baseDisplaySize, timeout: 3.5, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
//TODO:localize
let tooltipController = TooltipController(content: .text("Processing video may take a few minutes."), baseFontSize: self.presentationData.listsFontSize.baseDisplaySize, balancedTextLayout: true, timeout: 3.5, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
self.checksTooltipController = tooltipController
tooltipController.dismissed = { [weak self, weak tooltipController] _ in
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.checksTooltipController === tooltipController {
strongSelf.checksTooltipController = nil
}
}
self.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
if let strongSelf = self {
return (strongSelf.chatDisplayNode, CGRect(origin: location, size: CGSize()))
let _ = self.chatDisplayNode.messageTransitionNode.addCustomOffsetHandler(itemNode: itemNode, update: { [weak tooltipController] offset, transition in
guard let tooltipController, tooltipController.isNodeLoaded else {
return false
}
return nil
}))
guard let containerView = tooltipController.view else {
return false
}
containerView.bounds = containerView.bounds.offsetBy(dx: 0.0, dy: -offset)
transition.animateOffsetAdditive(layer: containerView.layer, offset: offset)
return true
})
self.present(tooltipController, in: .current, with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
guard let self else {
return nil
}
return (self.chatDisplayNode, CGRect(origin: location, size: CGSize()))
}, sourceRectIsGlobal: true))
}
}