Merge commit '555c097d0725be294d0dcf27e94f0ec8d0448613'

This commit is contained in:
Ali 2022-03-08 23:11:34 +04:00
commit 2984a7657d
5 changed files with 48 additions and 20 deletions

View File

@ -279,9 +279,6 @@ public class AttachmentController: ViewController {
} }
func switchToController(_ type: AttachmentButtonType, _ ascending: Bool) -> Bool { func switchToController(_ type: AttachmentButtonType, _ ascending: Bool) -> Bool {
guard !self.animating else {
return false
}
guard self.currentType != type else { guard self.currentType != type else {
if let controller = self.currentControllers.last { if let controller = self.currentControllers.last {
controller.scrollToTopWithTabBar?() controller.scrollToTopWithTabBar?()
@ -360,12 +357,22 @@ public class AttachmentController: ViewController {
} }
if case .compact = layout.metrics.widthClass { if case .compact = layout.metrics.widthClass {
let offset = strongSelf.container.isExpanded ? 10.0 : 24.0 let offset = 25.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 { let initialPosition = strongSelf.container.clipNode.layer.position
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 let targetPosition = initialPosition.offsetBy(dx: 0.0, dy: offset)
self?.container.clipNode.layer.removeAllAnimations() var startPosition = initialPosition
self?.animating = false if let presentation = strongSelf.container.clipNode.layer.presentation() {
startPosition = presentation.position
}
strongSelf.container.clipNode.layer.animatePosition(from: startPosition, to: targetPosition, duration: 0.2, removeOnCompletion: false, completion: { [weak self] finished in
if let strongSelf = self, finished {
strongSelf.container.clipNode.layer.animateSpring(from: NSValue(cgPoint: targetPosition), to: NSValue(cgPoint: initialPosition), keyPath: "position", duration: 0.4, delay: 0.0, initialVelocity: 0.0, damping: 70.0, removeOnCompletion: false, completion: { [weak self] finished in
if finished {
self?.container.clipNode.layer.removeAllAnimations()
self?.animating = false
}
}) })
} }
}) })
@ -373,7 +380,7 @@ public class AttachmentController: ViewController {
strongSelf.animating = false 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() snapshotView?.removeFromSuperview()
previousController?.resetForReuse() previousController?.resetForReuse()
}) })

View File

@ -208,7 +208,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
self.addSubnode(self.containerNode) self.addSubnode(self.containerNode)
self.containerNode.addSubnode(self.backgroundNode) self.containerNode.addSubnode(self.backgroundNode)
self.containerNode.addSubnode(self.gridNode) self.containerNode.addSubnode(self.gridNode)
self.containerNode.addSubnode(self.scrollingArea) // self.containerNode.addSubnode(self.scrollingArea)
let collection = controller.collection let collection = controller.collection
let preloadPromise = self.preloadPromise let preloadPromise = self.preloadPromise
@ -533,6 +533,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
self.currentDisplayMode = displayMode self.currentDisplayMode = displayMode
self.dismissInput() self.dismissInput()
self.controller?.dismissAllTooltips()
if case .selected = displayMode, self.selectionNode == nil, let controller = self.controller { if case .selected = displayMode, self.selectionNode == nil, let controller = self.controller {
let selectionNode = MediaPickerSelectedListNode(context: controller.context) 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) { fileprivate func send(asFile: Bool = false, silently: Bool, scheduleTime: Int32?, animated: Bool, completion: @escaping () -> Void) {
self.controller?.dismissAllTooltips()
var hasHeic = false var hasHeic = false
let allItems = self.controller?.interaction?.selectionState?.selectedItems() ?? [] let allItems = self.controller?.interaction?.selectionState?.selectedItems() ?? []
for item in allItems { for item in allItems {
@ -1194,7 +1197,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
super.displayNodeDidLoad() super.displayNodeDidLoad()
} }
private weak var undoController: UndoOverlayController? private weak var undoOverlayController: UndoOverlayController?
private func showSelectionUndo(item: TGMediaSelectableItem, count: Int32) { private func showSelectionUndo(item: TGMediaSelectableItem, count: Int32) {
var asset: PHAsset? var asset: PHAsset?
if let item = item as? TGMediaAsset { if let item = item as? TGMediaAsset {
@ -1216,12 +1219,12 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
} }
let presentationData = strongSelf.presentationData let presentationData = strongSelf.presentationData
if let undoController = strongSelf.undoController { if let undoOverlayController = strongSelf.undoOverlayController {
let text = presentationData.strings.Attachment_DeselectedItems(count) let text = presentationData.strings.Attachment_DeselectedItems(count)
undoController.content = .image(image: image ?? UIImage(), text: text) undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
} else { } else {
let text = presentationData.strings.Attachment_DeselectedItems(count) 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 { guard let strongSelf = self else {
return true return true
} }
@ -1233,8 +1236,8 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
} }
return true return true
}) })
strongSelf.present(undoController, in: .window(.root)) strongSelf.present(undoOverlayController, in: .window(.root))
strongSelf.undoController = undoController strongSelf.undoOverlayController = undoOverlayController
} }
}) })
} }
@ -1275,7 +1278,12 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
} }
} }
func dismissAllTooltips() {
self.undoOverlayController?.dismissWithCommitAction()
}
@objc private func cancelPressed() { @objc private func cancelPressed() {
self.dismissAllTooltips()
self.dismiss() self.dismiss()
} }

View File

@ -8998,6 +8998,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.sendMessageActionsController?.dismiss() self.sendMessageActionsController?.dismiss()
self.themeSceen?.dismiss() self.themeSceen?.dismiss()
self.attachmentController?.dismiss()
self.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts() self.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
if let _ = self.peekData { if let _ = self.peekData {
@ -10322,6 +10324,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
guard let peer = self.presentationInterfaceState.renderedPeer?.peer else { guard let peer = self.presentationInterfaceState.renderedPeer?.peer else {
return return
} }
let inputIsActive = self.presentationInterfaceState.inputMode == .text
self.chatDisplayNode.dismissInput() self.chatDisplayNode.dismissInput()
var bannedSendMedia: (Int32, Bool)? var bannedSendMedia: (Int32, Bool)?
@ -10619,10 +10624,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
} }
Queue.mainQueue().justDispatch { let present = {
self.present(attachmentController, in: .window(.root)) self.present(attachmentController, in: .window(.root))
self.attachmentController = attachmentController self.attachmentController = attachmentController
} }
if inputIsActive {
Queue.mainQueue().after(0.1, {
present()
})
} else {
present()
}
} }
private func oldPresentAttachmentMenu(editMediaOptions: MessageMediaEditingOptions?, editMediaReference: AnyMediaReference?) { private func oldPresentAttachmentMenu(editMediaOptions: MessageMediaEditingOptions?, editMediaReference: AnyMediaReference?) {

View File

@ -1207,7 +1207,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
needsShareButton = false needsShareButton = false
} }
} }
var tmpWidth: CGFloat var tmpWidth: CGFloat
if allowFullWidth { if allowFullWidth {
tmpWidth = baseWidth tmpWidth = baseWidth

View File

@ -493,7 +493,7 @@ final class ChatMessageReactionsFooterContentNode: ChatMessageBubbleContentNode
context: item.context, context: item.context,
presentationData: item.presentationData, presentationData: item.presentationData,
presentationContext: item.controllerInteraction.presentationContext, 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 return (layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right + buttonsUpdate.proposedWidth, { boundingWidth in
var boundingSize = CGSize() var boundingSize = CGSize()