Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions submodules/Display/Source/KeyboardManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ class KeyboardManager {
}
}

private func endAnimations(view: UIView) {
view.layer.removeAllAnimations()
for subview in view.subviews {
endAnimations(view: subview)
}
}

public func viewTreeContainsFirstResponder(view: UIView) -> Bool {
if view.isFirstResponder {
return true
Expand All @@ -149,18 +142,17 @@ public func viewTreeContainsFirstResponder(view: UIView) -> Bool {

public final class KeyboardViewManager {
private let host: StatusBarHost
var willDismissEditingWithoutAnimation: (() -> Void)?

init(host: StatusBarHost) {
self.host = host
}

public func dismissEditingWithoutAnimation(view: UIView) {
if viewTreeContainsFirstResponder(view: view) {
view.endEditing(true)
if let keyboardWindow = self.host.keyboardWindow {
for view in keyboardWindow.subviews {
endAnimations(view: view)
}
self.willDismissEditingWithoutAnimation?()
UIView.performWithoutAnimation {
view.endEditing(true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelega
return
}

topController.cancelInteractiveKeyboardGestures()
topController.isBeingInteractivelyPopped = true
topController.viewWillDisappear(true)
let topNode = topController.displayNode
var bottomControllerLayout = layout
Expand Down Expand Up @@ -299,6 +301,7 @@ public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelega
strongSelf.state.transition = nil

strongSelf.controllerRemoved(top.value)
topController.isBeingInteractivelyPopped = false
strongSelf.ignoreInputHeight = false
})
} else {
Expand All @@ -307,7 +310,8 @@ public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelega
return
}
strongSelf.state.transition = nil


top.value.isBeingInteractivelyPopped = false
top.value.viewDidAppear(true)
transition.previous.value.viewDidDisappear(true)
})
Expand Down
5 changes: 5 additions & 0 deletions submodules/Display/Source/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public protocol CustomViewControllerNavigationDataSummary: AnyObject {
private weak var activeInputView: UIResponder?

open var hasActiveInput: Bool = false
public internal(set) var isBeingInteractivelyPopped: Bool = false

open var overlayWantsToBeBelowKeyboard: Bool {
return false
Expand Down Expand Up @@ -657,6 +658,10 @@ public protocol CustomViewControllerNavigationDataSummary: AnyObject {
open func viewWillLeaveNavigation() {
}

open func cancelInteractiveKeyboardGestures() {
self.view.windowHost?.cancelInteractiveKeyboardGestures()
}

open override func viewDidAppear(_ animated: Bool) {
self.activeInputView = nil

Expand Down
23 changes: 23 additions & 0 deletions submodules/Display/Source/WindowContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public class Window1 {
private var statusBarHidden = false

private var shouldNotAnimateLikelyKeyboardAutocorrectionSwitch: Bool = false
private var suppressNextKeyboardHideAnimationUntil: Double?

public private(set) var forceInCallStatusBarText: String? = nil
public var inCallNavigate: (() -> Void)?
Expand Down Expand Up @@ -477,6 +478,10 @@ public class Window1 {
self.topPresentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics), transition: .immediate)
self.overlayPresentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics), transition: .immediate)

self.keyboardViewManager?.willDismissEditingWithoutAnimation = { [weak self] in
self?.suppressNextKeyboardHideAnimationUntil = CACurrentMediaTime() + 1.0
}

//TODO:release check old iOS
/*self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: UIApplication.willChangeStatusBarFrameNotification, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
if let strongSelf = self, strongSelf.statusBarHost != nil {
Expand Down Expand Up @@ -648,6 +653,9 @@ public class Window1 {
transition = .immediate
}
}
if strongSelf.shouldSuppressNextKeyboardHideAnimation(keyboardHeight: keyboardHeight) {
transition = .immediate
}

strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: transition, overrideTransition: false) }
}
Expand Down Expand Up @@ -717,6 +725,21 @@ public class Window1 {
self.hostView.containerView.addGestureRecognizer(recognizer)
self.hostView.containerView.addSubview(self.badgeView)
}

private func shouldSuppressNextKeyboardHideAnimation(keyboardHeight: CGFloat) -> Bool {
guard let suppressNextKeyboardHideAnimationUntil = self.suppressNextKeyboardHideAnimationUntil else {
return false
}
if suppressNextKeyboardHideAnimationUntil < CACurrentMediaTime() {
self.suppressNextKeyboardHideAnimationUntil = nil
return false
}
if keyboardHeight.isLessThanOrEqualTo(0.0) {
self.suppressNextKeyboardHideAnimationUntil = nil
return true
}
return false
}

public required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand Down
15 changes: 9 additions & 6 deletions submodules/TelegramUI/Sources/ChatController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7967,12 +7967,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
override public func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

if #available(iOS 18.0, *) {
} else {
//TODO:release
}
UIView.performWithoutAnimation {
self.view.endEditing(true)
if !self.isBeingInteractivelyPopped {
UIView.performWithoutAnimation {
self.view.endEditing(true)
}
}

self.chatDisplayNode.historyNode.canReadHistory.set(.single(false))
Expand Down Expand Up @@ -8048,6 +8046,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.chatDisplayNode.willNavigateAway()
}

override public func cancelInteractiveKeyboardGestures() {
super.cancelInteractiveKeyboardGestures()
self.chatDisplayNode.cancelInteractiveKeyboardGestures()
}

override public func inFocusUpdated(isInFocus: Bool) {
self.disableStickerAnimationsPromise.set(!isInFocus)
self.chatDisplayNode.inFocusUpdated(isInFocus: isInFocus)
Expand Down