mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-02 12:48:45 +00:00
Fix inconsistent iOS keyboard animation when switching from a text field with prediction enabled to one without autocorrection
This commit is contained in:
parent
7cb664eb14
commit
0c22b4b37c
@ -272,6 +272,8 @@ public class Window1 {
|
|||||||
public var previewThemeAccentColor: UIColor = .blue
|
public var previewThemeAccentColor: UIColor = .blue
|
||||||
public var previewThemeDarkBlur: Bool = false
|
public var previewThemeDarkBlur: Bool = false
|
||||||
|
|
||||||
|
private var shouldNotAnimateLikelyKeyboardAutocorrectionSwitch: Bool = false
|
||||||
|
|
||||||
public private(set) var forceInCallStatusBarText: String? = nil
|
public private(set) var forceInCallStatusBarText: String? = nil
|
||||||
public var inCallNavigate: (() -> Void)? {
|
public var inCallNavigate: (() -> Void)? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -522,7 +524,15 @@ public class Window1 {
|
|||||||
transitionCurve = .easeInOut
|
transitionCurve = .easeInOut
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: .animated(duration: duration, curve: transitionCurve), overrideTransition: false) }
|
var transition: ContainedViewLayoutTransition = .animated(duration: duration, curve: transitionCurve)
|
||||||
|
|
||||||
|
if strongSelf.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch, let inputHeight = strongSelf.windowLayout.inputHeight {
|
||||||
|
if abs(inputHeight - keyboardHeight) <= 44.1 {
|
||||||
|
transition = .immediate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: transition, overrideTransition: false) }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1203,4 +1213,11 @@ public class Window1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func doNotAnimateLikelyKeyboardAutocorrectionSwitch() {
|
||||||
|
self.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch = true
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3222,8 +3222,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}, beginMessageSearch: { [weak self] domain, query in
|
}, beginMessageSearch: { [weak self] domain, query in
|
||||||
if let strongSelf = self {
|
guard let strongSelf = self else {
|
||||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in
|
return
|
||||||
|
}
|
||||||
|
var interactive = true
|
||||||
|
if strongSelf.chatDisplayNode.isInputViewFocused {
|
||||||
|
interactive = false
|
||||||
|
strongSelf.context.sharedContext.mainWindow?.doNotAnimateLikelyKeyboardAutocorrectionSwitch()
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: interactive, { current in
|
||||||
return current.updatedTitlePanelContext {
|
return current.updatedTitlePanelContext {
|
||||||
if let index = $0.firstIndex(where: {
|
if let index = $0.firstIndex(where: {
|
||||||
switch $0 {
|
switch $0 {
|
||||||
@ -3242,7 +3250,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}.updatedSearch(current.search == nil ? ChatSearchData(domain: domain).withUpdatedQuery(query) : current.search?.withUpdatedDomain(domain).withUpdatedQuery(query))
|
}.updatedSearch(current.search == nil ? ChatSearchData(domain: domain).withUpdatedQuery(query) : current.search?.withUpdatedDomain(domain).withUpdatedQuery(query))
|
||||||
})
|
})
|
||||||
strongSelf.updateItemNodesSearchTextHighlightStates()
|
strongSelf.updateItemNodesSearchTextHighlightStates()
|
||||||
}
|
|
||||||
}, dismissMessageSearch: { [weak self] in
|
}, dismissMessageSearch: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in
|
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in
|
||||||
@ -4384,7 +4391,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return a && b
|
return a && b
|
||||||
})
|
})
|
||||||
|
|
||||||
self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings)
|
self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings, fontSize: self.presentationInterfaceState.fontSize)
|
||||||
|
|
||||||
self.recentlyUsedInlineBotsDisposable = (recentlyUsedInlineBots(postbox: self.context.account.postbox) |> deliverOnMainQueue).start(next: { [weak self] peers in
|
self.recentlyUsedInlineBotsDisposable = (recentlyUsedInlineBots(postbox: self.context.account.postbox) |> deliverOnMainQueue).start(next: { [weak self] peers in
|
||||||
self?.recentlyUsedInlineBotsValue = peers.filter({ $0.1 >= 0.14 }).map({ $0.0 })
|
self?.recentlyUsedInlineBotsValue = peers.filter({ $0.1 >= 0.14 }).map({ $0.0 })
|
||||||
|
|||||||
@ -97,6 +97,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
private var titleAccessoryPanelNode: ChatTitleAccessoryPanelNode?
|
private var titleAccessoryPanelNode: ChatTitleAccessoryPanelNode?
|
||||||
|
|
||||||
private var inputPanelNode: ChatInputPanelNode?
|
private var inputPanelNode: ChatInputPanelNode?
|
||||||
|
private weak var currentDismissedInputPanelNode: ASDisplayNode?
|
||||||
private var secondaryInputPanelNode: ChatInputPanelNode?
|
private var secondaryInputPanelNode: ChatInputPanelNode?
|
||||||
private var accessoryPanelNode: AccessoryPanelNode?
|
private var accessoryPanelNode: AccessoryPanelNode?
|
||||||
private var inputContextPanelNode: ChatInputContextPanelNode?
|
private var inputContextPanelNode: ChatInputContextPanelNode?
|
||||||
@ -1105,7 +1106,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
inputPanelNode.frame = apparentInputPanelFrame.offsetBy(dx: 0.0, dy: apparentInputPanelFrame.height + previousInputPanelBackgroundFrame.maxY - apparentInputBackgroundFrame.maxY)
|
inputPanelNode.frame = apparentInputPanelFrame.offsetBy(dx: 0.0, dy: apparentInputPanelFrame.height + previousInputPanelBackgroundFrame.maxY - apparentInputBackgroundFrame.maxY)
|
||||||
inputPanelNode.alpha = 0.0
|
inputPanelNode.alpha = 0.0
|
||||||
}
|
}
|
||||||
|
if !transition.isAnimated {
|
||||||
|
inputPanelNode.layer.removeAllAnimations()
|
||||||
|
if let currentDismissedInputPanelNode = self.currentDismissedInputPanelNode, inputPanelNode is ChatSearchInputPanelNode {
|
||||||
|
currentDismissedInputPanelNode.layer.removeAllAnimations()
|
||||||
|
}
|
||||||
|
}
|
||||||
transition.updateFrame(node: inputPanelNode, frame: apparentInputPanelFrame)
|
transition.updateFrame(node: inputPanelNode, frame: apparentInputPanelFrame)
|
||||||
transition.updateAlpha(node: inputPanelNode, alpha: 1.0)
|
transition.updateAlpha(node: inputPanelNode, alpha: 1.0)
|
||||||
}
|
}
|
||||||
@ -1197,12 +1203,19 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
if let dismissedInputPanelNode = dismissedInputPanelNode, dismissedInputPanelNode !== self.secondaryInputPanelNode {
|
if let dismissedInputPanelNode = dismissedInputPanelNode, dismissedInputPanelNode !== self.secondaryInputPanelNode {
|
||||||
var frameCompleted = false
|
var frameCompleted = false
|
||||||
var alphaCompleted = false
|
var alphaCompleted = false
|
||||||
|
self.currentDismissedInputPanelNode = dismissedInputPanelNode
|
||||||
let completed = { [weak self, weak dismissedInputPanelNode] in
|
let completed = { [weak self, weak dismissedInputPanelNode] in
|
||||||
if let strongSelf = self, let dismissedInputPanelNode = dismissedInputPanelNode, strongSelf.inputPanelNode === dismissedInputPanelNode {
|
guard let strongSelf = self, let dismissedInputPanelNode = dismissedInputPanelNode else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if strongSelf.currentDismissedInputPanelNode === dismissedInputPanelNode {
|
||||||
|
strongSelf.currentDismissedInputPanelNode = nil
|
||||||
|
}
|
||||||
|
if strongSelf.inputPanelNode === dismissedInputPanelNode {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if frameCompleted && alphaCompleted {
|
if frameCompleted && alphaCompleted {
|
||||||
dismissedInputPanelNode?.removeFromSupernode()
|
dismissedInputPanelNode.removeFromSupernode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let transitionTargetY = layout.size.height - insets.bottom
|
let transitionTargetY = layout.size.height - insets.bottom
|
||||||
@ -2258,4 +2271,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
completion?()
|
completion?()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setEnablePredictiveTextInput(_ value: Bool) {
|
||||||
|
self.textInputPanelNode?.enablePredictiveInput = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user