mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix inputHeight edge cases
This commit is contained in:
parent
772f461352
commit
ba3d2a2430
@ -306,7 +306,11 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
var updatedStatusBarStyle = self.statusBarStyle
|
var updatedStatusBarStyle = self.statusBarStyle
|
||||||
if let top = self.state.top {
|
if let top = self.state.top {
|
||||||
self.applyLayout(layout: layout, to: top, isMaster: true, transition: transition)
|
var updatedLayout = layout
|
||||||
|
if let topTransition = self.state.transition {
|
||||||
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
|
self.applyLayout(layout: updatedLayout, to: top, isMaster: true, transition: transition)
|
||||||
updatedStatusBarStyle = top.value.statusBar.statusBarStyle
|
updatedStatusBarStyle = top.value.statusBar.statusBarStyle
|
||||||
} else {
|
} else {
|
||||||
updatedStatusBarStyle = .Ignore
|
updatedStatusBarStyle = .Ignore
|
||||||
@ -364,6 +368,10 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
guard let strongSelf = self, let topTransition = topTransition, strongSelf.state.transition === topTransition else {
|
guard let strongSelf = self, let topTransition = topTransition, strongSelf.state.transition === topTransition else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if viewTreeContainsFirstResponder(view: topTransition.previous.value.view) {
|
||||||
|
strongSelf.ignoreInputHeight = true
|
||||||
|
}
|
||||||
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: topTransition.previous.value.view)
|
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: topTransition.previous.value.view)
|
||||||
strongSelf.state.transition = nil
|
strongSelf.state.transition = nil
|
||||||
|
|
||||||
@ -376,6 +384,8 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
strongSelf.applyLayout(layout: layout, to: toValue, isMaster: true, transition: .immediate)
|
strongSelf.applyLayout(layout: layout, to: toValue, isMaster: true, transition: .immediate)
|
||||||
toValue.value.viewDidAppear(true)
|
toValue.value.viewDidAppear(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strongSelf.ignoreInputHeight = false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if let fromValue = fromValue {
|
if let fromValue = fromValue {
|
||||||
|
@ -129,6 +129,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
private var validStatusBarStyle: NavigationStatusBarStyle?
|
private var validStatusBarStyle: NavigationStatusBarStyle?
|
||||||
private var validStatusBarHidden: Bool = false
|
private var validStatusBarHidden: Bool = false
|
||||||
|
|
||||||
|
private var ignoreInputHeight: Bool = false
|
||||||
private var currentStatusBarExternalHidden: Bool = false
|
private var currentStatusBarExternalHidden: Bool = false
|
||||||
|
|
||||||
private var scheduledLayoutTransitionRequestId: Int = 0
|
private var scheduledLayoutTransitionRequestId: Int = 0
|
||||||
@ -257,6 +258,14 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
private func updateContainers(layout rawLayout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
private func updateContainers(layout rawLayout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
var layout = rawLayout
|
var layout = rawLayout
|
||||||
|
|
||||||
|
if self.ignoreInputHeight {
|
||||||
|
if layout.inputHeight == nil {
|
||||||
|
self.ignoreInputHeight = false
|
||||||
|
} else {
|
||||||
|
layout = layout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let globalScrollToTopNode = self.globalScrollToTopNode {
|
if let globalScrollToTopNode = self.globalScrollToTopNode {
|
||||||
globalScrollToTopNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -1.0), size: CGSize(width: layout.size.width, height: 1.0))
|
globalScrollToTopNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -1.0), size: CGSize(width: layout.size.width, height: 1.0))
|
||||||
}
|
}
|
||||||
@ -317,14 +326,16 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
strongSelf.updateContainers(layout: layout, transition: transition)
|
strongSelf.updateContainers(layout: layout, transition: transition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modalContainer.interactivelyDismissed = { [weak self, weak modalContainer] in
|
modalContainer.interactivelyDismissed = { [weak self, weak modalContainer] hadInputFocus in
|
||||||
guard let strongSelf = self, let modalContainer = modalContainer else {
|
guard let strongSelf = self, let modalContainer = modalContainer else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let controllers = strongSelf._viewControllers.filter { controller in
|
let controllers = strongSelf._viewControllers.filter { controller in
|
||||||
return !modalContainer.container.controllers.contains(where: { $0 === controller })
|
return !modalContainer.container.controllers.contains(where: { $0 === controller })
|
||||||
}
|
}
|
||||||
|
strongSelf.ignoreInputHeight = hadInputFocus
|
||||||
strongSelf.setViewControllers(controllers, animated: false)
|
strongSelf.setViewControllers(controllers, animated: false)
|
||||||
|
strongSelf.ignoreInputHeight = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modalContainers.append(modalContainer)
|
modalContainers.append(modalContainer)
|
||||||
@ -332,7 +343,12 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
|
|
||||||
for container in self.modalContainers {
|
for container in self.modalContainers {
|
||||||
if !modalContainers.contains(where: { $0 === container }) {
|
if !modalContainers.contains(where: { $0 === container }) {
|
||||||
transition = container.dismiss(transition: transition, completion: { [weak container] in
|
if viewTreeContainsFirstResponder(view: container.view) {
|
||||||
|
self.ignoreInputHeight = true
|
||||||
|
container.view.endEditing(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
transition = container.dismiss(transition: transition, completion: { [weak self, weak container] in
|
||||||
container?.removeFromSupernode()
|
container?.removeFromSupernode()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -825,7 +841,11 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
public func filterController(_ controller: ViewController, animated: Bool) {
|
public func filterController(_ controller: ViewController, animated: Bool) {
|
||||||
let controllers = self.viewControllers.filter({ $0 !== controller })
|
let controllers = self.viewControllers.filter({ $0 !== controller })
|
||||||
if controllers.count != self.viewControllers.count {
|
if controllers.count != self.viewControllers.count {
|
||||||
|
if controller.isViewLoaded && viewTreeContainsFirstResponder(view: controller.view) {
|
||||||
|
self.ignoreInputHeight = true
|
||||||
|
}
|
||||||
self.setViewControllers(controllers, animated: animated)
|
self.setViewControllers(controllers, animated: animated)
|
||||||
|
self.ignoreInputHeight = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
|
|||||||
private(set) var dismissProgress: CGFloat = 0.0
|
private(set) var dismissProgress: CGFloat = 0.0
|
||||||
var isReadyUpdated: (() -> Void)?
|
var isReadyUpdated: (() -> Void)?
|
||||||
var updateDismissProgress: ((CGFloat, ContainedViewLayoutTransition) -> Void)?
|
var updateDismissProgress: ((CGFloat, ContainedViewLayoutTransition) -> Void)?
|
||||||
var interactivelyDismissed: (() -> Void)?
|
var interactivelyDismissed: ((Bool) -> Void)?
|
||||||
|
|
||||||
private var ignoreScrolling = false
|
private var ignoreScrolling = false
|
||||||
private var isDismissed = false
|
private var isDismissed = false
|
||||||
@ -152,8 +152,9 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let hadInputFocus = viewTreeContainsFirstResponder(view: strongSelf.view)
|
||||||
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: strongSelf.view)
|
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: strongSelf.view)
|
||||||
strongSelf.interactivelyDismissed?()
|
strongSelf.interactivelyDismissed?(hadInputFocus)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
self.horizontalDismissOffset = nil
|
self.horizontalDismissOffset = nil
|
||||||
@ -194,7 +195,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if targetOffset == 0.0 {
|
if targetOffset == 0.0 {
|
||||||
strongSelf.interactivelyDismissed?()
|
strongSelf.interactivelyDismissed?(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.ignoreScrolling = false
|
self.ignoreScrolling = false
|
||||||
@ -255,7 +256,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if targetOffset == 0.0 {
|
if targetOffset == 0.0 {
|
||||||
strongSelf.interactivelyDismissed?()
|
strongSelf.interactivelyDismissed?(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.ignoreScrolling = false
|
self.ignoreScrolling = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user