diff --git a/submodules/ContextUI/Sources/ContextController.swift b/submodules/ContextUI/Sources/ContextController.swift index 6917289507..d58400ca17 100644 --- a/submodules/ContextUI/Sources/ContextController.swift +++ b/submodules/ContextUI/Sources/ContextController.swift @@ -2150,6 +2150,7 @@ public protocol ContextExtractedContentSource: AnyObject { var initialAppearanceOffset: CGPoint { get } var centerVertically: Bool { get } var keepInPlace: Bool { get } + var adjustContentForSideInset: Bool { get } var ignoreContentTouches: Bool { get } var blurBackground: Bool { get } var shouldBeDismissed: Signal { get } @@ -2169,6 +2170,10 @@ public extension ContextExtractedContentSource { return false } + var adjustContentForSideInset: Bool { + return false + } + var actionsHorizontalAlignment: ContextActionsHorizontalAlignment { return .default } diff --git a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift index f2175d2fb2..f889644ca3 100644 --- a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift +++ b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift @@ -744,7 +744,7 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo } } - let contentParentGlobalFrame: CGRect + var contentParentGlobalFrame: CGRect var contentRect: CGRect var isContentResizeableVertically: Bool = false let _ = isContentResizeableVertically @@ -825,6 +825,22 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo } } + var contentParentGlobalFrameOffsetX: CGFloat = 0.0 + if case let .extracted(extracted) = self.source, extracted.adjustContentForSideInset { + let contentSideInset: CGFloat = actionsSideInset + 6.0 + + var updatedFrame = contentParentGlobalFrame + if updatedFrame.origin.x + updatedFrame.width > layout.size.width - contentSideInset { + updatedFrame.origin.x = layout.size.width - contentSideInset - updatedFrame.width + } + if updatedFrame.origin.x < contentSideInset { + updatedFrame.origin.x = contentSideInset + } + + contentParentGlobalFrameOffsetX = updatedFrame.minX - contentParentGlobalFrame.minX + contentParentGlobalFrame = updatedFrame + } + let keepInPlace: Bool let actionsHorizontalAlignment: ContextActionsHorizontalAlignment switch self.source { @@ -1154,17 +1170,21 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo } else if contentX + contentWidth > layout.size.width / 2.0, actionsSize.height > 0.0 { let fixedContentX = layout.size.width - (contentX + contentWidth) animationInContentXDistance = fixedContentX - contentX - - contentNode.layer.animateSpring( - from: -animationInContentXDistance as NSNumber, to: 0.0 as NSNumber, - keyPath: "position.x", - duration: duration, - delay: 0.0, - initialVelocity: 0.0, - damping: springDamping, - additive: true - ) } + } else { + animationInContentXDistance = contentParentGlobalFrameOffsetX + } + + if animationInContentXDistance != 0.0 { + contentNode.layer.animateSpring( + from: -animationInContentXDistance as NSNumber, to: 0.0 as NSNumber, + keyPath: "position.x", + duration: duration, + delay: 0.0, + initialVelocity: 0.0, + damping: springDamping, + additive: true + ) } contentNode.layer.animateSpring( @@ -1416,17 +1436,21 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo } else if contentX + contentWidth > layout.size.width / 2.0{ let fixedContentX = layout.size.width - (contentX + contentWidth) animationInContentXDistance = contentX - fixedContentX - - contentNode.offsetContainerNode.layer.animate( - from: -animationInContentXDistance as NSNumber, - to: 0.0 as NSNumber, - keyPath: "position.x", - timingFunction: timingFunction, - duration: duration, - delay: 0.0, - additive: true - ) } + } else { + animationInContentXDistance = -contentParentGlobalFrameOffsetX + } + + if animationInContentXDistance != 0.0 { + contentNode.offsetContainerNode.layer.animate( + from: -animationInContentXDistance as NSNumber, + to: 0.0 as NSNumber, + keyPath: "position.x", + timingFunction: timingFunction, + duration: duration, + delay: 0.0, + additive: true + ) } contentNode.offsetContainerNode.position = contentNode.offsetContainerNode.position.offsetBy(dx: animationInContentXDistance, dy: -animationInContentYDistance) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 97cad329f7..e8fc71dcb5 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -4424,7 +4424,11 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } else if let peer = forwardInfo.source ?? forwardInfo.author { item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } else if let _ = forwardInfo.authorSignature { - item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) + var subRect: CGRect? + if let textNode = forwardInfoNode.textNode { + subRect = textNode.frame + } + item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, subRect) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift index 427ed60fa7..f924d4be48 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift @@ -73,7 +73,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { } } - private var textNode: TextNode? + public private(set) var textNode: TextNode? private var credibilityIconNode: ASImageNode? private var infoNode: InfoButtonNode? private var expiredStoryIconView: UIImageView? diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift index f8232cb5de..1cfb2d9641 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift @@ -2892,6 +2892,7 @@ private final class ExtractedContentSourceImpl: ContextExtractedContentSource { var keepInPlace: Bool let ignoreContentTouches: Bool = true let blurBackground: Bool + let adjustContentForSideInset: Bool = true private let controller: ViewController private let sourceNode: ContextExtractedContentContainingNode