mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
iPad context menu layout
This commit is contained in:
@@ -755,9 +755,12 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case .controller:
|
case let .controller(source):
|
||||||
if let contentNode = controllerContentNode {
|
if let contentNode = controllerContentNode {
|
||||||
var defaultContentSize = CGSize(width: layout.size.width - 12.0 * 2.0, height: layout.size.height - 12.0 * 2.0 - contentTopInset - layout.safeInsets.bottom)
|
var defaultContentSize = CGSize(width: layout.size.width - 12.0 * 2.0, height: layout.size.height - 12.0 * 2.0 - contentTopInset - layout.safeInsets.bottom)
|
||||||
|
if case .regular = layout.metrics.widthClass {
|
||||||
|
defaultContentSize.width = min(defaultContentSize.width, 400.0)
|
||||||
|
}
|
||||||
defaultContentSize.height = min(defaultContentSize.height, 460.0)
|
defaultContentSize.height = min(defaultContentSize.height, 460.0)
|
||||||
|
|
||||||
let contentSize: CGSize
|
let contentSize: CGSize
|
||||||
@@ -770,7 +773,30 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
isContentResizeableVertically = true
|
isContentResizeableVertically = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if case .regular = layout.metrics.widthClass {
|
||||||
|
if let transitionInfo = source.transitionInfo(), let (sourceView, sourceRect) = transitionInfo.sourceNode() {
|
||||||
|
let sourcePoint = sourceView.convert(sourceRect.center, to: self.view)
|
||||||
|
|
||||||
|
contentRect = CGRect(origin: CGPoint(x: sourcePoint.x - floor(contentSize.width * 0.5), y: sourcePoint.y - floor(contentSize.height * 0.5)), size: contentSize)
|
||||||
|
if contentRect.origin.x < 0.0 {
|
||||||
|
contentRect.origin.x = 0.0
|
||||||
|
}
|
||||||
|
if contentRect.origin.y < 0.0 {
|
||||||
|
contentRect.origin.y = 0.0
|
||||||
|
}
|
||||||
|
if contentRect.origin.x + contentRect.width > layout.size.width {
|
||||||
|
contentRect.origin.x = layout.size.width - contentRect.width
|
||||||
|
}
|
||||||
|
if contentRect.origin.y + contentRect.height > layout.size.height {
|
||||||
|
contentRect.origin.y = layout.size.height - contentRect.height
|
||||||
|
}
|
||||||
|
} else {
|
||||||
contentRect = CGRect(origin: CGPoint(x: floor((layout.size.width - contentSize.width) * 0.5), y: floor((layout.size.height - contentSize.height) * 0.5)), size: contentSize)
|
contentRect = CGRect(origin: CGPoint(x: floor((layout.size.width - contentSize.width) * 0.5), y: floor((layout.size.height - contentSize.height) * 0.5)), size: contentSize)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
contentRect = CGRect(origin: CGPoint(x: floor((layout.size.width - contentSize.width) * 0.5), y: floor((layout.size.height - contentSize.height) * 0.5)), size: contentSize)
|
||||||
|
}
|
||||||
|
|
||||||
contentParentGlobalFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: layout.size.height))
|
contentParentGlobalFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: layout.size.height))
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
@@ -815,9 +841,9 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
|
|
||||||
let actionsStackPresentation: ContextControllerActionsStackNode.Presentation
|
let actionsStackPresentation: ContextControllerActionsStackNode.Presentation
|
||||||
switch self.source {
|
switch self.source {
|
||||||
case .location, .reference:
|
case .location, .reference, .controller:
|
||||||
actionsStackPresentation = .inline
|
actionsStackPresentation = .inline
|
||||||
case .extracted, .controller:
|
case .extracted:
|
||||||
actionsStackPresentation = .modal
|
actionsStackPresentation = .modal
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,7 +867,10 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
|
|||||||
contentHeight = min(contentHeight, contentRect.height)
|
contentHeight = min(contentHeight, contentRect.height)
|
||||||
contentHeight = max(contentHeight, 200.0)
|
contentHeight = max(contentHeight, 200.0)
|
||||||
|
|
||||||
contentRect = CGRect(origin: CGPoint(x: 12.0, y: floor((layout.size.height - contentHeight) * 0.5)), size: CGSize(width: layout.size.width - 12.0 * 2.0, height: contentHeight))
|
if case .regular = layout.metrics.widthClass {
|
||||||
|
} else {
|
||||||
|
contentRect = CGRect(origin: CGPoint(x: contentRect.minX, y: floor(contentRect.midY - contentHeight * 0.5)), size: CGSize(width: contentRect.width, height: contentHeight))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isAnimatingOut = false
|
var isAnimatingOut = false
|
||||||
|
|||||||
@@ -570,6 +570,14 @@ final class ContextSourceContainer: ASDisplayNode {
|
|||||||
transition: .immediate
|
transition: .immediate
|
||||||
)
|
)
|
||||||
case .controller:
|
case .controller:
|
||||||
|
if case .regular = layout.metrics.widthClass {
|
||||||
|
self.backgroundNode.updateColor(
|
||||||
|
color: UIColor(white: 0.0, alpha: 0.4),
|
||||||
|
enableBlur: false,
|
||||||
|
forceKeepBlur: false,
|
||||||
|
transition: .immediate
|
||||||
|
)
|
||||||
|
} else {
|
||||||
self.backgroundNode.updateColor(
|
self.backgroundNode.updateColor(
|
||||||
color: presentationData.theme.contextMenu.dimColor,
|
color: presentationData.theme.contextMenu.dimColor,
|
||||||
enableBlur: true,
|
enableBlur: true,
|
||||||
@@ -578,6 +586,7 @@ final class ContextSourceContainer: ASDisplayNode {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: layout.size), beginWithCurrentState: true)
|
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: layout.size), beginWithCurrentState: true)
|
||||||
self.backgroundNode.update(size: layout.size, transition: transition)
|
self.backgroundNode.update(size: layout.size, transition: transition)
|
||||||
|
|||||||
@@ -5,22 +5,30 @@ public class OutgoingChatContextResultMessageAttribute: MessageAttribute {
|
|||||||
public let queryId: Int64
|
public let queryId: Int64
|
||||||
public let id: String
|
public let id: String
|
||||||
public let hideVia: Bool
|
public let hideVia: Bool
|
||||||
|
public let webpageUrl: String?
|
||||||
|
|
||||||
public init(queryId: Int64, id: String, hideVia: Bool) {
|
public init(queryId: Int64, id: String, hideVia: Bool, webpageUrl: String?) {
|
||||||
self.queryId = queryId
|
self.queryId = queryId
|
||||||
self.id = id
|
self.id = id
|
||||||
self.hideVia = hideVia
|
self.hideVia = hideVia
|
||||||
|
self.webpageUrl = webpageUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(decoder: PostboxDecoder) {
|
required public init(decoder: PostboxDecoder) {
|
||||||
self.queryId = decoder.decodeInt64ForKey("q", orElse: 0)
|
self.queryId = decoder.decodeInt64ForKey("q", orElse: 0)
|
||||||
self.id = decoder.decodeStringForKey("i", orElse: "")
|
self.id = decoder.decodeStringForKey("i", orElse: "")
|
||||||
self.hideVia = decoder.decodeBoolForKey("v", orElse: false)
|
self.hideVia = decoder.decodeBoolForKey("v", orElse: false)
|
||||||
|
self.webpageUrl = decoder.decodeOptionalStringForKey("wurl")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
encoder.encodeInt64(self.queryId, forKey: "q")
|
encoder.encodeInt64(self.queryId, forKey: "q")
|
||||||
encoder.encodeString(self.id, forKey: "i")
|
encoder.encodeString(self.id, forKey: "i")
|
||||||
encoder.encodeBool(self.hideVia, forKey: "v")
|
encoder.encodeBool(self.hideVia, forKey: "v")
|
||||||
|
if let webpageUrl = self.webpageUrl {
|
||||||
|
encoder.encodeString(webpageUrl, forKey: "wurl")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "wurl")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ func _internal_outgoingMessageWithChatContextResult(to peerId: PeerId, threadId:
|
|||||||
replyToMessageId = EngineMessageReplySubject(messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: MessageId.Id(clamping: threadId)), quote: nil)
|
replyToMessageId = EngineMessageReplySubject(messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: MessageId.Id(clamping: threadId)), quote: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var webpageUrl: String?
|
||||||
|
if case let .webpage(_, _, url, _, _) = result.message {
|
||||||
|
webpageUrl = url
|
||||||
|
}
|
||||||
|
|
||||||
var attributes: [MessageAttribute] = []
|
var attributes: [MessageAttribute] = []
|
||||||
attributes.append(OutgoingChatContextResultMessageAttribute(queryId: result.queryId, id: result.id, hideVia: hideVia))
|
attributes.append(OutgoingChatContextResultMessageAttribute(queryId: result.queryId, id: result.id, hideVia: hideVia, webpageUrl: webpageUrl))
|
||||||
if !hideVia {
|
if !hideVia {
|
||||||
attributes.append(InlineBotMessageAttribute(peerId: botId, title: nil))
|
attributes.append(InlineBotMessageAttribute(peerId: botId, title: nil))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user