Improve context panels appearance animation

This commit is contained in:
Ilya Laktyushin
2021-06-17 16:22:53 +03:00
parent bb28e0e4d3
commit 302cfa6390
9 changed files with 61 additions and 25 deletions

View File

@@ -120,6 +120,7 @@ final class CommandMenuChatInputContextPanelNode: ChatInputContextPanelNode {
if sendImmediately {
interfaceInteraction.sendBotCommand(command.peer, "/" + command.command.text)
} else {
interfaceInteraction.updateShowCommands { _ in return false }
interfaceInteraction.updateTextInputStateAndMode { textInputState, inputMode in
var commandQueryRange: NSRange?
inner: for (range, type, _) in textInputStateContextQueryRangeAndType(textInputState) {
@@ -128,7 +129,6 @@ final class CommandMenuChatInputContextPanelNode: ChatInputContextPanelNode {
break inner
}
}
if let range = commandQueryRange {
let inputText = NSMutableAttributedString(attributedString: textInputState.inputText)
@@ -143,7 +143,6 @@ final class CommandMenuChatInputContextPanelNode: ChatInputContextPanelNode {
let selectionPosition = (inputText.string as NSString).length + 1
return (ChatTextInputState(inputText: inputText, selectionRange: selectionPosition ..< selectionPosition), inputMode)
}
return (textInputState, inputMode)
}
}
}
@@ -193,7 +192,10 @@ final class CommandMenuChatInputContextPanelNode: ChatInputContextPanelNode {
if let topItemOffset = topItemOffset {
let position = strongSelf.listView.layer.position
strongSelf.listView.layer.animatePosition(from: CGPoint(x: position.x, y: position.y + (strongSelf.listView.bounds.size.height - topItemOffset)), to: position, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring)
strongSelf.listView.position = CGPoint(x: position.x, y: position.y + (strongSelf.listView.bounds.size.height - topItemOffset))
ContainedViewLayoutTransition.animated(duration: 0.3, curve: .spring).animateView {
strongSelf.listView.position = position
}
}
}
})