Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing keyboard support in Drawers #1938

Merged
Merged
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
10 changes: 7 additions & 3 deletions ios/FluentUI/Drawer/DrawerPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class DrawerPresentationController: UIPresentationController {
}
case .up:
if actualPresentationOrigin == containerView.bounds.maxY {
return containerView.safeAreaInsets.bottom + keyboardHeight
return keyboardHeight == 0 ? containerView.safeAreaInsets.bottom : keyboardHeight
mischreiber marked this conversation as resolved.
Show resolved Hide resolved
}
case .fromLeading:
if actualPresentationOrigin == containerView.bounds.minX {
Expand Down Expand Up @@ -344,6 +344,9 @@ class DrawerPresentationController: UIPresentationController {
}

private func frameForContentView(in bounds: CGRect) -> CGRect {
guard let containerView = containerView else {
return .zero
}
var contentFrame = bounds.inset(by: marginsForContentView())

var contentSize = presentedViewController.preferredContentSize
Expand Down Expand Up @@ -380,7 +383,8 @@ class DrawerPresentationController: UIPresentationController {

contentFrame.origin.x += (contentFrame.width - contentSize.width) / 2
if presentationDirection == .up {
contentFrame.origin.y = contentFrame.maxY - contentSize.height
contentFrame.origin.y = keyboardHeight != 0 ? max(landscapeMode ? 0 : sourceViewController.view.safeAreaInsets.top,
containerView.frame.maxY - keyboardHeight - contentSize.height) : contentFrame.maxY - contentSize.height
}
} else {
if actualPresentationOffset == 0 {
Expand Down Expand Up @@ -510,7 +514,7 @@ class DrawerPresentationController: UIPresentationController {
keyboardAnimationDuration = (notificationInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue

keyboardFrame = containerView.convert(keyboardFrame, from: nil)
keyboardHeight = max(0, containerView.bounds.maxY - containerView.safeAreaInsets.bottom - keyboardFrame.minY)
keyboardHeight = max(0, containerView.bounds.maxY - keyboardFrame.minY)
}
}

Expand Down