Improvements

This commit is contained in:
Isaac 2024-04-09 17:08:31 +04:00
parent 004f49affe
commit 668ad2906d
5 changed files with 57 additions and 23 deletions

View File

@ -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<Bool, NoError> { get }
@ -2169,6 +2170,10 @@ public extension ContextExtractedContentSource {
return false
}
var adjustContentForSideInset: Bool {
return false
}
var actionsHorizontalAlignment: ContextActionsHorizontalAlignment {
return .default
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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?

View File

@ -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