mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Fix context actions positioning
This commit is contained in:
@@ -2201,16 +2201,22 @@ public extension ContextLocationContentSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class ContextControllerReferenceViewInfo {
|
public final class ContextControllerReferenceViewInfo {
|
||||||
|
public enum ActionsPosition {
|
||||||
|
case bottom
|
||||||
|
case top
|
||||||
|
}
|
||||||
public let referenceView: UIView
|
public let referenceView: UIView
|
||||||
public let contentAreaInScreenSpace: CGRect
|
public let contentAreaInScreenSpace: CGRect
|
||||||
public let insets: UIEdgeInsets
|
public let insets: UIEdgeInsets
|
||||||
public let customPosition: CGPoint?
|
public let customPosition: CGPoint?
|
||||||
|
public let actionsPosition: ActionsPosition
|
||||||
|
|
||||||
public init(referenceView: UIView, contentAreaInScreenSpace: CGRect, insets: UIEdgeInsets = UIEdgeInsets(), customPosition: CGPoint? = nil) {
|
public init(referenceView: UIView, contentAreaInScreenSpace: CGRect, insets: UIEdgeInsets = UIEdgeInsets(), customPosition: CGPoint? = nil, actionsPosition: ActionsPosition = .bottom) {
|
||||||
self.referenceView = referenceView
|
self.referenceView = referenceView
|
||||||
self.contentAreaInScreenSpace = contentAreaInScreenSpace
|
self.contentAreaInScreenSpace = contentAreaInScreenSpace
|
||||||
self.insets = insets
|
self.insets = insets
|
||||||
self.customPosition = customPosition
|
self.customPosition = customPosition
|
||||||
|
self.actionsPosition = actionsPosition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -756,8 +756,12 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
|
|
||||||
transition.updateFrame(node: self.contentRectDebugNode, frame: contentRect, beginWithCurrentState: true)
|
transition.updateFrame(node: self.contentRectDebugNode, frame: contentRect, beginWithCurrentState: true)
|
||||||
|
|
||||||
var actionsFrame = CGRect(origin: CGPoint(x: actionsSideInset, y: contentRect.maxY + contentActionsSpacing), size: actionsSize)
|
var actionsFrame: CGRect
|
||||||
|
if case let .reference(source) = self.source, let actionsPosition = source.transitionInfo()?.actionsPosition, case .top = actionsPosition {
|
||||||
|
actionsFrame = CGRect(origin: CGPoint(x: actionsSideInset, y: contentRect.minY - contentActionsSpacing - actionsSize.height), size: actionsSize)
|
||||||
|
} else {
|
||||||
|
actionsFrame = CGRect(origin: CGPoint(x: actionsSideInset, y: contentRect.maxY + contentActionsSpacing), size: actionsSize)
|
||||||
|
}
|
||||||
var contentVerticalOffset: CGFloat = 0.0
|
var contentVerticalOffset: CGFloat = 0.0
|
||||||
|
|
||||||
if keepInPlace, case .extracted = self.source {
|
if keepInPlace, case .extracted = self.source {
|
||||||
@@ -774,17 +778,6 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
if let reactionContextNode = self.reactionContextNode {
|
if let reactionContextNode = self.reactionContextNode {
|
||||||
additionalVisibleOffsetY += reactionContextNode.visibleExtensionDistance
|
additionalVisibleOffsetY += reactionContextNode.visibleExtensionDistance
|
||||||
}
|
}
|
||||||
if case let .reference(source) = self.source {
|
|
||||||
var actionsFrameIsOutOfScreen = false
|
|
||||||
if let contentAreaInScreenSpace = source.transitionInfo()?.contentAreaInScreenSpace {
|
|
||||||
if !contentAreaInScreenSpace.contains(actionsFrame) {
|
|
||||||
actionsFrameIsOutOfScreen = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if actionsFrame.maxY > layout.size.height || actionsFrameIsOutOfScreen {
|
|
||||||
actionsFrame.origin.y = contentRect.minY - actionsSize.height - contentActionsSpacing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if case .center = actionsHorizontalAlignment {
|
if case .center = actionsHorizontalAlignment {
|
||||||
actionsFrame.origin.x = floor(contentParentGlobalFrame.minX + contentRect.midX - actionsFrame.width / 2.0)
|
actionsFrame.origin.x = floor(contentParentGlobalFrame.minX + contentRect.midX - actionsFrame.width / 2.0)
|
||||||
if actionsFrame.maxX > layout.size.width - actionsEdgeInset {
|
if actionsFrame.maxX > layout.size.width - actionsEdgeInset {
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ private final class ReferenceContentSource: ContextReferenceContentSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func transitionInfo() -> ContextControllerReferenceViewInfo? {
|
func transitionInfo() -> ContextControllerReferenceViewInfo? {
|
||||||
return ContextControllerReferenceViewInfo(referenceView: self.sourceView, contentAreaInScreenSpace: self.contentArea, customPosition: self.customPosition)
|
return ContextControllerReferenceViewInfo(referenceView: self.sourceView, contentAreaInScreenSpace: self.contentArea, customPosition: self.customPosition, actionsPosition: .top)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user