Skip to content

Commit

Permalink
Fixing keyboard support in drawers (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialee0416 authored Dec 5, 2023
1 parent 5b5ca0a commit 8fd3718
Showing 1 changed file with 7 additions and 3 deletions.
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
}
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

0 comments on commit 8fd3718

Please sign in to comment.