diff --git a/submodules/AttachmentUI/Sources/AttachmentController.swift b/submodules/AttachmentUI/Sources/AttachmentController.swift index 5a11fbd3b4..69e7080960 100644 --- a/submodules/AttachmentUI/Sources/AttachmentController.swift +++ b/submodules/AttachmentUI/Sources/AttachmentController.swift @@ -279,9 +279,6 @@ public class AttachmentController: ViewController { } func switchToController(_ type: AttachmentButtonType, _ ascending: Bool) -> Bool { - guard !self.animating else { - return false - } guard self.currentType != type else { if let controller = self.currentControllers.last { controller.scrollToTopWithTabBar?() @@ -347,6 +344,7 @@ public class AttachmentController: ViewController { snapshotView.frame = self.container.container.frame self.container.clipNode.view.addSubview(snapshotView) + let alreadyAnimating = self.animating self.animating = true let _ = (controller.ready.get() @@ -360,20 +358,24 @@ public class AttachmentController: ViewController { } if case .compact = layout.metrics.widthClass { - let offset = strongSelf.container.isExpanded ? 10.0 : 24.0 - strongSelf.container.clipNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: offset), duration: 0.18, removeOnCompletion: false, additive: true, completion: { [weak self] _ in - if let strongSelf = self { - strongSelf.container.clipNode.layer.animateSpring(from: NSValue(cgPoint: CGPoint(x: 0.0, y: 0.0)), to: NSValue(cgPoint: CGPoint(x: 0.0, y: -offset)), keyPath: "position", duration: 0.55, delay: 0.0, initialVelocity: 0.0, damping: 70.0, removeOnCompletion: false, additive: true, completion: { [weak self] _ in - self?.container.clipNode.layer.removeAllAnimations() - self?.animating = false - }) - } - }) + if !alreadyAnimating { + let offset = 25.0 + strongSelf.container.clipNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: offset), duration: 0.15, removeOnCompletion: false, additive: true, completion: { [weak self] finished in + if let strongSelf = self, finished { + strongSelf.container.clipNode.layer.animateSpring(from: NSValue(cgPoint: CGPoint(x: 0.0, y: 0.0)), to: NSValue(cgPoint: CGPoint(x: 0.0, y: -offset)), keyPath: "position", duration: 0.45, delay: 0.0, initialVelocity: 0.0, damping: 70.0, removeOnCompletion: false, additive: true, completion: { [weak self] finished in + if finished { + self?.container.clipNode.layer.removeAllAnimations() + self?.animating = false + } + }) + } + }) + } } else { strongSelf.animating = false } - snapshotView?.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { [weak snapshotView] _ in + snapshotView?.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.23, removeOnCompletion: false, completion: { [weak snapshotView] _ in snapshotView?.removeFromSuperview() previousController?.resetForReuse() }) diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 06c5b165ae..8ab13e91fa 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -208,7 +208,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { self.addSubnode(self.containerNode) self.containerNode.addSubnode(self.backgroundNode) self.containerNode.addSubnode(self.gridNode) - self.containerNode.addSubnode(self.scrollingArea) +// self.containerNode.addSubnode(self.scrollingArea) let collection = controller.collection let preloadPromise = self.preloadPromise @@ -533,6 +533,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { self.currentDisplayMode = displayMode self.dismissInput() + self.controller?.dismissAllTooltips() if case .selected = displayMode, self.selectionNode == nil, let controller = self.controller { let selectionNode = MediaPickerSelectedListNode(context: controller.context) @@ -669,6 +670,8 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } fileprivate func send(asFile: Bool = false, silently: Bool, scheduleTime: Int32?, animated: Bool, completion: @escaping () -> Void) { + self.controller?.dismissAllTooltips() + var hasHeic = false let allItems = self.controller?.interaction?.selectionState?.selectedItems() ?? [] for item in allItems { @@ -1194,7 +1197,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { super.displayNodeDidLoad() } - private weak var undoController: UndoOverlayController? + private weak var undoOverlayController: UndoOverlayController? private func showSelectionUndo(item: TGMediaSelectableItem, count: Int32) { var asset: PHAsset? if let item = item as? TGMediaAsset { @@ -1216,12 +1219,12 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } let presentationData = strongSelf.presentationData - if let undoController = strongSelf.undoController { + if let undoOverlayController = strongSelf.undoOverlayController { let text = presentationData.strings.Attachment_DeselectedItems(count) - undoController.content = .image(image: image ?? UIImage(), text: text) + undoOverlayController.content = .image(image: image ?? UIImage(), text: text) } else { let text = presentationData.strings.Attachment_DeselectedItems(count) - let undoController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: true, action: { [weak self] action in + let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: true, action: { [weak self] action in guard let strongSelf = self else { return true } @@ -1233,8 +1236,8 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } return true }) - strongSelf.present(undoController, in: .window(.root)) - strongSelf.undoController = undoController + strongSelf.present(undoOverlayController, in: .window(.root)) + strongSelf.undoOverlayController = undoOverlayController } }) } @@ -1275,7 +1278,12 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } } + func dismissAllTooltips() { + self.undoOverlayController?.dismissWithCommitAction() + } + @objc private func cancelPressed() { + self.dismissAllTooltips() self.dismiss() } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index fae04d0af4..35f9e7f951 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -8998,6 +8998,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.sendMessageActionsController?.dismiss() self.themeSceen?.dismiss() + self.attachmentController?.dismiss() + self.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts() if let _ = self.peekData { @@ -10322,6 +10324,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let peer = self.presentationInterfaceState.renderedPeer?.peer else { return } + + let inputIsActive = self.presentationInterfaceState.inputMode == .text + self.chatDisplayNode.dismissInput() var bannedSendMedia: (Int32, Bool)? @@ -10619,10 +10624,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } } - Queue.mainQueue().justDispatch { + let present = { self.present(attachmentController, in: .window(.root)) self.attachmentController = attachmentController } + + if inputIsActive { + Queue.mainQueue().after(0.1, { + present() + }) + } else { + present() + } } private func oldPresentAttachmentMenu(editMediaOptions: MessageMediaEditingOptions?, editMediaReference: AnyMediaReference?) { diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index dc62b3c9a8..efa60a6a20 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -1207,7 +1207,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode needsShareButton = false } } - + var tmpWidth: CGFloat if allowFullWidth { tmpWidth = baseWidth diff --git a/submodules/TelegramUI/Sources/ChatMessageReactionsFooterContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageReactionsFooterContentNode.swift index ef0076299e..1ae5e8b8c3 100644 --- a/submodules/TelegramUI/Sources/ChatMessageReactionsFooterContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageReactionsFooterContentNode.swift @@ -493,7 +493,7 @@ final class ChatMessageReactionsFooterContentNode: ChatMessageBubbleContentNode context: item.context, presentationData: item.presentationData, presentationContext: item.controllerInteraction.presentationContext, - availableReactions: item.associatedData.availableReactions, reactions: reactionsAttribute, message: item.message, alignment: .left, constrainedWidth: constrainedSize.width, type: item.message.effectivelyIncoming(item.context.account.peerId) ? .incoming : .outgoing) + availableReactions: item.associatedData.availableReactions, reactions: reactionsAttribute, message: item.message, alignment: .left, constrainedWidth: constrainedSize.width - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, type: item.message.effectivelyIncoming(item.context.account.peerId) ? .incoming : .outgoing) return (layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right + buttonsUpdate.proposedWidth, { boundingWidth in var boundingSize = CGSize()