diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 2c25243c82..4141be56e5 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -2937,7 +2937,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch // MARK: Swiftgram var toolbarOffset: CGFloat = 0.0 - toolbarOffset = layoutToolbar(transition: transition, panelHeight: panelHeight, width: width, leftInset: originalLeftInset, rightInset: rightInset, displayBotStartButton: displayBotStartButton) + toolbarOffset = layoutToolbar(transition: transition, panelHeight: panelHeight, width: width, leftInset: originalLeftInset, rightInset: rightInset, displayBotStartButton: displayBotStartButton, animatedTransition: animatedTransition) return panelHeight + toolbarOffset } @@ -5224,7 +5224,7 @@ extension ChatTextInputPanelNode { self.view.addSubview(toolbarHostingController.view) } - func layoutToolbar(transition: ContainedViewLayoutTransition, panelHeight: CGFloat, width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, displayBotStartButton: Bool) -> CGFloat { + func layoutToolbar(transition: ContainedViewLayoutTransition, panelHeight: CGFloat, width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, displayBotStartButton: Bool, animatedTransition: Bool) -> CGFloat { var toolbarHeight: CGFloat = 0.0 var toolbarSpacing: CGFloat = 0.0 if #available(iOS 13.0, *) { @@ -5232,15 +5232,26 @@ extension ChatTextInputPanelNode { if displayBotStartButton { toolbarHostingController.view.isHidden = true } else if !self.isFocused { - transition.updateAlpha(layer: toolbarHostingController.view.layer, alpha: 0.0, completion: { _ in + if animatedTransition { + transition.updateAlpha(layer: toolbarHostingController.view.layer, alpha: 0.0, completion: { _ in + toolbarHostingController.view.isHidden = true + }) + } else { + toolbarHostingController.view.alpha = 0.0 toolbarHostingController.view.isHidden = true - }) + } } else { toolbarHeight = 44.0 toolbarSpacing = 1.0 + let newFrame = CGRect(origin: CGPoint(x: leftInset, y: panelHeight + toolbarSpacing), size: CGSize(width: width - rightInset - leftInset, height: toolbarHeight)) + if animatedTransition { + transition.updateFrame(view: toolbarHostingController.view, frame: newFrame) + transition.updateAlpha(layer: toolbarHostingController.view.layer, alpha: 1.0) + } else { + toolbarHostingController.view.frame = newFrame + toolbarHostingController.view.alpha = 1.0 + } toolbarHostingController.view.isHidden = false - transition.updateFrame(view: toolbarHostingController.view, frame: CGRect(origin: CGPoint(x: leftInset, y: panelHeight + toolbarSpacing), size: CGSize(width: width - rightInset - leftInset, height: toolbarHeight))) - transition.updateAlpha(layer: toolbarHostingController.view.layer, alpha: 1.0) } } }