Fix calculating the position of the keyboard in ComposeContentViewController (#909)

Co-authored-by: Marcus Kida <marcus.kida@bearologics.com>
This commit is contained in:
Jed Fox 2023-04-12 08:39:17 -04:00 committed by GitHub
parent 0b9277db37
commit e2ef9f07a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -207,7 +207,15 @@ extension ComposeContentViewController {
self.tableView.contentInset.bottom = padding - self.view.safeAreaInsets.bottom
self.tableView.verticalScrollIndicatorInsets.bottom = padding - self.view.safeAreaInsets.bottom
UIView.animate(withDuration: 0.3) {
self.composeContentToolbarViewBottomLayoutConstraint.constant = endFrame.height
// ref: https://developer.apple.com/documentation/uikit/uiresponder/1621578-keyboardframeenduserinfokey
let localKeyboardFrame = self.view.convert(endFrame, from: self.view.window!.screen.coordinateSpace)
let intersection = self.view.bounds.intersection(localKeyboardFrame)
if intersection.isEmpty {
self.composeContentToolbarViewBottomLayoutConstraint.constant = 0
} else {
self.composeContentToolbarViewBottomLayoutConstraint.constant = self.view.bounds.maxY - intersection.minY
}
self.view.layoutIfNeeded()
}
})