Fixed a bug that left a blank at the bottom of the screen (flutter/engine#17474)

I fixed a bug that left a blank at the bottom of the screen when the iPad's split keyboard was hidden.

I also had the same problem with this issue, so I fixed it.
iPad split keyboard cause a blank space problem

There is no function to change the space size at the bottom of the screen when the split keyboard is moved. This is because it's not clear what the keyboard should do when it's moved to the top of the screen.
This commit is contained in:
Ryoichi Izumita 2020-04-08 03:27:15 +09:00 committed by GitHub
parent 33843702fe
commit fee9895d51

View File

@ -953,13 +953,23 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
- (void)keyboardWillChangeFrame:(NSNotification*)notification {
NSDictionary* info = [notification userInfo];
CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]);
CGFloat scale = [UIScreen mainScreen].scale;
CGRect keyboardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect screenRect = [[UIScreen mainScreen] bounds];
// Considering the iPad's split keyboard, Flutter needs to check if the keyboard frame is present
// in the screen to see if the keyboard is visible.
if (CGRectIntersectsRect(keyboardFrame, screenRect)) {
CGFloat bottom = CGRectGetHeight(keyboardFrame);
CGFloat scale = [UIScreen mainScreen].scale;
// The keyboard is treated as an inset since we want to effectively reduce the window size by
// the keyboard height. The Dart side will compute a value accounting for the keyboard-consuming
// bottom padding.
_viewportMetrics.physical_view_inset_bottom = bottom * scale;
} else {
_viewportMetrics.physical_view_inset_bottom = 0;
}
// The keyboard is treated as an inset since we want to effectively reduce the window size by the
// keyboard height. The Dart side will compute a value accounting for the keyboard-consuming
// bottom padding.
_viewportMetrics.physical_view_inset_bottom = bottom * scale;
[self updateViewportMetrics];
}