Fixed overlay presentation when keyboard window is about to be hidden or appears to remain on the screen when it actually doesn't.

Added keyboard-awareness to tab bar on iPad.
This commit is contained in:
Ilya Laktyushin 2018-10-22 18:59:00 +03:00
parent 06b1bc2bdd
commit b34f174520
2 changed files with 11 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import Foundation
import AsyncDisplayKit
import SwiftSignalKit
private func isViewVisibleInHierarchy(_ view: UIView) -> Bool {
private func isViewVisibleInHierarchy(_ view: UIView, _ initial: Bool = true) -> Bool {
guard let window = view.window else {
return false
}
@ -12,7 +12,11 @@ private func isViewVisibleInHierarchy(_ view: UIView) -> Bool {
if view.superview === window {
return true
} else if let superview = view.superview {
return isViewVisibleInHierarchy(superview)
if initial && view.frame.minY >= superview.frame.height {
return false
} else {
return isViewVisibleInHierarchy(superview, false)
}
} else {
return false
}

View File

@ -36,7 +36,7 @@ final class TabBarControllerNode: ASDisplayNode {
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
let update = {
let tabBarHeight: CGFloat
var tabBarHeight: CGFloat
let bottomInset: CGFloat = layout.insets(options: []).bottom
if !layout.safeInsets.left.isZero {
tabBarHeight = 34.0 + bottomInset
@ -44,6 +44,10 @@ final class TabBarControllerNode: ASDisplayNode {
tabBarHeight = 49.0 + bottomInset
}
if let inputHeight = layout.inputHeight, layout.metrics.widthClass == .regular {
tabBarHeight += inputHeight
}
transition.updateFrame(node: self.tabBarNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - tabBarHeight), size: CGSize(width: layout.size.width, height: tabBarHeight)))
self.tabBarNode.updateLayout(size: layout.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, bottomInset: bottomInset, transition: transition)
}