diff --git a/submodules/ContextUI/Sources/ContextController.swift b/submodules/ContextUI/Sources/ContextController.swift index f10636dcad..ea74e730f7 100644 --- a/submodules/ContextUI/Sources/ContextController.swift +++ b/submodules/ContextUI/Sources/ContextController.swift @@ -1325,7 +1325,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi var originalContentFrame = CGRect(origin: CGPoint(x: originalContentX, y: originalContentY), size: originalProjectedContentViewFrame.1.size) let topEdge = max(contentTopInset, self.contentAreaInScreenSpace?.minY ?? 0.0) - let bottomEdge = max(layout.intrinsicInsets.bottom, self.contentAreaInScreenSpace?.maxY ?? layout.size.height) + let bottomEdge = min(layout.size.height - layout.intrinsicInsets.bottom, self.contentAreaInScreenSpace?.maxY ?? layout.size.height) if originalContentFrame.minY < topEdge { let requiredOffset = topEdge - originalContentFrame.minY @@ -1333,8 +1333,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi let offset = min(requiredOffset, availableOffset) originalActionsFrame = originalActionsFrame.offsetBy(dx: 0.0, dy: offset) originalContentFrame = originalContentFrame.offsetBy(dx: 0.0, dy: offset) - } else if originalContentFrame.maxY > bottomEdge { - let requiredOffset = bottomEdge - originalContentFrame.maxY + } else if originalActionsFrame.maxY > bottomEdge { + let requiredOffset = bottomEdge - originalActionsFrame.maxY let offset = requiredOffset originalActionsFrame = originalActionsFrame.offsetBy(dx: 0.0, dy: offset) originalContentFrame = originalContentFrame.offsetBy(dx: 0.0, dy: offset) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index b0f1752e3d..e2d2bf5bde 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -7644,10 +7644,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.push(controller) } }, openSendAsPeer: { [weak self] node, gesture in - guard let strongSelf = self, let node = node as? ContextReferenceContentNode, let peers = strongSelf.presentationInterfaceState.sendAsPeers else { + guard let strongSelf = self, let node = node as? ContextReferenceContentNode, let peers = strongSelf.presentationInterfaceState.sendAsPeers, let layout = strongSelf.validLayout else { return } + let cleanInsets = layout.intrinsicInsets + let insets = layout.insets(options: .input) + let bottomInset = max(insets.bottom, cleanInsets.bottom) + 43.0 + let defaultMyPeerId: PeerId if let channel = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case .group = channel.info, channel.hasPermission(.canBeAnonymous) { defaultMyPeerId = channel.id @@ -7660,7 +7664,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G items.append(.custom(ChatSendAsPeerTitleContextItem(text: strongSelf.presentationInterfaceState.strings.Conversation_SendMesageAs.uppercased()), false)) items.append(.custom(ChatSendAsPeerListContextItem(context: strongSelf.context, chatPeerId: peerId, peers: peers, selectedPeerId: myPeerId), false)) - let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .reference(ChatControllerContextReferenceContentSource(controller: strongSelf, sourceNode: node)), items: .single(ContextController.Items(items: items)), gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .reference(ChatControllerContextReferenceContentSource(controller: strongSelf, sourceNode: node, insets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: bottomInset, right: 0.0))), items: .single(ContextController.Items(items: items)), gesture: gesture) contextController.dismissed = { [weak self] in if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(interactive: true, { @@ -14179,14 +14183,16 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent private final class ChatControllerContextReferenceContentSource: ContextReferenceContentSource { private let controller: ViewController private let sourceNode: ContextReferenceContentNode + private let insets: UIEdgeInsets - init(controller: ViewController, sourceNode: ContextReferenceContentNode) { + init(controller: ViewController, sourceNode: ContextReferenceContentNode, insets: UIEdgeInsets) { self.controller = controller self.sourceNode = sourceNode + self.insets = insets } func transitionInfo() -> ContextControllerReferenceViewInfo? { - return ContextControllerReferenceViewInfo(referenceNode: self.sourceNode, contentAreaInScreenSpace: UIScreen.main.bounds.insetBy(dx: 0.0, dy: 72.0)) + return ContextControllerReferenceViewInfo(referenceNode: self.sourceNode, contentAreaInScreenSpace: UIScreen.main.bounds.inset(by: insets)) } }